In my program, I have several threads that are started with the process and that remain until the program ends. They will meet different loads during the lifetime of the app, and at times they will all run at 100%.
By default the Linux thread scheduler will change affinity on a multi-core system for these threads quite frivolously IMO. When I look at the bouncing graphs in my graphical process monitor (the one in gnome) I can't help but think that this constitutes some kind of overhead.
EDIT: To clarify, even for very stable loads, the threads are scheduled on different cores, and even though it is not visible in the image provided it is at times very clear that the core selected for each thread is "swapped" frequently.
Will not this constant change in affinity affect performance adversely?
In that case, why is it implemented this way? What benefits does the changing affinity have?
My guesses are:
- Wear levelling - Don't put all the work on one core
- Unintentional - Some smart algorithm tries to optimize usage depending on load and it so happens that the overhead of is not significant enough to warrant keeping the affinity over changing it.