3
$\begingroup$

Perhaps this isn't exactly a computer science question, but I thought this wouldn't strictly fit in Electrical Engineering either. Let me know if I should move this somewhere else

Suppose I have a process that is single-threaded and rather poorly optimised. It doesn't max out my processor, and instead stays stuck at around 20% usage. Would overclocking my CPU even really affect the running speed?

$\endgroup$
  • $\begingroup$ Is that 20% of a single core? If so, the process is waiting for the IO (disk, network, ...) or intentionally sleeping (unlikely). Making the CPU faster would lead to no improvement, since the bottleneck is elsewhere. $\endgroup$ – chi Sep 28 '17 at 12:56
  • 1
    $\begingroup$ @chi Not no improvement, since the 20% would be sped up. Amdahl's law applies, so gains would be small. $\endgroup$ – Raphael Sep 28 '17 at 14:23
  • $\begingroup$ @Raphael Ah, you are right. I was too quick to assume the disk/whatever was 100% busy, which is likely not to be the case. $\endgroup$ – chi Sep 28 '17 at 15:58
9
$\begingroup$

Optimization is not really something that should be guessed at. Instead you need to measure what is going on to determine the chokepoints and where changes need to be made.

A faster processor may have little or no effect especially since the CPU utilization is not maxed out. CPU speed affects only those parts of the program which are actually running on the CPU. If the program is waiting for something else such as an I/O operation, a faster CPU doesn't help. The chokepoint is not the CPU speed but rather the I/O speed.

So you may have a faster CPU but that just means that your program gets to a place where it has to wait for something else to happen a bit faster. If your program requires user input then no matter how fast the CPU, the program is still bounded by the speed of a human doing the input.

Program speed also is affected by the algorithms being used. A faster CPU may help a bad algorithm go faster, a kind of linear increase, a better algorithm may provide several orders of magnitude improvement in speed and performance.

Another possible throughput increase can come from multi-threading. This only really helps if you can divide out the overall problem into multiple, asynchronous tasks that can be run simultaneously and the results of each task combined when all are done. The more need there is for synchronizing tasks and events the more likely that multi-threading will not provide that much of an improvement.

With multi-threading there is always the question of how many separately running cores are in the CPU or how many CPUs are being used for the program.

Multi-threading with a single core on a single CPU may or may not help since the various threads are sharing the same core and CPU. It depends on whether some threads are able to progress while other threads are waiting for some resource or event to happen such as I/O to complete.

If you are able to divide out the program into multiple threads and assign the different threads to different CPU cores or multiple processes and assign the different processes to different CPUs then more things can be happening simultaneously. However if all those threads are not compute intensive and are waiting rather than running then it may not make that much difference.

Finally the actual hardware design can make a large difference in the throughput of a CPU. Overclocking a CPU means that it is running faster however it is the same hardware. The differences in throughput between various CPU generations is not due to just CPU clock speed. There are also hardware improvements so that two CPUs with the same clock speed will show very different processing throughput because the hardware design of one is superior to the other. This is where design details such as branch prediction, prefetch, size of the onboard cache, and other hardware details really make a difference.

$\endgroup$
  • 5
    $\begingroup$ Spot on. I once had to deal with such an issue where devops was throwing insane amounts of computing power at a build job that took 30 hours to complete. Turns out it was i/o bound because all dependencies were pulled over a slow network link to make the build "easier" to execute. One simple pre-caching step for deps, installing an SSD, and using fewer CPUs, had the build down to 15 minutes, and our monthly AWS/CC3 bill down a lot. Measly $500 bonus though. $\endgroup$ – Cloud Sep 28 '17 at 17:26
3
$\begingroup$

Yes, overclocking will speed up the process, but probably not by much.

If the program can't utilize a CPU core to 100% that means it's waiting for something, most likely IO. That waiting won't be sped up as CPU speed increases. However, at least sometimes the program will do some computation on the CPU. For those operations a faster clock helps.

Most likely you would see a 10% utilization if you doubled your processor speed since the waiting time dominates. How much overclocking helps depends on the exact program.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.