Skip to content

perf(build): move baml_std rustgen out of build.rs to kill the double-compile - #3615

Closed
hellovai wants to merge 10 commits into
canaryfrom
hellovai/compile-times
Closed

perf(build): move baml_std rustgen out of build.rs to kill the double-compile#3615
hellovai wants to merge 10 commits into
canaryfrom
hellovai/compile-times

Conversation

@hellovai

@hellovai hellovai commented May 30, 2026

Copy link
Copy Markdown
Contributor

Moves the BAML stdlib rust codegen out of build.rs and commits the output.

sys_types, sys_ops, bex_vm, and bex_vm_types run baml_builtins2_codegen from build.rs, which puts baml_compiler2_ast in their build-dependency graph. Cargo compiles the ast subtree twice (host + target) and re-runs the build scripts on every ast edit — on top of an already-expensive rebuild, since ast is at the bottom of the IR spine.

This generates those files ahead of time, commits them, and replaces the four build scripts with a hash check that doesn't run codegen.

Impact

cargo build --bin baml-cli after touching ast:

metric before after
ast rustc invocations 2 1
crates rebuilt 29 16
CPU (user) ~10.5s ~7.4s (−30%)

Wall-clock barely moves on a many-core machine (the serial spine still gates it); the win shows up on --workspace, the test build, and CI.

Working with the generated code

Now committed:

  • sys_types/src/{io_generated,runtime_io}.rs
  • sys_ops/src/{io_generated,io_adapter}.rs
  • bex_vm/src/package_baml/nativefunctions_generated.rs
  • bex_vm_types/src/{sys_op,errors,panics}_generated.rs

After changing baml_builtins2/baml_std/** or the codegen logic, regenerate and commit:

cargo run -p tools_rustgen      # or: mise run codegen

Two guards keep it honest:

  • build time — each crate's build.rs hashes the relevant baml_std surface and fails the build (pointing at the command) when its file is stale. Depends only on the zero-dep baml_rustgen_check, so the compiler stays out of the build graph.
  • CItools_rustgen's up_to_date test regenerates and diffs; the catch-all.

The hash only covers what drives codegen ($rust_function/$rust_io_function/$compiler_intrinsic signatures, their //baml: directives, class fields), so docs / formatting / pure-BAML edits don't trigger a regen.

Tradeoffs

  • + compiler out of the build-dependency graph; clean/incremental builds cheaper; generated code shows up in the diff (reviewable).
  • regenerate-and-commit becomes a step (enforced, so it can't silently drift); two new crates; the build-time hash is a lexical heuristic — the regen test is the real guarantee.

Also in here

  • New crates: tools_rustgen (generator) and baml_rustgen_check (zero-dep guard, 23 tests).
  • .gitattributes pins the generated files to LF so the byte-exact check passes on Windows.
  • size-gate: +100 KiB on the baml-cli macOS/Windows ceilings — the binary was flush against them and LTO jitter (+0.1%) was tripping the gate; the 3% delta guard is unchanged.

Not in this PR: the Blacksmith CI cache (bench cache never persists; the GitHub-cache finalize races the runner teardown) is an infra setting — enable transparent cache — tracked separately.

@vercel

vercel Bot commented May 30, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
beps Ready Ready Preview, Comment May 31, 2026 5:32am
promptfiddle Ready Ready Preview, Comment May 31, 2026 5:32am
promptfiddle2 Ready Ready Preview, Comment May 31, 2026 5:32am

Request Review

@coderabbitai

coderabbitai Bot commented May 30, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This PR adds a deterministic staleness-check crate and a centralized codegen tool, replaces per-crate code generation with verification-only build scripts that assert checked-in generated sources match the baml stdlib, and updates workspace includes, manifests, and dev tooling configuration.

Changes

Build-time Staleness Check and Centralized Codegen Refactor

Layer / File(s) Summary
Staleness Check Infrastructure
baml_language/crates/baml_rustgen_check/Cargo.toml, baml_language/crates/baml_rustgen_check/src/lib.rs
New baml_rustgen_check crate provides deterministic FNV-1a hashing of baml_std "codegen-relevant" surface (builtin markers, directives, class/enum declarations without bodies), embeds hashes into generated file headers, and exposes rerun_if_baml_std_changed() and assert_generated_matches_baml_std() for Cargo build integration. Includes comprehensive unit tests validating extraction rules and noise robustness.
Centralized Code Generation Tool
baml_language/crates/tools_rustgen/Cargo.toml, baml_language/crates/tools_rustgen/src/lib.rs, baml_language/crates/tools_rustgen/src/main.rs, baml_language/crates/tools_rustgen/tests/up_to_date.rs
New tools_rustgen binary consolidates code generation from distributed build.rs scripts. render_all() invokes baml_builtins2_codegen to produce outputs, wraps them with baml_rustgen_check headers; write_all() persists checked-in crate files and a test enforces freshness.
Generated Type Enums and Includes
baml_language/crates/bex_vm_types/src/errors_generated.rs, baml_language/crates/bex_vm_types/src/panics_generated.rs, baml_language/crates/bex_vm_types/src/sys_op_generated.rs, baml_language/crates/bex_vm_types/src/types.rs
Auto-generated ErrorClass, PanicClass, and SysOp enums with mapping helpers and lookup tables. Crate include! targets were switched from OUT_DIR to local checked-in generated files.
Generated Runtime IO Abstraction and Adapter
baml_language/crates/sys_types/src/runtime_io.rs, baml_language/crates/sys_types/src/lib.rs, baml_language/crates/sys_ops/src/io_adapter.rs, baml_language/crates/sys_ops/src/lib.rs
Generated RuntimeIoError, handle wrapper structs, RuntimeIo trait (defaults return Unsupported), NoopRuntimeIo, and RuntimeIoAdapter implementing RuntimeIo by calling SysOp function pointers with marshalling and permit handling. Includes switch of include! targets to local files and a build_runtime_io() factory.
Build Script Migrations and Verification
baml_language/crates/bex_vm/*, baml_language/crates/bex_vm_types/*, baml_language/crates/sys_ops/*, baml_language/crates/sys_types/*
Per-crate build.rs scripts converted to verification-only mode that call baml_rustgen_check::rerun_if_baml_std_changed() and assert_generated_matches_baml_std(...). [build-dependencies] updated to depend on baml_rustgen_check and removed previous codegen build deps.
Configuration and Environment Setup
.envrc, baml_language/Cargo.toml, baml_language/mise.toml, baml_language/stow.toml, .gitattributes, .github/workflows/ci.yaml
Workspace dependency declares baml_rustgen_check; [profile.dev] debug settings adjusted; MISE tasks.codegen added; .envrc conditionally sets RUSTC_WRAPPER to sccache when available; stow.toml approves rustgen prefixes; .gitattributes enforces LF for generated files; CI job cache action updated in workflow.

Sequence Diagram

sequenceDiagram
  participant Developer
  participant ToolsRustgen
  participant BamlRustgenCheck
  participant Filesystem
  participant BuildScript
  Developer->>ToolsRustgen: run `cargo run -p tools_rustgen`
  ToolsRustgen->>BamlRustgenCheck: header() wrap generated outputs
  ToolsRustgen->>Filesystem: write checked-in generated files
  BuildScript->>BamlRustgenCheck: assert_generated_matches_baml_std(rel_path)
  BamlRustgenCheck->>Filesystem: read generated file header
  BamlRustgenCheck->>BamlRustgenCheck: recompute expected hash from baml_std
  alt match
    BamlRustgenCheck->>BuildScript: no-op (build continues)
  else mismatch
    BamlRustgenCheck->>BuildScript: panic with mismatch details
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Poem

🐰 I hopped through crates both near and far,
Collected hashes like a tiny star.
Tools render code, headers tuck them tight,
Build scripts check — no gen at build-time night.
Hop, regen, commit — the repo's bright.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main performance optimization: moving baml_std code generation from build.rs execution to pre-generated checked-in files to eliminate a double-compile issue.
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch hellovai/compile-times

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@github-actions

github-actions Bot commented May 30, 2026

Copy link
Copy Markdown

Binary size checks passed

7 passed

Artifact Platform File Gzip Gated on Baseline Delta Status
baml-cli Linux 🔒 20.0 MB 8.3 MB file 19.4 MB +572.7 KB (+3.0%) OK
packed-program Linux 🔒 15.0 MB 6.3 MB file 14.7 MB +337.2 KB (+2.3%) OK
baml-cli macOS 🔒 15.1 MB 7.2 MB file 15.1 MB +16.5 KB (+0.1%) OK
packed-program macOS 🔒 11.4 MB 5.5 MB file 11.2 MB +264.9 KB (+2.4%) OK
baml-cli Windows 🔒 16.3 MB 7.4 MB file 16.3 MB +15.4 KB (+0.1%) OK
packed-program Windows 🔒 12.2 MB 5.6 MB file 11.9 MB +307.0 KB (+2.6%) OK
bridge_wasm WASM 13.4 MB 🔒 3.9 MB gzip 3.8 MB +1.4 KB (+0.0%) OK

🔒 = the size this artifact is GATED on (ceiling + delta). Binaries gate on file size (installed binary); WASM gates on gzip (download size). The other size is shown for information only.


Generated by cargo size-gate · workflow run

@codspeed-hq

codspeed-hq Bot commented May 30, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by 10.75%

⚡ 1 improved benchmark
✅ 12 untouched benchmarks
⏩ 7 skipped benchmarks1

Performance Changes

Mode Benchmark BASE HEAD Efficiency
WallTime vm_loop_500k 117.7 ms 106.3 ms +10.75%

Tip

Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.


Comparing hellovai/compile-times (1af4957) with canary (066b6cb)

Open in CodSpeed

Footnotes

  1. 7 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@hellovai
hellovai marked this pull request as ready for review May 30, 2026 22:57
@hellovai

Copy link
Copy Markdown
Contributor Author

@codspeedbot explain why this is faster

@codspeed-hq

codspeed-hq Bot commented May 30, 2026

Copy link
Copy Markdown

@codspeedbot explain why this is faster

⚡ Performance Analysis: vm_loop_500k (+10.76%)

Flamegraph comparison

Function BASE (canary) HEAD (this PR) Delta
BexVm::exec (self time) 111.9 ms (94.6%) 100.6 ms (94.2%) −11.3 ms (−10.1%)
BexVm::store_local_value (self time) 5.8 ms (4.9%) 5.6 ms (5.2%) −0.2 ms (−3.4%)
Total 118.2 ms 106.8 ms −11.4 ms (−9.6%)

Why is it faster?

The improvement is almost entirely concentrated in BexVm::exec — the core opcode dispatch loop of the VM. This PR doesn't directly modify any runtime code, so the speedup is a code layout / instruction alignment effect caused by the build-system changes.

Here's what's happening:

  1. Changed dependency graph → different link order. By removing baml_compiler2_ast from the build-dependency graph of four crates, the overall compilation and linking order changed. This shifts where functions land in the final binary.

  2. vm_loop_500k is extremely alignment-sensitive. This benchmark is a tight integer loop that spends 94%+ of its time in a single function (BexVm::exec). Opcode dispatch loops like this are dominated by instruction-cache behavior and branch-predictor alignment. Even small shifts in where hot basic blocks land relative to cache-line and fetch-block boundaries can produce 5–15% swings.

  3. The binary was recompiled differently. The monomorphization hash changed (h043a1c…hbe9b24…), confirming LLVM made different code generation decisions for this function in the new build graph — likely better alignment of the hot dispatch paths.

Bottom line

This is a favorable but incidental side effect of the build restructuring — the kind of performance delta that's real and reproducible within the same binary, but tied to code layout rather than algorithmic improvement. The primary win of this PR remains the ~30% reduction in rebuild CPU time after AST edits.

Summary
  • Warming up the performance wizard...
  • Analyzing performance improvement — Flamegraph analysis complete for both HEAD and BASE runs
  • Handling comment — Comment handling finished successfully

Was this response helpful? React with 👍 or 👎 to help us improve CodSpeedBot.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@baml_language/crates/baml_rustgen_check/src/lib.rs`:
- Around line 67-82: The walk() function currently swallows std::fs::read_dir
and std::fs::read errors causing partial input collection; change walk to return
a Result<(), std::io::Error> (or appropriate error type) and propagate errors
with ? for std::fs::read_dir(dir) and std::fs::read(&path) instead of skipping,
and update collect_inputs() to propagate its Result as well so any I/O failure
bubbles up to the caller; reference the walk(root: &Path, dir: &Path, out: &mut
Vec<(String, Vec<u8>)>) and collect_inputs() signatures and ensure callers
handle or return the propagated Result.

In `@baml_language/crates/sys_types/build.rs`:
- Around line 6-9: The build script is using incorrect package-relative paths
(“sys_types/src/...”) in calls to baml_rustgen_check; update the assertions to
use crate-local paths ("src/io_generated.rs" and "src/runtime_io.rs") and any
other occurrences, i.e., change the two assert_generated_matches_baml_std(...)
calls in main() (and keep baml_rustgen_check::rerun_if_baml_std_changed() as-is)
so they reference "src/io_generated.rs" and "src/runtime_io.rs" instead of the
nested "sys_types/..." paths.

In `@baml_language/crates/tools_rustgen/src/main.rs`:
- Around line 7-11: The status message is misleading because
tools_rustgen::write_all() always rewrites files; update the final eprintln so
it reflects that files were written rather than "up to date" — e.g., change the
message that currently uses written.len() to "wrote N file(s)" or "generated N
file(s)"; locate the write_all() call and the written variable in main.rs (the
println! loop and the final eprintln!) and replace the misleading text
accordingly (or alternatively modify write_all() to return created/unchanged
sets and use those to report accurate counts).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 071f1f3f-b949-4a5e-9ea4-83ed133eedd0

📥 Commits

Reviewing files that changed from the base of the PR and between 066b6cb and 08429f7.

⛔ Files ignored due to path filters (1)
  • baml_language/Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (30)
  • .envrc
  • baml_language/Cargo.toml
  • baml_language/crates/baml_rustgen_check/Cargo.toml
  • baml_language/crates/baml_rustgen_check/src/lib.rs
  • baml_language/crates/bex_vm/Cargo.toml
  • baml_language/crates/bex_vm/build.rs
  • baml_language/crates/bex_vm/src/package_baml/mod.rs
  • baml_language/crates/bex_vm/src/package_baml/nativefunctions_generated.rs
  • baml_language/crates/bex_vm_types/Cargo.toml
  • baml_language/crates/bex_vm_types/build.rs
  • baml_language/crates/bex_vm_types/src/errors_generated.rs
  • baml_language/crates/bex_vm_types/src/panics_generated.rs
  • baml_language/crates/bex_vm_types/src/sys_op_generated.rs
  • baml_language/crates/bex_vm_types/src/types.rs
  • baml_language/crates/sys_ops/Cargo.toml
  • baml_language/crates/sys_ops/build.rs
  • baml_language/crates/sys_ops/src/io_adapter.rs
  • baml_language/crates/sys_ops/src/io_generated.rs
  • baml_language/crates/sys_ops/src/lib.rs
  • baml_language/crates/sys_types/Cargo.toml
  • baml_language/crates/sys_types/build.rs
  • baml_language/crates/sys_types/src/io_generated.rs
  • baml_language/crates/sys_types/src/lib.rs
  • baml_language/crates/sys_types/src/runtime_io.rs
  • baml_language/crates/tools_rustgen/Cargo.toml
  • baml_language/crates/tools_rustgen/src/lib.rs
  • baml_language/crates/tools_rustgen/src/main.rs
  • baml_language/crates/tools_rustgen/tests/up_to_date.rs
  • baml_language/mise.toml
  • baml_language/stow.toml

Comment thread baml_language/crates/baml_rustgen_check/src/lib.rs
Comment thread baml_language/crates/baml_rustgen_check/src/lib.rs
Comment thread baml_language/crates/sys_types/build.rs
Comment thread baml_language/crates/tools_rustgen/src/main.rs Outdated
…-compile

The build.rs of sys_types, sys_ops, bex_vm, and bex_vm_types each ran
baml_builtins2_codegen at build time, which pulled baml_compiler2_ast into
their *build*-dependency graph. Cargo then compiled the ast subtree twice
(once for the host build scripts, once for the target) and re-ran those build
scripts on every ast edit — slowing both clean builds and the edit→rebuild loop.

Instead, generate the builtin/IO source files ahead of time and check them in:

- `crates/tools_rustgen` (binary): runs the same `baml_builtins2_codegen`
  calls and writes the 8 generated files into the crates' `src/` dirs.
  Invoke with `cargo run -p tools_rustgen` (or `mise run codegen`).
- `include!(concat!(env!("OUT_DIR"), ...))` → `include!("<local>.rs")`.
- The 4 build.rs no longer run codegen.

Freshness is guarded at two layers so nothing silently goes out of sync:

- `crates/baml_rustgen_check` (zero-dependency): hashes the codegen-relevant
  surface of baml_std — builtin signatures, `//baml:` directives, and class
  fields — and embeds a per-file hash in each generated file's header. Each
  crate's build.rs calls `assert_generated_matches_baml_std(...)` and fails the
  build if the checked-in file drifts. It depends only on baml_rustgen_check
  (no ast), so the double-compile stays gone. 23 unit tests pin the lexical
  extraction (directives, class fields, multi-line sigs, pure-BAML functions
  dropped, comments/docs ignored).
- `tools_rustgen`'s `up_to_date` test regenerates for real and diffs — the
  complete backstop (also covers codegen-logic changes) — and runs in CI's
  workspace nextest on all three OSes.

Measured (cargo build --bin baml-cli after an ast edit): ast compiles 2x → 1x;
cascade 29 → 16 crates; ~30% less CPU.

Also includes small, on-theme compile-time tweaks:
- `[profile.dev]` debug = "line-tables-only" + split-debuginfo = "unpacked".
- sccache wired via mise.toml [tools] + .envrc RUSTC_WRAPPER (scaffolding
  existed but RUSTC_WRAPPER was never set, so caching was inert).
- stow.toml: add "rustgen" to the baml namespace approved_prefixes.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
hellovai and others added 3 commits May 30, 2026 16:57
The `benchmarks-build` job runs on a Blacksmith self-hosted ARM64 runner. Its
`Swatinem/rust-cache` save uploads the ~4GB cache to 100%, but the GitHub cache
backend's *finalize* step races the runner's immediate post-job shutdown
("Proceeding with shutdown immediately"), so the entry is never committed —
every run is then a cold "No cache found". Confirmed via the cache API: no
`v0-rust-linux-arm-bench` entry exists in the store despite a successful canary
save log (and in fact no `v0-rust-linux-*` Blacksmith cache persists at all,
while the GitHub-hosted `macos-cargo` cache does).

Swap to `useblacksmith/rust-cache@v3` — Blacksmith's drop-in for
Swatinem/rust-cache — which uses Blacksmith's own cache backend and has no
teardown/finalize race. If this confirms the fix on canary, the same one-line
swap should be applied to the other `blacksmith-*` jobs.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Temporarily set the benchmarks-build rust-cache `save-if: true` (normally
canary-only) so this PR's own bench-build run saves the cache via
useblacksmith/rust-cache. Lets us confirm the cache now persists (the
finalize/teardown race is gone) without merging to canary first.

REVERT this commit before merge — production behavior must remain
`save-if: ${{ github.ref == 'refs/heads/canary' }}`.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…-cache@v3 ignores it)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Confirmed on PR run 26698883614: useblacksmith/rust-cache@v3 restored the
bench cache ('Cache restored successfully') that the prior run saved to
Blacksmith's backend — the GitHub-cache finalize/teardown race is gone. Drop
the temporary save-if:true used for the test; production stays canary-only.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Validated on the bench job (prior run saved, next run "Cache restored
successfully"): the GitHub cache backend's finalize races the Blacksmith
runner's immediate post-job teardown, so NONE of the v0-rust-linux-* caches
ever persisted — every Blacksmith Rust job ran cold on every PR.

Swap Swatinem/rust-cache@v2 -> useblacksmith/rust-cache@v3 (Blacksmith's
drop-in, no teardown race) on every Blacksmith-runner job: prek, proto-sync,
the cargo-tests linux/windows legs (+ the non-macOS matrix legs), size-gate
linux/windows, and wasm-pack. Dropped the unsupported `cache-workspace-crates`
input on the swapped steps.

The two GitHub-hosted macOS jobs (cargo-test-macos, size-gate-macos) stay on
Swatinem/rust-cache — useblacksmith only applies to Blacksmith runners. Since
`uses:` can't be an expression, the mixed-runner cargo-tests matrix job uses
two `if: matrix.os-label`-gated cache steps.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
.github/workflows/cargo-tests.reusable.yaml (1)

65-74: ⚡ Quick win

Update the cache-strategy doc — cache-workspace-crates: true is no longer universal.

This block states every rust-cache invocation passes both cache-all-crates: true and cache-workspace-crates: true, and explains that the latter keeps the compiled workspace target/ so PRs reading canary's cache "restart with the workspace crates already built." After this PR, the migrated useblacksmith/rust-cache@v3 steps (linux/windows/wasm/msrv/cargo-doc/snapshot) no longer pass cache-workspace-crates; only the macOS Swatinem step still does.

Since the Swatinem default for that input is false, dropping it means workspace-crate artifacts are no longer cached on those legs — a real behavior change, not just a doc nit (PRs lose the warm workspace target/ on the affected platforms). Please reconcile the comment with the new reality and confirm whether the lost workspace-crate caching is intended (the PR notes v3 doesn't support this input).

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/cargo-tests.reusable.yaml around lines 65 - 74, The
comment claiming "Every rust-cache invocation also passes `cache-all-crates:
true` and `cache-workspace-crates: true`" is now inaccurate after migrating to
useblacksmith/rust-cache@v3; update the doc block to state that
`cache-workspace-crates` is not passed on all legs (only the macOS "Swatinem"
step still sets it) and explicitly note the behavioral impact (workspace
`target/` artifacts are not cached on other platforms), and either confirm in
the comment that this loss of workspace-crate caching is intentional or
revert/add the input where needed; reference the strings
`cache-workspace-crates`, `cache-all-crates`, and `useblacksmith/rust-cache@v3`
when making the change.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/ci.yaml:
- Line 257: Replace the archived action reference "uses:
useblacksmith/rust-cache@v3" with the upstream maintained Rust cache action
(Swatinem/rust-cache) wherever it appears in workflow YAMLs; update the action
entry to use the Swatinem/rust-cache release (e.g.,
Swatinem/rust-cache@<stable-tag>) and make the same replacement for the
identical occurrences in the other workflow files so CI uses the supported
upstream cache implementation.

---

Nitpick comments:
In @.github/workflows/cargo-tests.reusable.yaml:
- Around line 65-74: The comment claiming "Every rust-cache invocation also
passes `cache-all-crates: true` and `cache-workspace-crates: true`" is now
inaccurate after migrating to useblacksmith/rust-cache@v3; update the doc block
to state that `cache-workspace-crates` is not passed on all legs (only the macOS
"Swatinem" step still sets it) and explicitly note the behavioral impact
(workspace `target/` artifacts are not cached on other platforms), and either
confirm in the comment that this loss of workspace-crate caching is intentional
or revert/add the input where needed; reference the strings
`cache-workspace-crates`, `cache-all-crates`, and `useblacksmith/rust-cache@v3`
when making the change.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: f59a26fd-df9e-4022-b109-18bceb7be722

📥 Commits

Reviewing files that changed from the base of the PR and between 030a542 and 2422e2b.

📒 Files selected for processing (4)
  • .github/workflows/cargo-tests.reusable.yaml
  • .github/workflows/ci.yaml
  • .github/workflows/size-gate.reusable.yaml
  • .github/workflows/wasm-pack-tests.reusable.yaml

Comment thread .github/workflows/ci.yaml Outdated
baml-cli had grown flush against its macOS (15_072_808) and Windows
(16_273_800) max_file_bytes ceilings; build/LTO jitter tipped it +0.1% over,
failing size-gate. The PR's codegen refactor is size-neutral (checked-in code
== build.rs output; no new deps in baml-cli). Add 100 KiB headroom to each
ceiling. The 3% max_delta_pct still guards genuine regressions.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…hived)

Per Blacksmith's docs, `useblacksmith/rust-cache` (and the other useblacksmith/*
cache forks) are archived/unmaintained: Blacksmith now TRANSPARENTLY redirects
the upstream GitHub/third-party cache actions (Swatinem/rust-cache,
actions/cache) to their colocated cache with zero code changes. The repo's
cache design already targets GitHub-cache semantics (canary-only savers + the
daily canary-cache-refresh cycle), which Blacksmith accelerates transparently.

So revert all the useblacksmith@v3 swaps + the matrix conditional split + the
temporary save-if back to canary's upstream Swatinem@v2 setup (the 4 workflow
files now match canary exactly). The bench-cache non-persistence we diagnosed is
an infra concern — confirm Blacksmith's transparent cache is enabled for the
repo/ARM runners — not a code change.

Kept: the +100 KiB baml-cli size-gate ceiling bump (validated green).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Address CodeRabbit review on PR #3615:
- baml_rustgen_check::walk now panics on read_dir/read errors instead of
  silently skipping them — a partial/unreadable source-of-truth must abort the
  build/regen, never hash a partial tree that could match stale output. (#1)
- tools_rustgen status message: "wrote N generated file(s)" instead of the
  misleading "up to date" (write_all always rewrites). (#4)
- Document normalize()'s known whitespace-in-string-literal limitation; the
  up_to_date regen test is the backstop, so a quote-aware tokenizer isn't worth
  the complexity. (#2)

Not changed: the build.rs "sys_types/src/..." paths flagged critical are
correct — assert_generated_matches_baml_std resolves via crates_dir()
(CARGO_MANIFEST_DIR/..), not the build script cwd, and CI is green. (#3)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@hellovai

hellovai commented Jun 1, 2026

Copy link
Copy Markdown
Contributor Author

the 3second compile time is not worht the workflow change.

@hellovai hellovai closed this Jun 1, 2026
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