Experiment with pinning worker threads to physical CPU threads
Integrate the following library https://github.com/OpenHFT/Java-Thread-Affinity (most likely Linux only) and measure performance difference on a purely CPU bound benchmark (WorkStealingBenchmark.alloc might be a good candidate, or ParallelBenchmark).
I doubt that this issue has a clear road to being shipped as part of a Cats Effect release, but it would be a cool experiment nonetheless.
I doubt that this issue has a clear road to being shipped as part of a Cats Effect release
Out of curiosity, Is there a good way this could be implemented as an alternative runtime (i.e. as its own project)?
The integration point of this experiment is not with Cats Effect (I only imagine that we would need to call a couple of library methods in the WorkerThread/WorkStealingThreadPool constructor methods to pin each thread to a certain CPU) but with the native libraries/OS/sbt setup prior to running anything, and whether or not that's doable or even worth it.
Very cool! A worthy experiment imo
Affinity pool is lives in akka now, super cool to see it lands in ce too
@hepin1989 I assume you mean the pool introduced in https://github.com/akka/akka/pull/23104, which pins actors to threads?
Note that the Work Stealing Thread Pool in Cats Effect provides high affinity of fibers to threads. You can read about it here: https://typelevel.org/cats-effect/docs/thread-model#work-stealing-pool
The goal of this issue is to experiment with pinning JVM threads to physical CPU threads (in addition to pinning fibers to JVM threads).
Oh, I'm sorry, I didn't realize that Akka is also using https://github.com/OpenHFT/Java-Thread-Affinity. Interesting :)
Edit: Nope, nevermind, seems it was removed during review of that PR in https://github.com/akka/akka/pull/23104#discussion_r123489400.
Fwiw, I think we have fairly solid evidence at this point that dynamic soft pinning behaves a lot better, particularly since the JIT and GC will always wander around and contend us away from things.