After fixing a program, you need to turn the code into something executable and test that it works properly. In a post published on November 12, 2026, developer Farzad Zakaria analyzed how long it takes to build and test the software library libuv. Running the process on a single virtual CPU took 78 seconds, and about two-thirds of the 47.4 seconds on the chain of tasks that determined the completion time involved waiting rather than computation. 1
Time in the 78 seconds that is not easy to cut
A build turns human-written code into an executable form, while testing checks whether the result behaves as expected. In this case, Zakaria added a time-analysis feature to Rewind, a virtual environment that records executions and can replay them, and used it to examine the build and tests for libuv 1.51.0. 1
The analysis starts with the critical path. When one task must finish before the next can begin, the critical path is the chain of linked tasks that holds up completion the longest. Independent tasks can be handled simultaneously by adding CPUs, but adding more workers cannot make a task start immediately if it has to wait for the result of an earlier step. 1
The actual runtime and the length of the critical path in this recording were as follows. The 47.4 seconds is a theoretical lower bound calculated from the task dependencies and recorded task times; it is not a measurement of an improvement after changing the code. 1
| Category | Time | Conditions and meaning |
|---|---|---|
| Total run | 78.0 seconds | Time to build and test on a single virtual CPU |
| Critical path | 47.4 seconds | Minimum time that remains even with more CPUs, given the recorded task dependencies |
The difference between the two figures is about 30.6 seconds. According to the original post, this is the range of time that could be cut by handling more tasks at once. By contrast, cutting the 47.4 seconds further would require changing the tasks on that path or the relationships between them. Zakaria explained that even with 64 cores, the run would still take about 47 seconds. 1
What showed up while the CPU was idle
What made up those 47.4 seconds was unexpected. On the critical path, 33% of the time was spent computing, while 67% was spent with the execution flow asleep. “Asleep” here does not mean the computer was turned off; it means the program’s execution flow was waiting for a period of time or an event, and was not doing work on the CPU. 1
Breaking down the waiting time further, waiting for an event accounted for epoll_pwait 23.1 seconds, waiting for a set period of time accounted for clock_nanosleep 8.53 seconds, and synchronization between execution flows accounted for futex 100 milliseconds. These are all measurements from this critical path. 1
A CPU profile shows what calculations kept the CPU busy. But execution flows that are asleep and not using the CPU are absent from that view. If, as in this case, most of the time determining completion is spent waiting, looking only for compute-heavy sections to optimize can miss what is actually holding up the whole process. 1
Zakaria explains that Rewind records task switches to replay an execution, and that the new feature also records which task woke a waiting task. Using those records, you can inspect which tasks were waiting and what allowed the next task to run—even after a slow execution has finished. In contrast, tracing in a typical runtime environment has to be enabled before the slowdown occurs, and tracing itself has a cost. 1
Tests, not the build, were holding things up
The next clue came from splitting the critical path by task stage. The figures below do not show how long each stage took out of the total runtime; they show how much each contributed to the 47.4-second critical path. 1
| Stage | Time on the critical path |
|---|---|
| Configuration | 3.54 seconds |
| Build | 1.67 seconds |
| Checks and tests | 42.0 seconds |
| Five other stages | 99 milliseconds |
Although the task was called “build and test,” the main factor holding up completion was the checking stage, not the build stage that produces the code. Following the process lineage—the chain of running programs—further, the test command make check accounted for 41.9 seconds of the path, and the test runner lt-run-tests accounted for 36.4 seconds of that. 1
According to Zakaria, the test runner called 287 tests, each taking 1–3 seconds. The fact that all the tests appeared on a single, continuous critical path means that, in this recording, the runner ran them one after another. If the next test cannot start while each test is waiting, those short waits add up across the total completion time. 1
The analysis also shows how quickly the run would finish if some part took no time at all. For example, under the assumption that all test-runner processes take no time at all, the result is 36.1 seconds. This figure is an extreme comparison for estimating potential improvements; it does not mean that removing or parallelizing the tests actually shaved 36.1 seconds off the run. Nor is the time a task spends on the path necessarily the same as the time saved by removing it. 1
What was behind the test that waited 3.38 seconds?
Finding a slow section does not mean you can simply remove that time. Zakaria picked one test, hrtime, to examine more closely. The 3.38 seconds it added to the critical path were almost entirely time spent asleep in clock_nanosleep. The tool showed 75 waits for that process. 1
He then rewound the recording to when the waiting began and checked the source-code location. The test called uv_sleep(45), waiting 45 milliseconds each time. Repeating that 75 times comes to about 3.375 seconds, which matches the 3.38 seconds shown in the analysis. Instead of vaguely concluding that “the CPU is slow,” he was able to identify both the number of waits and their duration. 1
But this wait was not a mistake. The test is meant to check how much a high-resolution time value changes before and after the system sleeps. Zakaria concluded that there was nothing to optimize in this case. Even after finding a slow section, you cannot know whether cutting the wait is the right fix until you understand the feature being tested. 1
In Rewind, you can select a waiting interval on a color-coded graph of the path to inspect the call flow and source code at that moment. 1
Conclusion
The 3.38 seconds spent by the hrtime test was not idle time to eliminate; it was time spent waiting to check that time was passing correctly. Finding a slow section is not enough—you need to understand what the time is being used for before you can decide how to make the process faster. 1
Have you ever waited for a program to install or update and felt it was taking a long time even though the computer wasn’t busy?
References
- Worshipping at the altar of Brendan Gregg · fzakaria.com↩








