.net - Why ThreadPool has 250 worker threads per processor by default? -
taken from Microsoft documentation:
By default, 250 worker threads in thread pool There are available processors you can change this setting using the ThreadPool.SetMaxThreads method.
This is also called because it is widely known that there is some overhead:
Some levels of thread overhead, if a computer There are multiple processors and if you split processing into two threads, you will not see improvement in 100 percent performance.
More from some of the experiences, D has a 1 to 4 thread per CPU, and 250 is not ! Does anyone know why 250? Is there any value that is used to give the best overall performance , or so that you give it to that pool pool in every
Inspiration is not displayed. As you have mentioned, having too much thread can easily reduce performance (due to context switching, cash thrashing, content etc.).
The idea behind this magical number is that the deadlock user code. A developer might cause a deadlock if he quits multiple work items for a thread pool that waits at other items in the queue of the thread pool if a situation occurs where the thread pool uses its maximum threads (They're all waiting in the state), you've got a deadlock
Of course there is nothing special with the number "250", and even if the deadlock is generated If you can Evlpr insist on using such a problematic use patterns of the thread pool. However, in such scenarios, the chance of reaching a stalemate may be reduced.
Joe Duffy explains this logic more deeply in his post:.
Comments
Post a Comment