⏱️ Reading time: 9 min
A team of engineers cut their continuous integration (CI) time from three hours to under a minute, according to Moab’s engineering blog, after migrating their entire codebase to a monorepo over a weekend in August. This matters most for backend and platform teams with a growing monorepo, because slow CI becomes the bottleneck for every pull request, especially when engineers run dozens of parallel work threads.
📑 En este artículo
- What subminute CI is, and why it’s not just “more parallelism”
- Why this case matters for a team with a growing monorepo
- Parallelism: fork after initializing, not before
- Caching: everything that can be saved to disk, gets saved
- Hardware: why two small runners start faster than one big one
- Elimination: the trimming list that doesn’t touch business logic
- The test selection Moab decided not to use
- Comparison: how other tools attack the same problem
- What this means for a backend developer with a Python monorepo
- Limitations: when this strategy doesn’t make sense for you
- References
Before publishing the result, the team re-ran its original pytest and xdist setup on a GitHub Actions runner. The run was cut off by a three-hour timeout, according to the same Moab blog. That gap between a small repo and one with millions of lines of code is what this article addresses, without rewriting the whole application.
What subminute CI is, and why it’s not just “more parallelism”
Subminute CI is a continuous integration pipeline whose median runtime per run stays under a minute even as the project grows. It’s not a single fast run by chance, but a property the team monitors and protects run after run. Moab achieved it by attacking four fronts at once: parallelism, caching, hardware and eliminating unnecessary work.
The order matters. Adding more processes to a slow task makes it, at best, a little less slow. Moab first removed everything that wasn’t strictly necessary from the critical path, and only then parallelized what was left. That’s why a fast tool like xdist doesn’t fix a slow pipeline if most of the time goes into building Docker images or cloning the entire repository.
Why this case matters for a team with a growing monorepo
This matters most for backend and platform teams (DevOps, SRE) who already feel their CI has become the bottleneck for every pull request. Moab notes that its fast CI lets it respond to customer requests and fix bugs without every change getting stuck in a queue, especially now that engineers juggle dozens of parallel work threads, according to the same blog.
Moab’s stack is AWS, Terraform, Python, Flask, SQLAlchemy, Postgres and React with TypeScript, a common combination in enterprise backends. If your stack looks similar, several of these techniques apply almost directly; if you use a different language, the underlying principle (removing work from the critical path before parallelizing) carries over just the same.
Parallelism: fork after initializing, not before
Moab initializes the full application once, freezes it in memory, and then forks it as many times as there are vCPUs available on the runner. Forking after initialization avoids repeating the cost of starting Flask, loading models and opening connections in every test process.
The distribution of unit tests across processes isn’t random: it uses execution-time metrics from previous runs and, within each runner, applies the Longest Processing Time heuristic to balance the load. Tests with no history are distributed with hash partitioning, so the split stays deterministic. Each pipeline check also runs as a separate job, and Moab avoids sequential dependencies between jobs unless they’re strictly necessary.
flowchart TD
A["Push to a PR"] --> B["Runner starts and initializes the app"]
B --> C["State is frozen in memory"]
C --> D["Fork per available vCPU"]
D --> E["LPT + hash partitioning distribution"]
E --> F["Results reported before cleanup"]
📌 Note: on Hacker News, byroot pointed out that forking a process after starting threads is tricky territory. POSIX generally prohibits it, and while it’s technically possible to do carefully on Linux, it’s easy to introduce a subtle bug if the fork happens at the wrong moment.
Caching: everything that can be saved to disk, gets saved
Moab attaches a persistent storage volume to its test runners, and that volume survives between runs. It holds a git mirror of the codebase, so each run only needs a shallow fetch instead of a full checkout from GitHub. Docker images also live on that disk, which avoids rebuilding them on every run; a separate job updates them when needed.
Before running tests, Moab warms the disk by reading the images and source code, so those pages are already cached by the time tests need them. Instead of rebuilding the database schema on every run, they restore a development database snapshot stored on Amazon S3, applying only the migrations the pull request brings, if any.
Hardware: why two small runners start faster than one big one
Moab uses a third-party provider to get faster runners than GitHub Actions’ standard ones. Most of its jobs run on 16-vCPU Ubuntu x64 machines, which start between 8 and 12 seconds after the push, according to its own profiling (source). In those tests, two 16-vCPU machines start faster combined than a single 32-vCPU machine, so Moab prefers parallelizing across small runners instead of scaling up to a big one.
Elimination: the trimming list that doesn’t touch business logic
The fourth front is, according to Moab, where the small gains that add up accumulate. Among the cuts they document:
- Lazy imports: avoid loading the entire application upfront.
- Paused garbage collection during stretches where it doesn’t help, like the initial import.
- Self-skipping jobs: the migrations step doesn’t run if the PR doesn’t touch the schema, and Semgrep scans only the diff instead of the whole repo.
- Faster tools: replaced slow predecessors with uv, ruff, ty, bun check, oxlint and oxfmt.
- Native forking instead of xdist: migrated from pytest-xdist to the direct fork described above.
- Report before exit: the pipeline reports results before the runner finishes its cleanup, and polls for jobs to finish instead of querying the GitHub API.
- Deferred compilation: Pydantic models and Flask routes are built only when they’re used.
- Fixtures that flush, not commit: FactoryBoy fixtures persist with a flush instead of a full commit.
- Squashed migrations: fewer accumulated migrations means less time applying them on top of the snapshot.
All of this runs with telemetry and pytest extensions disabled during execution, another small cut that, multiplied across thousands of runs, adds up.
The test selection Moab decided not to use
There’s one technique almost any team with a large monorepo considers first: running only the tests affected by a change, instead of the full suite. Moab evaluated it and deliberately dropped it. Trying to predict which tests are in scope for a change isn’t worth the risk when you’re the financial source of truth for your customers, so they always run the entire suite (source: Moab blog).
It’s a product decision, not just an engineering one. An ERP that calculates inventory and billing can’t afford a false negative because a test-selection algorithm got it wrong about what a change affected. If your domain tolerates that risk, the test selection used by tools like Bazel or Nx remains a legitimate lever; if not, Moab’s path (eliminate everything else and run the full suite) is the more conservative alternative.
Comparison: how other tools attack the same problem
Moab built this solution by hand on top of its own stack. It’s not the only way to get fast CI in a large monorepo: there are tools that solve parts of the same problem differently.
| Tool | Main approach | Test selection | Adoption cost |
|---|---|---|---|
| Moab’s approach | Disk caching, native forking and manual trimming at every layer of the stack | No, always runs the full suite | High in-house engineering effort, zero in third-party licensing |
| Bazel | Build system with remote caching and a per-target dependency graph | Yes, via build-graph dependency analysis | High: requires migrating the build to Bazel rules |
| Nx | Monorepo tool focused on JavaScript and TypeScript with an affected-projects graph | Yes, runs only the projects affected by the diff | Medium: integrates on top of existing Node projects |
The underlying difference is philosophical. Bazel and Nx bet on running less work by identifying what changed, while Moab bets on making running everything cheap in itself. For a new team, adopting Nx or Bazel is usually faster than replicating what Moab built by hand.
What this means for a backend developer with a Python monorepo
If you maintain a monorepo with pytest and GitHub Actions and your CI already takes 10 or 15 minutes, the first step isn’t copying Moab’s list, it’s measuring where the time goes. A simple profile of the run (how long checkout takes, how long dependency installation takes, how long the runner takes to start, and how long the tests themselves take) usually shows that a good chunk of the time is lost before a single test runs.
With that profile in hand, the concrete actions are: check whether your runner provider allows a persistent disk between runs, because Moab’s caching gain depends on that; measure whether your Docker images get rebuilt unnecessarily on every push; and decide, based on business judgment and not just speed, whether your domain tolerates test selection or whether you should always run the full suite like Moab.
Limitations: when this strategy doesn’t make sense for you
Moab’s approach requires dedicated infrastructure: persistent disk attached to runners, a hardware provider faster than the standard, and an in-house process to keep the database snapshot on S3 up to date. None of this is free in engineering time, and a commenter on the Hacker News thread about the article summed it up with an uncomfortable question, “is your time free?“, questioning whether the engineering effort invested in these optimizations pays off versus accepting a slower CI.
It also depends on the stack. The forking, deferred Pydantic and Flask route optimizations assume Python and Flask; a monorepo in another language can apply the principle (parallelism, caching, less unnecessary work) but not these specific techniques. And the technical risk byroot pointed out, about forking after starting threads, is real: if your application opens threads before the fork, blindly replicating this can introduce intermittent bugs that are hard to reproduce.
If what you’re after is visibility into where time gets lost in your own pipeline before deciding what to optimize, in the same thread brennerm mentioned pipescan, a beta tool built to identify which CI jobs or steps consume the most time and offer the most room for improvement.
References
- Subminute CI, Moab engineering blog: primary source for every technique and figure in this article.
- Hacker News thread on “Subminute CI”: technical discussion and community objections cited in the body.
- Bazel: build system with remote caching and dependency-graph test selection, used as a comparison point.
- Nx: monorepo tool for JavaScript and TypeScript with affected-project selection, used as a comparison point.
- pytest-xdist: the parallelism tool Moab replaced with native forking.
Featured image: Foto de Lightsaber Collection en Unsplash
How each article is made (sources, testing and editorial criteria): How we work.
Did it work for you? Got a different error? Say so below: questions get answered and help the next reader.
Leave a comment
0 Comments