Re:Taking a Look at CLR Thread Pool 'Thread Injection' Algor...
by matthewwarren on Friday April 14, 2017 @05:51AM
(#14113503)
Yeah there's only so much the Thread Pool can do, it doesn't have the same knowledge of your workload as you do.
They have added things like work-stealing to it, which might help with task locality in some scenarios
In cases where you know you are going to be running very many jobs on your thread pool you can get improved throughput by assigning each thread a specific job type so that it can blast through many jobs of the same type with better locality and less overhead. You can also leverage the underlying platform thread pool to spin up the job type workers and run them for a bit to avoid managing thread counts yourself.
To a degree if you're using an existing parallel framework it may do this for you, but at least on the CLR the options there like Parallel.For aren't so great - lots of abstraction overhead that will show up in profiles.