Using GitHub Actions Step Timing Annotations to Pinpoint Runner Startup Versus Cache Restore Versus Test Execution Drag
Separate startup, cache restore, and test time to find the real delay.
Sponsored by Graphide

To speed up slow GitHub Actions CI, measure runner startup and queue time, cache restore latency, and test execution on their own before changing YAML. Step durations expose the work inside a job, while job-level timestamps expose the wait before it starts. The right optimization follows from which bucket owns the delay.
Why "CI is slow" is three different problems wearing one symptom
“CI is slow” conflates three different causes of delay. Runner startup and queue time cover the interval before the first step fires. Cache restore latency is the cost of shipping and unpacking a tarball on a clean VM. Test execution is the work the job exists to perform, including the CPU-bound work that faster hardware can shorten. These buckets require different remedies.
Treating the total duration as the diagnosis encourages changes that leave the main delay untouched. More test parallelism does not remove a queue, and a larger cache can increase the time spent restoring dependencies. A faster runner can shorten execution without improving access to a runner slot. A useful diagnosis therefore identifies which interval accounts for the wait and what mechanism controls it.

Where GitHub Actions already exposes per-step timing
GitHub Actions exposes per-step execution durations in its own interface. Opening a job run and expanding its steps shows how long each took, while errors and warnings can appear as annotations on the workflow summary page. No third-party service is needed to begin this analysis. The existing job history provides the first comparison between setup, cache restore, and test execution, rather than forcing a team to infer their contributions from a single total.
For measurements that need more visibility, GITHUB_STEP_SUMMARY lets a workflow write Markdown to the run summary page. Each step receives its own summary file, capped at 1 MiB, and a job displays only a fixed number of summaries. Small timing records fit this purpose well. A duration that looks unremarkable in one log becomes useful when the same measurement appears consistently across runs, especially for steps whose slowdown accumulates gradually.
A simple shell pattern starts with start=$(date +%s) just before the operation being measured. After the operation, elapsed=$(( $(date +%s) - start )) calculates its duration, and echo "elapsed=$elapsed" >> "$GITHUB_OUTPUT" exposes that value as a step output. The same step can publish it with echo "Duration ${elapsed}s" >> "$GITHUB_STEP_SUMMARY", or a later step can read the output and assemble the summary. GitHub’s REST API also returns .steps[].started_at and .completed_at through /repos/.../actions/runs/.../jobs, so runs can be compared as long as the comparison handles null timestamps for steps that have yet to finish.
What step timing cannot see: the queue interval before the first step fires
Step timing begins after the runner is ready. Everything before that boundary is absent from the step measurements, even though developers experience it as part of the same wait. Scheduler queue time is the interval spent waiting for a slot when the runner fleet is saturated. Cold-start provisioning is different, covering instance provisioning, runner registration, and image warmup before the job can execute. A workflow change aimed at execution does not resolve fleet saturation.
This distinction explains why short steps can coexist with a long wait. A developer may spend a minute or more waiting before the first annotation can record anything. Job-level created_at and started_at timestamps provide a separate view of that interval, while webhook-level observability offers another way to capture it. When the wall-clock wait substantially exceeds the sum of step durations, startup and queue time are the likely explanation.
Reading cache restore timing honestly, including the stale-hit trap
A green “Cache restored successfully” annotation confirms that a tarball was found and unpacked. It does not establish that restoring it was worthwhile. A large archive can consume a substantial share of the installation time that caching saves, because the archive still has to reach and unpack on a clean machine. For a Node monorepo with roughly 1.2 GB of node_modules, that restore cost can materially reduce the net benefit of a warm cache. Success and efficiency are different measurements.
Large caches can push restore time beyond a minute. GitHub’s default total cache storage limit is 10 GB per repository, so eviction can also turn an expected warm build into a cold one. Those outcomes need separate records. Averaging cold-cache and warm-cache runs obscures whether the problem is expensive restoration or frequent misses, and can make the aggregate look healthier than the underlying cache behavior.
The more deceptive failure is a stale exact hit. actions/cache treats an exact key match as nothing to upload, skipping the post-step upload entirely. An incrementally changing type-check cache can therefore remain frozen at its week-one snapshot while every later run reports a successful restore. In the stale-hit example, the measured step grows from 38 seconds to over four minutes across nine weeks while the annotation remains green. The successful lookup conceals the missing refresh.
Reading the timing honestly therefore requires the hit status as well as the duration. The cache-hit output is true only for an exact key match. A fallback through restore-keys is a partial hit, even though it may still provide useful cached content. Recording that distinction makes it possible to tell whether a fast restore supplied the intended snapshot, an older starting point, or no useful cache.

What the cache restore number tells you to do next
The next action depends on the timing pattern. If restore is fast but installation remains slow, the cache may be missing or its key may not match the useful contents. In that case, the relevant evidence is the key and hit status. The fix lies in which cache gets selected, while test execution can stay as it is.
When a lockfile change prevents an exact match, a restore-keys prefix can start the run from the previous snapshot. Only changed packages then need fetching. Without that fallback, every lockfile change can trigger a cold installation on that run. A partial hit is therefore not inherently a failure. Its value depends on the installation work it avoids.
If restore is slow but installation is fast, caching the fully linked output directory may be shifting too much work into transfer and unpacking. For Node, caching the package manager’s download store at ~/.npm rather than node_modules produces a smaller, more compressible tarball. The package manager then rebuilds the linked tree locally, so installation stays fast and there is no need to restore the entire output directory.
A growing duration under an exact hit points toward snapshot freshness instead. For incrementally growing build-tool or type-checker caches, appending ${{ github.run_id }} to the key forces a new entry each run. A restore-keys prefix still supplies the previous snapshot as the starting point.
Separating test execution time from setup noise in the step log
Teams often try to speed up test execution before they know how much of the wait it takes up. It is visible, and reducing it feels directly connected to the purpose of CI. Yet it can be the smallest bucket. Once setup and restoration are accounted for, the test step becomes a cleaner measurement of the work that remains, rather than a convenient explanation for the whole workflow.
A growing test duration still has two different interpretations. The suite may contain more tests running on the same infrastructure, in which case parallelism can divide the added work. Or the suite may have the same number of tests while some tests get slower. That requires per-test profiling.
Parallelism changes both the cost calculation and the wait. Three concurrent shards consume billable time on three jobs, so the shorter duration a developer sees is not itself evidence of lower compute cost. The precise total depends on shard duration and repeated setup.
Shard balance determines how much of that benefit reaches developers. A shard containing ten fast unit tests and one slow integration test can finish much later than one containing eleven fast tests. Balancing by measured per-test duration keeps shards roughly equal and avoids making the slowest shard the new limit on the workflow.
When workflow tuning is exhausted, can faster runners speed up slow GitHub Actions CI?
A faster CPU can help when setup and cache restoration are already lean and CPU-bound test execution takes up most of the wait. YAML cannot reproduce faster execution hardware. The useful comparison is the measured test-step duration on the current runner against the projected duration on the target. This preserves the distinction between removing avoidable setup and accelerating necessary work.
GitHub’s larger runners are one way to get faster hardware within the hosted service. They start at 4 vCPU, or 2 vCPU on Linux only, and are paid on all repositories, including public ones. The free 4-vCPU runner for open-source projects is a standard runner. That distinction prevents a misleading price comparison. A higher per-minute rate needs to be weighed against how much execution time it is expected to save.
Third-party infrastructure can address a different part of the same diagnosis. Depot provides ephemeral remote builders with persistent layer caches for Docker builds, targeting jobs where network layer-cache restoration is itself a bottleneck. Those builders are distinct from its GitHub Actions runners product. The relevant comparison is therefore the build and cache behavior of the service.
Warm self-hosted runners change restoration by keeping Docker layers, toolchains, and dependency caches on local NVMe. A network restore taking tens of seconds can become a disk read measured in single-digit seconds. Persistence has a cost, however. Machines that never reset can accumulate stale dependencies or port conflicts, while ephemeral runners built from warm images avoid that accumulation and retain much of the startup benefit.
When a burst of jobs arrives, faster runners may leave the wait for a slot unchanged and finish the work they take on sooner. When the measured delay is access to a runner slot, the relevant capacity is concurrency.
Building a timing baseline that survives code changes
A timing baseline turns individual measurements into regression signals. Each run’s summary can record the three bucket totals, with the startup interval drawn from job-level telemetry. The history then remains visible in the Actions UI. For a longer view, the REST API can supply step timestamps for the last N workflow runs, allowing durations to be plotted without repeatedly opening logs.
Cold-cache and warm-cache measurements need to be tracked in separate series. Otherwise, the overall restore time can look steady even as the miss rate changes. Exact hits and prefix fallbacks also provide context for interpreting movement within those series. When cache-related steps take longer but test execution stays steady, the cache is the place to start looking for the cause.
A growing duration under a green annotation deserves particular attention because it can remain operationally invisible while an explicit warning at least attracts notice. Cross-run timing could have exposed the stale-cache example by week three, before it worsened through week nine.
That practice becomes more valuable as coding agents generate more pull requests and commits. More changes mean more CI runs and more occasions for a small delay to compound. Catching a 20-second per-run regression before it becomes a 3-minute regression keeps the feedback loop fast as more code is produced. Agents can write code faster while teams still wait for CI, so the length of that wait is a key measure of how fast teams can deliver.


