Agent Architecture Weekly

Combining Warm Caches and Parallel Shards to Attack the Slowest CI Stages First

Fix caches, cancel stale runs, then shard tests to cut CI wait.

Sponsored by Graphide

Agent Architecture Weekly Editors
· 8 min read
Cover illustration for “Combining Warm Caches and Parallel Shards to Attack the Slowest CI Stages First”
CI Verification Workflows · December 1, 2026 · 8 min read · 1,791 words

To speed up slow GitHub Actions CI, shorten the critical path. Identify its slowest stage, warm its caches, cancel superseded runs, then shard tests if they remain the bottleneck. Faster runners belong after those fixes, when execution dominates elapsed time.

Why total CI wall-clock is set by the critical path, not by aggregate job-minutes

A workflow finishes when its longest chain of dependent jobs finishes. GitHub Actions uses needs edges for those dependencies to set which jobs can start right away and which must wait. Parallel jobs can consume substantial runner time without delaying the final result. But one slow dependency can hold up every job downstream. The critical path is the chain that determines the run’s overall finish time.

Aggregate job-minutes measure a different property of the workflow. They account for work across jobs, including work that happens simultaneously, so reducing them can lower consumption without bringing the verdict forward. That distinction governs where optimization effort belongs. Caching a fast parallel job or adding more parallel work cannot shorten a serial dependency chain elsewhere in the graph.

The target job must sit on the chain that gates completion, where its duration contributes to the end-to-end wait. Within that chain, the slowest job is the long pole. Its identity is not permanent, because shortening one chain can leave another controlling completion. Variable runner queue time can also change which chain finishes last.

How to find the slowest stage on the critical path before touching any configuration

Diagnosis starts with the workflow graph and measured timings. Reconstruct the needs edges from the YAML, then walk the dependencies using actual job start and end times to identify the chain that determines completion.

Next, separate each candidate job’s elapsed time into queue wait, runner startup, repository checkout, dependency restore, cache and disk I/O, and build or test execution. These costs require different fixes, so a single total duration is not a sufficient diagnosis.

The loudest complaint is not a reliable measurement. A test stage may attract attention while dependency restore or queue wait accounts for most of the delay on its path. The target is the dominant cost within the long pole.

Runner comparisons must follow that same decomposition of time. A runner that leads on CPU performance can still lose on cache throughput or queue depth, leaving the workflow slower despite faster execution. Record what dominates before changing configuration.

Why warm caches belong on the critical path before sharding is considered

Warm caches remove repeated work from the critical-path job. Dependency caches can turn installation from minutes into seconds, while compiled output and Docker layers avoid rebuilding work that remains reusable. These targets address distinct categories of setup and execution. Their value depends on whether the saved time advances completion. A cache hit on a job that finishes well before the critical path does not shorten the overall wait.

Caching should precede sharding because every shard repeats setup. If dependency restore is still slow, splitting tests adds more jobs that each pay that fixed cost before they can start running tests. A warm cache reduces that cost across all shards. The un-parallelizable portion becomes smaller, allowing a larger share of each job to benefit from splitting the suite. This also postpones the point at which repeated setup makes further sharding an unattractive expense.

A poorly keyed cache can miss after spending time attempting a restore, then require the full installation anyway. Keys tied to frequently changing lockfiles can make this extra work common. Storage policy also shapes the outcome. GitHub’s default cache evicts entries unused for seven days, and the repository cap allows large dependency trees and Docker layers to displace one another.

Restore throughput should be measured on its own, even on a hit. Avrea’s runner benchmark reports a 1 GB restore taking 14.10 s on GitHub-hosted runners and 2.89 s on its colocated storage. The benchmark keeps cold and warm builds separate and measures cache transfer on its own. Its publisher also competes in the comparison. Cache architecture changes elapsed time as well as determining whether a cache exists.

What sharding actually does to wall-clock, and when it is worth the trade-off

Sharding divides a test suite across a matrix of parallel jobs. When that suite occupies the critical path, parallel execution can reduce the test stage’s contribution to the workflow’s duration. The slowest shard sets the stage’s finish time. An uneven split thus saves less time than the number of jobs might suggest, because shards that have finished cannot help the one still running.

A Playwright suite illustrates the distinction without promising a particular result. Splitting the suite across jobs can bring the verdict forward when tests are the long pole and the resulting shards have similar durations. If one shard retains most of the slow tests, it remains the gate. If setup dominates every shard, splitting test execution addresses only a small portion of elapsed time.

The gain also has a price in runner-minutes. The tests still have to run, and each extra job repeats setup that a single job would do once. Warm caches keep that repeated portion small, but do not make sharding free. Sharding is appropriate when a faster verdict justifies the extra consumption and the tests are demonstrably on the critical path. Applied elsewhere, it adds cost without reducing the wait for completion.

The sequencing rule in practice: cache first, cancel superseded runs, then shard

Diagram: Cache → Cancel → Shard: The Optimization Priority Order. Visualizes: Visualize the four-stage sequential optimization order described in the article: (1) Warm dependency and build caches on the critical-path job, (2) Cancel…

The practical sequence starts with warm dependency and build caches on the critical-path job. Where shared infrastructure prevents useful reuse, that foundation comes before caching individual build outputs. Otherwise, a configuration change can leave the cause of the delay in place. The pattern is to fix shared infrastructure first, then reuse the outputs built on it.

Cancellation comes next because runs that are out of date use capacity that useful work needs. Setting cancel-in-progress to true for superseded runs releases runner capacity for work someone is still waiting on. It does not accelerate a test command directly. Instead, it removes stale demand that can keep a current run from starting promptly. This matters even more when many pull requests are active at once.

Sharding comes next only if tests are still the long pole. With warm caches and less stale work competing for runners, the matrix addresses test execution. Previous run timings provide the basis for rebalancing shards. A nominally even division is insufficient if its execution times are uneven.

Re-measurement belongs between changes. A cache fix that works may take the test job off the critical path before sharding is needed. After cancellation cuts queue pressure, execution may account for most of the time. The sequence is therefore a priority order, with each technique applied only as needed.

What faster runner alternatives to GitHub-hosted runners can and cannot fix

Faster runners belong after the free configuration fixes have been exhausted. More CPU performance can accelerate CPU-bound builds and tests on the critical path, but it does not itself repair cache misses, slow external downloads, or queue time. Hardware must match the measured bottleneck. A workflow dominated by restore and I/O needs a different comparison from one dominated by compilation or test execution.

Third-party runners can preserve the existing GitHub Actions workflow. Migration is typically a GitHub App installation and a runs-on label change for the jobs being moved, with macOS, Windows, Arm, and self-hosted jobs unaffected. That makes a targeted move possible without replacing the whole graph. The relevant comparison is the selected job’s end-to-end duration.

For restore-heavy jobs, Avrea’s benchmark covers CPU scores, cache transfer, and end-to-end runs, while labeling its own tests separately and linking methods. Those details help explain what a result measures. They do not remove the publisher’s commercial interest or establish how another repository will behave. Cold and warm results should be kept separate when judging how well it fits.

Self-hosted runners have the lowest cost per core at scale, give teams full control of the hardware, and keep caches on local disk. The team, however, owns scaling, patching, security isolation, and idle cost. Cache architecture, incident fallback policy, security isolation, and support maturity affect whether a faster job is a workable production choice.

How AI-agent-driven PR volume changes the calculus for every technique in this sequence

Each agent-generated pull request triggers the job graph, so a critical-path cache miss or uneven shard recurs across more runs. The queue grows as those runs compete for capacity. A graph tolerable at human-paced commit volume can therefore become a persistent source of waiting without any individual command becoming slower.

An agent’s earlier attempt can consume capacity after a newer attempt has made its verdict obsolete. Superseded runs then hold up live work without giving useful feedback. Warm caches address a separate part of the same problem, preserving reuse when many pull requests share a dependency set. Repeated cold setup can erase the advantage of faster hardware.

Agents also depend on the verdict they are waiting for. When an agent must receive a CI result before proceeding, the critical path blocks its feedback loop just as it blocks a developer’s. Higher output increases the frequency with which the workflow must deliver a useful result, making both queue pressure and recurring setup costs more consequential.

The long pole can change as the code changes, so maintaining speed requires more than choosing an initial runner size. Graphide CI is another GitHub Actions runner alternative, using a team of AI agents to retune each job’s caches, machine, and run setup as the code changes. That approach addresses the risk that a previously fast job quietly becomes the next bottleneck. Its fit, like that of other runner options, depends on the actual workflow.

What the critical-path framework rules out — and what to do after one pass

The framework rules out treating every speed improvement as an end-to-end improvement. Caching an off-path job, sharding a fast suite, or adding parallel jobs around a serial bottleneck may leave the workflow’s finish time the same. Faster CPUs likewise do little for steps dominated by I/O or waiting. These changes can serve other goals, but they do not establish a shorter wait for CI. The targeting discipline is to connect each intervention to the path that gates the verdict.

Warm-cache results also have a defined limit. A new project or a lockfile change large enough to invalidate most layers can still require a cold build. Vendor benchmarks cannot remove that condition or predict every repository’s outcome. The practical comparison is to run the team’s own job on each option and assess actual workflow data.

After each change, reconstruct the timed path again. A different job may now hold up completion, even one that needed little attention before. The next intervention must follow that evidence.

Sources

  1. How it works · Graphide docs

More in CI Verification Workflows