---
title: "How to speed up CI: a series by language"
description: "Ten techniques that speed up CI in any language, plus a language-by-language series on faster tooling for JavaScript, Python, Java, Rust, and Go."
url: https://9apes.com/blog/speed-up-ci-builds/
---

# How to speed up CI: a series by language

To speed up CI, stop doing work nobody needs, make the work you keep cheaper to set up, replace slow tools with faster ones, and run what remains in parallel on hardware that suits it. In that order. Most slow pipelines are slow because of repeated setup and redundant jobs long before the compiler or test runner becomes the limit.

This post is the hub of a series. It covers the techniques that apply to any stack, then links to one post per ecosystem with the specific tools that changed in the last two years:

- [JavaScript and TypeScript](/blog/speed-up-javascript-typescript-ci/): oxlint, Vite and Vitest, TypeScript 7, and what comes after it
- [Python](/blog/speed-up-python-ci/): uv, Ruff, the new Rust-based type checkers, pytest-xdist, and Granian
- [Java](/blog/speed-up-java-ci/): Gradle build and configuration caches, Maven daemon and parallel builds, and JVM startup
- [Rust](/blog/speed-up-rust-ci/): linkers, sccache, cargo-nextest, and CI build profiles
- [Go](/blog/speed-up-go-ci/): the build and test caches, GOCACHEPROG, and golangci-lint

## Measure the critical path first

A pipeline is as slow as its longest chain of required jobs. Before changing anything, record two numbers for a few representative pull requests: time to the first required check result and time until every required check finishes. Then break the slowest chain into queueing, runner startup, setup, the work itself, and cache save.

That breakdown decides everything else. Halving a lint step that runs in parallel with a twelve-minute test job saves nothing. The [build-time measurement guide](/blog/reduce-github-actions-build-times/) walks through the method in detail.

## 1. Cancel runs nobody will read

When a developer pushes twice in a minute, the first run is already stale. A concurrency group keyed on the workflow and branch cancels it:

```yaml
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: ${{ github.event_name == 'pull_request' }}
```

Scope cancellation to validation. Deploy, migration, and release workflows need to finish or fail cleanly, not stop halfway. GitHub documents the behavior under [workflow concurrency](https://docs.github.com/en/actions/how-tos/write-workflows/choose-when-workflows-run/control-workflow-concurrency).

## 2. Run only what the change can affect

A documentation edit should not run a forty-minute integration suite. Path filters, monorepo tools that compute affected projects (Nx, Turborepo, Bazel, Pants, Gradle), and test selection all remove work outright, which beats making that work faster.

Check branch protection before you adopt any of them. A workflow skipped by a path filter can leave a required check pending forever and block the merge. A job skipped by an `if:` condition reports differently. GitHub's [required-check troubleshooting page](https://docs.github.com/en/pull-requests/how-tos/merge-and-close-pull-requests/troubleshooting-required-status-checks) explains the difference.

## 3. Install from a lockfile, and cache the store, not the output

Dependency installation is often the single largest setup cost. Every ecosystem in this series has a fast path for it: `pnpm install --frozen-lockfile`, `uv sync --locked`, `cargo fetch`, `go mod download`. Each resolves nothing and downloads only what the lockfile names.

Cache the package manager's download store rather than the installed tree (`node_modules`, a virtualenv, `target/`), unless you have measured that the installed tree restores faster. Stores are content-addressed and stable across branches; installed trees are large, platform-specific, and invalidated by small changes.

Then measure the cache itself. Restore, extraction, and save are not free. A cache that takes ninety seconds to restore a sixty-second install is a slowdown with a high hit rate. GitHub's [dependency caching overview](https://docs.github.com/en/actions/concepts/workflows-and-actions/dependency-caching) covers keys and scope.

## 4. Replace slow tools with native ones

The biggest change in CI speed since 2023 has nothing to do with CI providers. Linters, formatters, package managers, bundlers, and type checkers across most ecosystems have been rewritten in Rust or Go, and the rewrites are often an order of magnitude faster on the same machine:

| Ecosystem | Older tool | Native replacement |
| --- | --- | --- |
| JavaScript | ESLint, Prettier | oxlint, oxfmt, Biome |
| JavaScript | tsc (JavaScript) | TypeScript 7 (Go) |
| JavaScript | webpack, Rollup | Vite with Rolldown |
| Python | pip, pip-tools, Poetry | uv |
| Python | Flake8, isort, Black | Ruff |
| Python | mypy | ty, Pyrefly |

The per-language posts cover when each swap is safe, what still needs the old tool, and how to run both during a migration.

## 5. Split the critical path into parallel jobs

Lint, type checking, unit tests, and builds rarely depend on each other. Running them as separate jobs means the pipeline takes as long as the slowest, not the sum. Large test suites can be sharded further across a matrix.

Every extra job pays for its own runner startup, checkout, and dependency install again. Splitting a three-minute job into three one-minute jobs that each spend two minutes on setup makes the pipeline slower and more expensive. Shard where the work is much larger than the setup, and cut setup before you shard.

## 6. Fail fast on cheap checks

If formatting or linting fails, the expensive test run is wasted. Two options work well:

- Run cheap checks as their own fast job so developers see a failure in seconds, while long jobs continue in parallel.
- For expensive suites, make them depend on the cheap job with `needs:` so they never start on a commit that will be rejected anyway.

The first optimizes feedback time; the second optimizes spend. Pick per job.

## 7. Cut toolchain setup

Installing a compiler, a JDK, a Python interpreter, or system packages with `apt-get` on every run adds up. Prefer setup actions that download prebuilt toolchains, pin exact versions so caches stay warm, and move stable system dependencies into a container image or a prebuilt runner image instead of installing them per job.

## 8. Move the exhaustive suite to the merge queue

With a [merge queue](https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/configuring-pull-request-merges/managing-a-merge-queue), you can run fast checks on every push and the full matrix only on the `merge_group` event, once per merge candidate. Developers get quick feedback while iterating, and main is still protected by the complete suite. This changes what blocks a merge, so agree on it as a team first.

## 9. Keep build caches warm across runs

Compiler and build caches (Gradle's build cache, sccache, Go's build cache, Bazel's remote cache, Turborepo's remote cache) let a job skip work that an earlier job already did. On ephemeral runners, local disk does not survive between jobs, so the cache needs a store that does: the Actions cache, an object store, or a dedicated cache service.

Measure ordinary source edits and dependency updates, not just unchanged rebuilds. A cache that only helps when nothing changed rarely helps in practice.

## 10. Match the runner to the bottleneck

Once the work is minimal, the hardware decides how long it takes. Single-threaded steps (much of type checking, linking, JVM startup, many test runners) benefit from fast cores, not more of them. Parallel compilation benefits from more cores. Dependency-heavy installs and large caches benefit from fast local disk and network.

Read the slow job's logs before buying a bigger machine. If CPUs sit idle during a serial step, more vCPU only adds cost.

## How 9apes speeds up CI builds

9apes runs GitHub Actions jobs on managed Linux runners. You install the GitHub App and change one line:

```diff
- runs-on: ubuntu-latest
+ runs-on: 9apes
```

What that changes:

- **Faster cores and local NVMe.** Runners use hardware chosen for high single-core performance with NVMe storage, which helps the serial steps and disk-heavy installs described above.
- **A fresh microVM per job.** Each job starts in a clean, isolated environment that is destroyed afterwards, so one job's leftovers cannot slow down or break the next.
- **Sizes from 1 to 8 vCPU** on Linux x86_64 (Ubuntu 24.04), so you can give compile-heavy jobs more cores and keep lint jobs small. See [available runners](/docs/available-runners/).

What it does not change: redundant jobs, cold caches, and serial workflows stay slow on any runner. Fix those first using the steps above, then compare runners.

The [9apes benchmarks](/benchmarks/) publish cold-build medians at matched vCPU counts, with the workflow and raw samples. For example, a cold Rust and Go build of `PeerDB-io/peerdb` took a median of 1,283 seconds on GitHub-hosted 2 vCPU runners and 492 seconds on 9apes 2 vCPU runners, measured on August 27, 2026. Those numbers measure the timed build step, not your pull request feedback time. To measure your own job, follow the [quick start](/docs/quick-start/) and compare against [current pricing](/pricing/).

## What is the fastest way to speed up a slow CI pipeline?

Cancel superseded runs and remove jobs that do not need to run for a given change. Both take minutes to set up and remove work entirely, which no faster tool or runner can match.

## Should I cache node_modules, virtualenvs, or target directories?

Usually not. Cache the package manager's download store and reinstall from the lockfile. Cache an installed tree only after measuring that restoring it is faster than installing.

## Does sharding tests always make CI faster?

No. Each shard repeats runner startup, checkout, and installation. Sharding helps when the test work is much larger than that setup, and hurts when it is not.

## Will a faster runner fix a slow pipeline?

Only the part of the pipeline that is limited by CPU, disk, or network. Queueing, redundant jobs, and cache misses need workflow changes first.
