0

I've been running a single-threaded brute force version of the famous Traveling Salesman Problem, and YourKit is pinpointing me the fact that the CPU is being used at 25%, at most.

What's the reason behind that fact? We've been told that these kind of algorithms are highly CPU intensive, yet there seems to be a lot of wasted CPU in this case.

My theory is the bottleneck must be the RAM access. Locking issues seem to be out of question, as the algorithm I'm running is single-threaded.

Am I right?

devoured elysium
  • 101,373
  • 131
  • 340
  • 557

2 Answers2

6

Promoting comment to answer.

You say your program is single-threaded, but you're only using 25% CPU.

That's an indication that you have a quad-core machine. (or perhaps dual-core with Hyper-Threading) With a single-thread, you cannot use more than 1 core.

So what you're seeing is normal.


As a side point, bottlenecks such as locking and memory access do not directly decrease your CPU usage. A single-threaded program that spends the whole time cache missing will still show the same 25% usage (on quad-core) as one that is running real computation.

In multi-threaded applications, CPU usage could be affected if such bottlenecks block other threads from running or if they affect load-balance.

Mysticial
  • 464,885
  • 45
  • 335
  • 332
4

...the CPU is being used at 25%, at most.

Do you have 4 cores (with or without Hyperthreading)?

What happens: your one process jumps between the four cores. For one core this gives an average utilization of 25%.

My theory is the bottleneck must be the RAM access. Locking issues seem to be out of question, as the algorithm I'm running is single-threaded.

RAM access time is not accounted individually, it's part of the CPU time.

A.H.
  • 63,967
  • 15
  • 92
  • 126