Is there a way to find out inside a .NET application whether Im is currently limited by CPU time or if IO is a bottleneck?
I am requesting a bunch of remote network services, the details of which are not significant and can be abstracted as:
// perform a single operation if ( [randomness] ) { sleep(10s of seconds); // DNS/TCP connection timeout } else { sleep(10s of miliseconds); // query a remote server } for x = 1β¦lots { // Do some CPU intensive work }
While I have a processor, Id can schedule as many of them as possible, because they will wait a long time for I / O, but as soon as the processor is fully loaded, I do not want to support spawning threads, because this will lead to increased performance collapse. The total number of tasks is "large."
The obvious answer would be to simply select βa reasonable amount of parallel threads as the setting, but this has two problems:
- The length of "sleep" can vary widely between a round trip on a local network and a TCP connection timeout, so the ratio of CPU to I / O latency can vary by 3 orders of magnitude.
- The size of the machine on which it will run can vary from a small single CPU to a machine with a heavy weight.
In an ideal world, I / O operations will all be replaced with asynchronous termination callbacks, but this is not easy / possible in this case, since the network RPC uses the existing blocking code.
source share