My question is addressed to performance issues in multithreading at Windows environment.
After testing my code I got results that increasing the number of threads do not increase the performance of parallel calculations and became less after some count. What is going on? Is it possible to find out the formula of optimal threads number: F(processors, memory..) = ?
My question is addressed to performance issues in multithreading at Windows environment. After testing
Share
It depends on what the threads are doing. If they are primarily CPU-bound, then the optimal number of threads is 1 per processor core. If they do any significant IO where they are waiting for response from the kernel, then more threads will increase performance.
There is context-switching overhead when you have more than one thread per core, so increasing the number of threads for CPU-bound calculations will always hurt performance.