Skip to content

chore: build through mbx's Cargo shim, toward a warm gate - #426

Draft
kixelated wants to merge 10 commits into
mainfrom
quest/m0/checks/cache
Draft

kixelated wants to merge 10 commits into
mainfrom
quest/m0/checks/cache

Conversation

@kixelated

@kixelated kixelated commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

The land gate's just ci builds every Rust workspace cold, on every batch. moq's gate builds through mbx in a per-repository cache, so it rebuilds only what changed (A warm gate, decided with the maintainer on 2026-11-01).

Approach

Copied from moq's dev shell and its gate:

  • flake.nix: the dev shell's shellHook puts mbx's Cargo shim back ahead of the pinned toolchain when mbx setup installed one, as moq's does, and exports its directory as RUST2_CARGO_SHIM. Without mbx on PATH it does nothing.
  • ts/, ffi/, driver/ and go/ justfiles: they prepend their nightly to PATH, which would put it ahead of the shim and skip mbx. They keep the shim first.
  • uniffi_macros: generate_and_include_scaffolding! (the trybuild feature) resolves its path from the calling file, as include_str! does. The UI cases named their UDL as ../../../../uniffi/... from trybuild's project inside target/, which only works when target/ is a real directory in the checkout. mbx's managed target lives outside it.
  • The quest now holds only the host change.

bench/build/run.sh needs nothing: it re-enters its own build-bench shell, whose toolchain lands ahead of any shim, so it still measures plain Cargo.

Measurements

A whole just ci (every module, since flake.nix changed) through mbx 1.29.2, in this worktree with an empty, isolated cache, CI=true and 8 jobs. CPU-seconds come from the quest gate scope's cgroup (cpu.stat). Load average was about 14 on 32 threads.

just ci through mbx 1.29.2 CPU-s wall
empty cache, at 3d0cabc 3344 910 s
warm, same tree 798 314 s
warm, after merging main (1071 files) and the go/ fix, at dafb487 709 244 s

uniffi_uitests passed in all three. The cold run compiled its trybuild cases (147 s); the warm runs reused them (under 1 s).

Earlier, per step, with mbx 1.28.0 at af523c7 (load average 15 to 22, so cold numbers vary by about 20%):

at af523c7 root clippy uniffi test build
plain Cargo, cold 715 407
mbx, empty cache 833 677
mbx, warm, same tree 61 8.4
mbx, warm, one leaf fixture edited 117 14
mbx, warm, #364's own change 766 429
  • fix(uniffi): port current binding ownership fixes #364 changed the generator in uniffi-dart, a build dependency of 25 fixtures. Cargo itself rebuilds every dependent, so the cache cannot help there.
  • An empty cache costs more than plain Cargo, since mbx hashes and stores every output. Only the gate's first run pays that.

Host changes

The host config is outside this repository. In order:

  1. Move the land host's mbx pin from 1.28.0 to 1.29.2 or later, the first release that prints real paths for files in a build script's OUT_DIR (jdx/mr-boxington#896). Rerun mbx setup wherever a shim exists: the shim runs the mbx its mbx-target file names, not the one on PATH, so an old shim keeps running 1.28.0 while that store path exists. The local user shim on this host still names 1.28.0.
  2. Give rust2's land instance moq's per-repository mbx profile (maintainer, 2026-11-02):
    rust2 = mbxCheck // {
      id = 9;
      enable = lib.mkDefault false;
      # check.yml's Check runs the same recipe; it needs no base.
      command = "just ci";
      cpuQuota = 800;
      memoryHigh = "8G";
      memorySwapMax = "1G";
    };
  3. Enable it once this PR has merged. Check it by reading a gate run's log for mbx's cache summary (mbx[cache]: object cache: ...).

Decisions needed

  1. Merge before or after the host's mbx pin moves? The dev shell routes cargo through any mbx on PATH that has a shim. Through mbx 1.29.1, uniffi_uitests fails that way. moq's gate on the same host is pinned to 1.28.0, and I could not confirm from this repository that rust2's runner has no mbx on its PATH.
    • A (recommended): hold this draft until host step 1 lands, then merge, then do steps 2 and 3. This removes the only risk, and step 1 is needed anyway.
    • B: merge now. This is safe if rust2's runner has no mbx, which is likely while it has no mbx profile. If it does have mbx, every queue batch fails at uniffi_uitests until step 1.
    • C: have the shell hook skip mbx older than 1.29.2. Not recommended: the check stops mattering once the pin moves, and it silently falls back to plain Cargo.

Settled earlier (2026-11-02): wait for the upstream fix rather than keep uniffi_uitests off mbx. mbx v1.29.2 (2026-11-03) shipped that fix in jdx/mr-boxington#897.

Impact

  • uniffi_macros::generate_and_include_scaffolding! (trybuild feature only): a relative path now resolves from the calling file, not from rustc's working directory. This is breaking. There is no MIGRATE.md entry, since docs: drop MIGRATE.md until the first release #571 dropped those until the first release. The fork's README lists it as a carried change.
  • Dev shell: RUST2_CARGO_SHIM is set when an mbx shim exists.

Alternatives

  • One cache shared with moq: ruled out by the per-repository decision.
  • Setting CARGO_TARGET_DIR inside the checkout to keep trybuild's relative paths working: that gives up mbx's managed targets, and the paths would still break for anyone who keeps a target elsewhere.

Follow-ups

  • Host steps above. The quest stays open for them.

Review

  • Reviewer: Codex, gpt-6.1-sol, medium (quest review --new), 2 rounds. Head reviewed: dafb487. Round 2: no findings.
  • Round 1 [medium] ffi/tests/api.py:18, restore UTF-8/LF stdout: refuted. The branch never touched that file. The round diffed against an origin/main that had moved past the branch's merge. After merging main again, git diff origin/main -- ffi/tests/api.py is empty.
  • The earlier session's P1 (resolve trybuild failures before enabling mbx) is fixed upstream by mbx 1.29.2, verified by the runs above.

Checks

  • just ci through mbx 1.29.2: passed at 3d0cabc (cold and warm) and at dafb487 (head).
  • just check: passed at 3d0cabc.
  • The optional Bench FFI (Swift) check failed on the old head a6755ce with unknown or missing subcommand 'swift-test' from the bench harness on its fork build. This diff does not touch the bench or Swift.

🤖 Generated with Claude Code

kixelated and others added 5 commits November 1, 2026 23:43
Quest-Claim: 8db415673a8cd2e6
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e calling file

trybuild compiles from inside the target directory, which mbx's managed
target moves out of the checkout.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated kixelated changed the title A warm gate chore: build through mbx's Cargo shim, toward a warm gate Nov 2, 2026
kixelated and others added 5 commits November 2, 2026 07:01
…ck on the host

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… remains

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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