Skip to content

ci: parallelize docker + forge cache + mold linker (toward sub-2min CI)#86

Open
koko1123 wants to merge 3 commits into
mainfrom
koko/beaconator-ci-under-2min
Open

ci: parallelize docker + forge cache + mold linker (toward sub-2min CI)#86
koko1123 wants to merge 3 commits into
mainfrom
koko/beaconator-ci-under-2min

Conversation

@koko1123

@koko1123 koko1123 commented Jul 19, 2026

Copy link
Copy Markdown
Collaborator

Push toward sub-2-minute PR CI, driven by benchmarks rather than guesswork.

What the benchmark showed (Apple M4; GHA ubuntu-latest 4-vCPU ≈ ~3× slower)

Measurement M4
Test-job compile floor (deps cached, workspace+test bins fresh) 12.4s
Release crate recompile @ opt-level 3 26.5s
Link the release binary (alloy graph) 8.3s
Unit-test execution ~0s

Two facts drive the plan: (1) jobs are compile/link-bound, not test-bound; (2) the docker job was the tall pole and ran as a serial tail (needs: [all tests]), so warm wall-clock was ~max(tests) + docker ≈ 4min — you can't get near 2min with a heavy job stacked on the end.

Changes (this PR)

  1. docker runs in parallel with the tests (dropped its needs). Wall-clock becomes max(job) instead of tests → docker. The test aggregate gate still lists docker, so a broken image still blocks the PR. Also replaced the image smoke test's fixed sleep 15 with a readiness poll.
  2. Cache the compiled mock contracts (tests/contracts/{out,cache} keyed on the .sol sources) so forge build is a no-op in the three Foundry jobs when the mocks are unchanged.
  3. mold linker for the release/image build (Dockerfile). Installed in the cached builder layer; RUSTFLAGS routes the linker to it (keeping -D warnings) for the cook + final build. Speeds the alloy+aws binary link on the (now-parallel) docker pole. Verified locally: builds with mold 1.10.1 and the binary boots.

Paired with #85

#85 adds opt-level = 2 for release (I/O-bound service; measured 26.5s → 19.4s, ~27% off the crate recompile). #85 + this PR together attack the docker pole: parallel + opt-2 compile + mold link.

Honest scope: why mold is NOT in the CI test jobs (yet)

I deliberately scoped mold to the image build. In the CI test jobs, installing mold costs ~8s (apt) which roughly cancels the link savings, and setting RUSTFLAGS cold-invalidates the shared rust-cache (ci key) — so it's not a clear win and it degrades the next few runs. If we want it there, the right form is a prebuilt-binary install (not apt) and accepting the one-time cache reset — happy to do it as a follow-up if you want to chase the last few seconds.

Realistic expectation

Warm, with docker parallelized + opt-2 + mold + forge-cache, the tall pole becomes either the heaviest test job or the parallel docker build, landing ≈ 90–120s — sub-2-min is achievable on warm runs, borderline. It won't hold on a run that changes Cargo.lock/Dockerfile (cache miss → cold). The one bigger lever left if you want it reliably under 2min is not building the image on every PR (gate the docker job to Dockerfile/deps changes) — flagged, not done here.

Summary by CodeRabbit

  • Bug Fixes

    • Improved Docker image test reliability by checking server readiness instead of using a fixed startup delay.
  • Performance

    • Accelerated Rust application builds by using the Mold linker.
  • CI Improvements

    • Added caching for compiled mock contracts to speed up test workflows.
    • Enabled Docker checks to run in parallel with other test jobs.

koko1123 added 3 commits July 19, 2026 09:26
Drop the docker job's needs so it no longer runs as a serial tail after every
test job; the 'test' aggregate gate still requires it. Also poll the container
for readiness instead of a fixed 'sleep 15' in the image smoke test.
Cache tests/contracts/{out,cache} keyed on the .sol sources + foundry.toml so
forge build is a no-op when the mocks are unchanged, saving a solc compile in
each of the three Foundry-dependent test jobs.
Install mold in the cached builder layer and route the linker to it via RUSTFLAGS
(keeping -D warnings) for the dependency cook and the final build, speeding the
link of the alloy + aws-sdk binary on the docker job -- the critical-path pole,
which now runs in parallel with the tests. Verified locally: image builds with
mold 1.10.1 and the binary boots and serves /.
@coderabbitai

coderabbitai Bot commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 75e656cf-7476-4a3e-8a30-308f9d979ab4

📥 Commits

Reviewing files that changed from the base of the PR and between 133f885 and 5db54b7.

📒 Files selected for processing (2)
  • .github/workflows/ci.yml
  • Dockerfile

📝 Walkthrough

Walkthrough

The PR adds Foundry output caching to three CI test jobs, allows the Docker job to run in parallel while retaining aggregate gating, replaces fixed startup delay with readiness polling, and configures Rust builds to use the mold linker.

Changes

CI and Docker workflow

Layer / File(s) Summary
Rust mold linker configuration
Dockerfile
The chef build stage installs mold, and Rust uses it alongside -D warnings for dependency cooking and application builds.
Compiled mock contract caching
.github/workflows/ci.yml
The integration, wallet, and full-integration test jobs cache Foundry outputs keyed by Solidity sources and foundry.toml.
Docker job scheduling and readiness
.github/workflows/ci.yml
The Docker job no longer waits on individual test jobs, while the aggregate test gate still requires it; container verification now polls the HTTP endpoint instead of sleeping for a fixed duration.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Suggested reviewers: lukemacauley

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main CI optimizations: parallel Docker execution, Foundry caching, and the mold linker.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch koko/beaconator-ci-under-2min

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant