Saturday 15 September 2012

c# - Determining the most efficient number of threads to use depending on system specs -


How is the maximum / correct number used for the given operation for a given system? I have an operation that can be completed anywhere from 1 to 100 threads. I can run a few tests and find out that it is the most efficient, but it seems that it relies heavily on the user's system.

Based on the number of core, OS etc, there is no such example for this? ?

I am working in C # .NET, although I'm not sure that it will make a difference.

There is no simple rule for this, depending on what they are doing entirely in this formula is. If they are burning the core then the ideal number is not much more than the number of available machines in the machine. To add more, the OS allows additional work-switching between them.

But if they do any I / O, they will be blocked for a long time, waiting for I / O to complete. In that case the ideal can be big, but it depends entirely on the concurrency in the I / O subsystem.

And sometimes the ideal is only one which is the case if thread execution is completely bound to a resource in which your machine is only one. Like memory bus or disk.

You have to measure. Review the Wikipedia article, select the number where the curve turns out. Look for caching effects that look like your program will actually do in practice. Repeating the disk-bound program repeatedly and actually obtaining data from the file system cache in place of the disk.

No comments:

Post a Comment