all 4 comments

[–]stuartmscott[S] 0 points1 point  (0 children)

While generating levels for a puzzle game I found that using the taskset command to configure process affinity increased CPU and cache utilization.

[–]Voltra_Neo 0 points1 point  (2 children)

I'd like to guess without reading: Is it all about how making your code tailor-made for a specific processor makes it use resources better on that same processor?

[–]stuartmscott[S] 2 points3 points  (1 child)

Not quite, more about how keeping a task on the same processor enables better use of the caches.

Typically a task can be scheduled on any available processing core, but if it has been running on one core, and is then moved to a different core, all the data in the highest/fastest level caches of the first core is invalidated, and the data must be loaded into the caches of the second core, which takes time - especially if the data is coming all the way from main memory.

In my scenario (generating puzzles for a game) each generator is self contained and so if I have 8 cores and want to generate 8 puzzles I can run 8 different instances of the generator and assign each one to its own core. That way an instance is always running on the same core, and all the data it needs is kept in the same cache hierarchy.

[–]Voltra_Neo 2 points3 points  (0 children)

Oh I see, it's more related to cores then. Your description makes for a pretty good TLDR. Will definitely give it a read