1

I read the packets from NIC in high rate and my writing speed is my program bottleneck would be caused packet losts. I browsed the web for solutions, and have reformed my code with AIO solutions and neither POSIX nor Linux-libaio satisfy my requirement for high rate writing with no lost.

Now I want to have a specific thread as writer in AIO which is bound to specific CPU core which is separated from program's main core.I tried to do that with POSIX and Linux-libaio but failed. POSIX creates two threads while program execution but both of them are on same CPU.

It will be appreciated if anyone help me to know that is there any possibility to persuade OS to create a specific thread in AIO as writer and assign a specific CPU core to it?

Note: my programming language is C on Linux

Resist
  • 73
  • 6
  • Possible duplicate of [How to assign threads to different cores in C?](https://stackoverflow.com/questions/53542815/how-to-assign-threads-to-different-cores-in-c) – roschach Jan 16 '19 at 09:38
  • Possible duplicate of [how to set CPU affinity of a particular pthread?](https://stackoverflow.com/questions/1407786/how-to-set-cpu-affinity-of-a-particular-pthread) – rustyx Jan 16 '19 at 09:56
  • This will make your writing slower as the data will always have to be handed off from the core that's only doing AIO initiation to whatever core is running the code that actually does the I/O. Perhaps worse, it'll also have to be handed off from the core that received the packet to the core that's running the AIO code first. You don't know better than the OS which core is the best one to run this code on. Why force its hand? – David Schwartz Jan 16 '19 at 13:22
  • How much data in total are you trying to write? What's your disk's sequential speed? How fast is the data coming in? How much RAM are you willing to use for buffering? – David Schwartz Jan 16 '19 at 13:24
  • If by "libaio", you're talking `io_submit`, then there's nothing automatic with threading. You'll have to roll your own thread and get the data over there. `io_submit` is not really non-blocking. You can expect to be in that call for several microseconds or longer, depending on the situation. So depending on your design, it can be beneficial to sequester it in its own thread. – Mike Andrews Jan 16 '19 at 21:16
  • Actually I have analyzed the program via htop which showed me up that packets lost would occur when loads on responsible CPU core increase to 100 percent. So I have been deciding to persuade OS to create a specific thread in AIO as writer and assign a specific CPU core to it. My program read rate is more than 1.1 MB per second and I'm sure that program bottleneck is it's writing speed which occurs as aforementioned. – Resist Jan 19 '19 at 04:07

0 Answers0