bhargavwork

CPU Is Only 30% Busy. Can It Still Be the Bottleneck?

Performance Analysis 101 - Part 2

Seven compiler jobs have finished. One is still working on the last object file. Until it finishes, the build system cannot launch the linker. You are still waiting, and across an eight-processor machine, the CPU graph reads 12.5%.

Idle processors cannot compile a file that is already being handled by one compiler process, and they cannot start linking before every required input exists. That is why a machine can look mostly idle while CPU execution time is still holding up the result you are waiting for.

In Part 1, we looked at an eight-processor illustration averaging 30% utilisation and asked whether spare CPU time elsewhere actually helps the critical path. The real question is never “How much CPU is unused?” It is: can the work holding me up actually use that CPU?

Illustrative diagram of eight logical processors before a link step: LP 0 is 100% busy compiling last_file.cpp while LP 1 through LP 7 sit idle at 0% busy because Link cannot launch until last_file.o is ready.
Illustrative build stall: seven idle logical processors cannot start the link step before the last prerequisite object file finishes.

What 12.5% Actually Means (and the Denominator Trap)

Before investigating a trace, it helps to be precise about what an aggregate CPU percentage measures.

Suppose a machine exposes eight logical processors to the operating system scheduler, and one thread runs continuously on a single logical processor while the other seven are idle. In an equal-weight system-wide view, that thread consumes one-eighth of the available logical-processor time: 12.5%.

Notice the wording: one-eighth of available logical-processor time, not one-eighth of some abstract raw compute budget. Modern cores share execution resources, frequency/thermal headroom, and memory bandwidth, especially when simultaneous multithreading (SMT) exposes two logical processors per physical core. So 12.5% tells you how much scheduled processor time was used across the machine’s logical processors over that sampling interval - not how much additional throughput the hardware could still deliver.

That arithmetic also explains a visual trap in system monitors. Take the exact same single-threaded workload and run it on a machine with four logical processors: one continuously scheduled thread reads as roughly 25% total CPU utilisation. Move that exact same thread onto a machine with sixteen logical processors, and it reads as roughly 6.25%.

The percentage dropped by a factor of four. Did the program become less CPU-bound? No - only the denominator grew, because we added logical processors that a single serial thread cannot use. On high-core-count machines, a single-digit CPU reading can look harmless while still representing a hard serial bottleneck on your critical path.

Illustrative arithmetic comparing one continuously busy logical processor across machines with 4, 8, and 16 logical processors, reporting 25.0%, 12.5%, and 6.25% total CPU respectively.
Illustrative arithmetic: the same serial thread reports 25.0% on 4 logical processors, 12.5% on 8, and 6.25% on 16. Only the denominator changed.

Available Capacity vs. Available Parallel Work

Why doesn’t the operating system simply spread that remaining work across the seven idle logical processors?

Because a processor cannot execute work that does not exist yet, and it cannot run the second half of a dependency before the first half produces its inputs. Suppose a calculation consists of four dependent steps: A finishes, then B consumes A’s output, then C, then D. You cannot schedule A on one logical processor and B on another to finish both together. B’s inputs are not ready.

There is a fundamental difference between available CPU capacity (idle scheduling slots on the hardware) and available parallel work (independent operations ready to run right now).

Click Search in a web application, and a heavy JavaScript handler starts running. The browser and operating system have dozens or hundreds of other threads, and most logical processors may look quiet. If layout, painting, or the next UI step cannot start until that handler finishes, spare capacity elsewhere on the chip cannot shorten your wait.

Even when parallel work does exist, it still has to sit on the right path. Imagine running one slow critical operation alongside ten unrelated background indexing jobs. System-wide CPU utilisation climbs, and plenty of logical processors stay busy, yet none of that background activity brings your result any closer.

Utilisation measures activity. Performance work cares about progress.

A Worked Investigation: Why a Software Build Stops Scaling

How do you actually tell whether lack of usable parallelism is holding up work on your machine?

A software build is one of the cleanest workloads to investigate because it gives you a visible finish line (the final binary), a worker count you can adjust directly (-j), and clear dependency edges between compilation and linking.

Suppose you suspect a build is bottlenecked by lack of usable parallelism rather than raw CPU speed. A worker sweep alone - timing -j 1, -j 2, -j 4, -j 8, -j 16 on an eight-logical-processor machine - is a great first experiment, provided you control the conditions:

  • Start from the exact same source revision for every trial.
  • Use a fresh build directory each time so incremental artifacts do not skew later runs.
  • Keep the compiler-cache policy consistent (either disabled across all runs or warmed identically).
  • Repeat each worker count more than once to spot background noise or thermal drift.
  • Record both elapsed wall-clock time and which job the linker waited for at the end.

Consider an illustrative worked sweep (constructed timings to show the diagnostic reasoning, not a recorded benchmark of a specific project):

Workers (-j)Elapsed TimeSpeedup vs. -j 1Illustrative build timeline
1120 s1.0xOne compiler process busy throughout; ~12.5% on 8 logical processors.
264 s1.9xClean parallel scaling across independent source files.
436 s3.3xMost files compile concurrently; a brief single-job tail appears before link.
826 s4.6xSeven workers finish around 16 s; one heavy file takes 22 s, then link runs 4 s.
1625 s4.8xNearly flat vs. 8; -j 16 permits sixteen concurrent build jobs on hardware that still has eight logical processors, and the same long file plus serial link dominate the tail.

Notice what each piece of evidence establishes, and what it leaves open. From elapsed times alone, you learn that scaling flattens past four to eight workers: raising the job limit from eight to sixteen saved one second overall on hardware that still has eight logical processors. You have moved from “the CPU graph looks low” to “adding workers beyond eight barely shortens the build.”

The timeline shows that the same compilation still held up the link: seven workers finish around 16 s, while one translation unit finishes at 22 s and the 4 s link launches only after that final object becomes available. That accounts for the idle logical processors from 16 s to 22 s - there is no ready work left until that straggler finishes. To establish that CPU execution held up those six seconds rather than the compiler thread spending part of that window blocked on I/O, you still inspect the compiler thread itself during 16 s to 22 s. And you can challenge the diagnosis with a testable prediction: if this compilation finishes one second earlier and remains the last prerequisite, the link should start one second earlier.

Illustrative build timeline. Seven workers finish around 16 seconds. The final compilation ends at 22 seconds and linking finishes at 26 seconds.
Illustrative -j 8 build. The link starts at 22 seconds, when its final object file is ready.

Why “Dominates Total CPU Time” Can Mislead You

This build scenario also exposes a subtle trap for beginners. It is tempting to assume that if a single job or thread limits latency, it must top the cumulative CPU-time ranking over the whole run.

Not always. Imagine a build where seven compiler jobs each consume 10 s of CPU time and finish together, while an eighth job consumes 4 s of CPU time but starts later in the dependency graph and finishes 100 ms after the other seven. Over the full build, that eighth job ranks near the bottom in total CPU seconds. Yet those final 100 ms are what delayed the link and pushed out the build’s finish time.

What puts work on the critical path is when it runs relative to the dependencies waiting on it, not whether it accumulated the largest CPU total across the entire interval.

Amdahl’s Law: The Elapsed-Time Ceiling

That flattening curve follows a general rule about elapsed time.

For a separate example, suppose 20% of the one-worker elapsed time must remain serial and cannot be parallelised, while the remaining 80% divides cleanly with zero overhead across as many logical processors as we supply. (Real workloads also pay synchronisation, scheduling, and memory-bandwidth costs, so treat this as a clean arithmetic upper bound.)

With 1 logical processor, the job takes 100% of its baseline elapsed time. As you add processors, the 80% parallel share shrinks (80% / N), while the 20% serial share stays untouched. Even in the theoretical limit of infinitely many processors, where the parallel portion approaches zero elapsed time, the 20% serial work remains. Total elapsed time cannot drop below one-fifth of the baseline, capping maximum speedup at 5x.

That is Amdahl’s Law: the portion of a workload that cannot use additional resources eventually sets the ceiling on how much elapsed time those resources can save.

Running, Runnable, and Waiting

So far, we looked at a build where a compiler process stayed busy while other logical processors went idle. Now flip the symptom: you inspect the thread your result depends on, and it accumulated almost no CPU time during a slow interval.

Giving that thread more logical processors might help - or might do absolutely nothing - depending on which of three scheduler states it spent that time in:

  • Running: actively scheduled and executing instructions on a logical processor.
  • Runnable (ready to run): ready to execute, sitting in the scheduler’s queue waiting for a logical processor to become free.
  • Waiting (blocked): asleep and not runnable at all until an external event completes - disk I/O, a network packet, a timer, or a synchronisation primitive held by another thread.

Every one of those states sends your investigation down a different branch.

If the critical thread spent most of the delay runnable on an overloaded machine, it was starved for CPU scheduling time - reducing competing work or adding cores can actually help. If it was running continuously on a serial step, it needs faster single-thread execution or less work on that path.

And if it was blocked on a lock, the investigation does not end with “it was asleep.” That finding gives you a new subject: what was the lock holder doing? The thread holding that lock might itself be running heavy CPU work - meaning a CPU-bound bottleneck on Thread B appeared as a sleeping wait on Thread A. Following the wakeup chain is what turns a raw thread state into a real diagnosis.

Illustrative 100 ms interval comparing two threads that each log 20 ms of running CPU time: Case A spends the remaining 80 ms runnable in the scheduler queue, while Case B spends 80 ms blocked waiting on a lock holder or I/O.
Illustrative 100 ms interval: both cases record 20 ms of CPU time, yet scheduler starvation and lock blocking require opposite fixes.

Load Imbalance, Barriers, and Why Traces Beat Aggregates

Two common patterns produce low aggregate CPU readings even in multi-threaded code that looks parallel on paper:

  • Load imbalance: Work is partitioned statically across eight workers, seven draw light chunks and finish early, and the eighth draws a heavy partition and runs twice as long. Seven logical processors sit idle waiting for one straggler.
  • Synchronisation barriers: Threads must reach a shared barrier or lock before advancing to the next stage. One delayed thread stalls the rest, dropping total CPU utilisation while everyone waits on the late arrival.

In both cases, a sampling profiler tells you which functions accumulated CPU samples, while an aggregate utilisation graph averages everything across cores and time. Neither shows the sequence of dependencies. A timeline trace with scheduler events records when each thread ran, when it became runnable, when it blocked, and which wakeup unblocked it; pairing those scheduling intervals with a call stack or build event lets you identify the particular lock, file, or build dependency on the critical path.

Latency vs. Throughput

None of this means spare logical processors go to waste. It means we need to be clear about which performance metric we are trying to improve.

If you have eight completely independent single-threaded jobs, running one job on an eight-processor machine will not cut that single job’s latency eightfold. Those extra logical processors can, however, run all eight jobs concurrently, raising system throughput (jobs completed per unit of time) even though individual job duration stays roughly the same.

Before declaring spare CPU “wasted headroom”, check whether your goal is making one critical task finish sooner or completing more independent tasks per hour.

Before Part 3: Inspect One Slow Interval Yourself

Pick one slow operation you can reproduce on your machine - a local software build with -j, a script, or an application action.

  1. Mark the interval: Note when the delay begins and when the result you care about finishes.
  2. Identify the critical thread or job: Determine which thread or process the next step had to wait for (for example, the last compiler job blocking the link, or the UI/handler thread blocking rendering).
  3. Check its scheduler states, if your trace shows them: Remember that a thread can migrate between logical processors while running, and a thread with 20 ms of CPU time during a 100 ms delay looks identical in CPU totals whether it spent the other 80 ms runnable in a queue or asleep on a lock. If you have a scheduler trace (such as perf sched, Windows Performance Recorder, or Instruments), measure how much of the interval that thread spent running, runnable, and blocked.
  4. Follow any block one step further: If it was blocked, record what had to happen before it could wake up - disk I/O, network response, or the lock holder’s own activity.
  5. Be honest about tool limits: If all you have is a task-manager CPU graph, write down which question remains open. “I cannot tell from this graph alone whether the critical thread was running across migrating cores, waiting in the run queue, or blocked” is a completely valid and accurate result.

Where This Leads Next: Active Cycles Are Still Only Evidence

Suppose you run that investigation, trace the critical thread through the slow interval, and confirm it really was running continuously - not blocked on I/O, not waiting on a lock, and not stuck in the scheduler queue.

Have you proven that the processor’s arithmetic units are maxed out?

Not yet. An operating system marks a thread as 100% running whenever it occupies a logical processor, even if the core spends half of those cycles stalled inside its own pipeline - waiting on instruction fetch, recovering from branch mispredictions, or waiting for data to arrive from L2 cache, last-level cache, or main memory.

We have established which thread sat on the critical path and that it was actively scheduled. Next, in Part 3: The CPU Is Fast… So Why Is It Waiting for Memory?, we step inside that running thread to see why a processor executing billions of cycles per second still spends much of its time waiting on the memory hierarchy.

Warm regards, Bhargav

References

  • Bhargav Achary - Performance Analysis 101 - Part 1: Why a Fast Computer Can Still Feel Slow, 3 November 2026.
  • Microsoft Learn - CPU Analysis (Windows Performance Toolkit guidance on aggregate CPU utilisation, thread states - running, ready, waiting - and critical-path analysis).
  • Gene M. Amdahl - Validity of the single processor approach to achieving large scale computing capabilities, AFIPS Spring Joint Computer Conference, April 1967 (origin of Amdahl’s Law).

Comments powered by Disqus.

This post is licensed under CC BY 4.0 by the author.