Technical document

Why Replacing a Test Runner with a Rust-based One Halves Execution Time — Deconstructing CI Acceleration from Process Startup Overhead, Fine-Grained Parallelization, and Memory Locality

It is frequently observed that execution time is reduced by 50% to 80% simply by replacing the test runner with a Rust-based foundation, without modifying the test code itself. This article will engineer an analysis, complete with Mermaid diagrams, of why such a significant performance difference arises from a mere runner change, examining runtime startup overhead, process-level and thread-level parallel scheduling, the impact of memory allocation and garbage collection, and the boundaries of I/O wait and external resource-dependent bottlenecks that should not be over-relied upon.
AI Development26 minPublication Date November 8, 2026Update date November 8, 2026
Thumbnail for Why Replacing a Test Runner with a Rust-based One Halves Execution Time — Deconstructing CI Acceleration from Process Startup Overhead, Fine-Grained Parallelization, and Memory Locality

Summary

Key points of this document

  • 1. Why does speed drastically change "without altering test code"?
  • 2. Comparison of Execution Models: Traditional Runners vs. Rust-based Runners
  • 3. The Three Major Mechanisms Behind Rust Test Runners' Speed Advantage

Overview

In software development, long test execution times in CI/CD pipelines and local environments are typical bottlenecks that erode engineers' concentration and development throughput. When faced with challenges such as "waiting several minutes to tens of minutes for tests to complete" or "slow CI per PR leading to a clogged merge queue" as test suites grow, many teams tend to consider refactoring test code, reducing test cases, or switching to expensive, large-scale CI runners.

However, there are frequent cases where test execution times are cut by more than half (sometimes even to one-third or one-fifth) simply by replacing the test execution infrastructure (test runner or harness) with a Rust-based tool, without making any changes to the test code itself.

This article will engineer an analysis of the mechanisms and applicability boundaries of why a mere runner replacement can lead to such dramatic speed differences, from the perspectives of runtime startup overhead, process management, fine-grained parallelization via work-stealing, and memory management and garbage collection (GC).


1. Why does speed drastically change "without altering test code"?

Test suite execution time is broadly the sum of two components: "processing time of the test code itself" and "harness overhead consumed by the test runner."

[Total Execution Time] = [Test Runner Overhead] + [Calculation/Wait Time of Test Logic Itself]

In projects with hundreds to thousands of lightweight unit tests, the latter, "calculation time of the test logic itself," is only a few milliseconds to tens of milliseconds per test. In fact, 70% to 90% of the total time is wasted on the following processes on the test runner side:

  • Initialization of language runtimes (Node.js, Python, etc.) and VMs
  • Process forking and module graph re-resolution for each test file
  • Parsing test files, AST generation, and transpilation
  • IPC (Inter-Process Communication) serialization/deserialization between worker processes
  • Thread pauses due to garbage collection (Stop-the-World)

Rust-based test runners (for example, the standard cargo test for the Rust ecosystem itselfcargo-nextest, Vitest and Biome in the JavaScript/TypeScript ecosystemuv, or Rust-based test support tools in the Python ecosystem) are designed to minimize this "test runner overhead" to near zero.

As a result, even without changing a single line of test logic, simply swapping out the runner causes the total execution time to drastically decrease by more than half.


2. Comparison of Execution Models: Traditional Runners vs. Rust-based Runners

The following Mermaid diagram compares the differences in execution structure between traditional dynamic language runners and standard harnesses, and optimized Rust-based test runners.

Loading diagram...

Traditional runners often adopt an approach of "forking a process per test file" to ensure test isolation. However, with this method, even if there are 100 tests within a file, one worker process is occupied until the entire file finishes execution, leading to a significant imbalance in CPU core allocation.

In contrast, advanced runners written in Rust decompose the entire test suite into individual, minimal test cases. They then continuously supply tasks to all CPU cores without interruption, utilizing a lightweight thread pool and a sophisticated scheduler.


3. The Three Major Mechanisms Behind Rust Test Runners' Speed Advantage

Why does a test infrastructure implemented in Rust operate so quickly? The main reasons can be summarized into the following three points.

(1) Instant Startup of Native Binaries and Zero Runtime Characteristics

Runners for dynamically typed languages (such as Jest) first need to launch the language's own runtime (e.g., V8 engine), load standard libraries, and read and evaluate configuration files before tests can even begin. This cold start alone can take hundreds of milliseconds to over a second.

Furthermore, when multiple worker processes are launched to parallelize tests in a CI environment, the runtime startup process is repeated for each worker, wasting a significant amount of CPU time and memory just on startup.

A test runner compiled in Rust is a single native binary called directly by the OS. Since there is no intermediate language interpretation, JIT compilation, or runtime bootstrapping, startup takes less than a few milliseconds. Actual validation processing begins the moment a test is invoked.

(2) Complete CPU Core Saturation through Work-Stealing

The biggest factor influencing test execution speed is "scheduling efficiency" – how effectively multi-core CPUs can be utilized without waste.

A prime example is cargo-nextest, widely used in the Rust ecosystem. The standard cargo test executes integration tests (files under tests/) as a single binary per file. Consequently, if there was one long-running test file, it was necessary to wait for that single file to finish, even if all other CPU cores had completed their processing and were idle.

cargo-nextest extracts individual test case lists as metadata from the test binary and manages parallel processes on a per-test-case basis. Furthermore, it uses a work-stealing algorithm, allowing idle CPU cores to immediately "steal" and execute unexecuted tests.

Loading diagram...

This fine-grained task distribution ensures that all CPU cores remain at nearly 100% utilization until just before test completion, compressing the overall execution time to the theoretical limit of the critical path.

(3) Memory Locality and Elimination of Garbage Collection (GC) Overhead

In dynamic language test runners, a large number of assertion objects, context objects, and mock data are allocated on the heap for each test case. As the number of test cases increases, memory consumption rises steadily, and the garbage collector periodically activates, pausing the entire execution thread (Stop-the-World).

Rust does not have garbage collection. Instead, based on RAII (Resource Acquisition Is Initialization) and its ownership system, memory is deterministically and immediately freed the moment it leaves scope.

Furthermore, data structures are compactly arranged in contiguous memory regions, resulting in an extremely high CPU L1/L2 cache hit rate and significantly reducing memory access latency.


4. Boundaries of Reduction Effects: What Gets Faster and What Doesn't

The question of whether changing the test runner to a Rust-based one will halve the time for any project naturally involves engineering boundaries (trade-offs and constraints).

The reduction effect varies greatly depending on the nature of the tests a project has.

Loading diagram...

Areas where reduction effects are maximized (50% to 80% reduction)

  • Unit test-centric suites: Test groups with no external dependencies, completed solely by CPU and memory. Since the execution time per test is short, reducing runner overhead directly leads to a reduction in overall execution time.
  • TypeScript/JavaScript repositories with many files: In environments where Babel/ts-jest transpilation ran for every file with traditional runners, replacing them with a runner that includes a fast Rust-based parser/transpiler (like SWC or OXC) can yield dramatic results.

Areas with limited reduction effects (less than 10%)

  • External I/O-bound tests: If waiting for database transaction completion, network request round-trip latency, or external API responses accounts for most of the execution time, speeding up the test runner will not resolve the bottleneck.
  • Real browser E2E tests: Browser startup time, DOM rendering, and animation waiting are dominant factors, so improvements at the test runner layer contribute only marginally.

Therefore, when embarking on test acceleration, it is crucial to first measure the duration profile of the test suite and determine whether the bottleneck lies in "CPU/runner overhead" or "I/O waiting."


5. Migration Considerations and Anti-Patterns

We will organize typical pitfalls many developers face when migrating to a fast, Rust-based test runner, along with their avoidance strategies.

(1) Data Race due to Global Shared State

Tests that "happened to work" because traditional runners executed them serially or with coarse file-level isolation may fail all at once due to advanced parallelization by a Rust-based runner.

  • Rewriting properties of singleton objects
  • Rewriting a single global variable or shared configuration
  • Concurrent writes to the same test DB table

Before increasing parallelism, it is necessary to ensure the orthogonality of test design so that each test case handles a completely independent context (or data scoped by a unique test ID).

(2) Sharing current directories and environment variables

If dynamic rewriting of process.chdir() or environment variables is performed within a test case, in an environment where parallel execution occurs per thread, the impact will spread across the entire process, leading to inexplicable test failures (Flaky Tests).

The standard practice is to redesign the system to inject environment-dependent values via arguments or context (Dependency Injection) instead of using global variables.


6. Summary: Redefining Priorities in CI Acceleration

In improving test execution speed, the approach with the highest return on investment (ROI) is "modernizing the infrastructure and tool layers while minimizing code modifications."

[Recommended Order of Improvement Steps]
1. Modernization of test runners (Adoption of Rust-based runners / cargo-nextest / Vitest / Biome, etc.)
   → Almost zero code changes, applicable immediately, impact of halving execution time
2. Utilization of in-memory DBs and Tmpfs (Physical elimination of I/O overhead)
   → Elimination of disk write waits
3. Refactoring of test code (Elimination of shared state, redefinition of mock boundaries)
   → Raising the limit of parallelism

Before attempting a 10% reduction by laboriously refactoring the entire test code, first replace the test runner with a modern Rust-based foundation. This alone can halve CI wait times and accelerate the feedback loop for the entire development team.

Technical documents

We will continue to increase technical documentation.

We will continue to organize our thoughts on AI, cloud, business app development, requirements definition, and operational design into documents.

Go to technical documentation list