Skip to content

perf(build): optimize deps but not workspace crates in dev/test#29507

Closed
mohammadfawaz wants to merge 1 commit into
masterfrom
perf/build-profiles
Closed

perf(build): optimize deps but not workspace crates in dev/test#29507
mohammadfawaz wants to merge 1 commit into
masterfrom
perf/build-profiles

Conversation

@mohammadfawaz

Copy link
Copy Markdown
Collaborator

What

Speeds up local build iteration by splitting optimization between Leo's own crates and its dependencies:

  • dev/test profiles: workspace crates drop from opt-level = 21 (fast incremental rebuilds), while all dependencies build at opt-level = 3 via [profile.<p>.package."*"]. snarkVM and friends are compiled once and cached, so runtime — including snarkVM proving in the test suite — stays fast even though our own crates are barely optimized.
  • test profile now emits debug = "line-tables-only" instead of full debuginfo — keeps file/line in backtraces, much cheaper to generate and link.
  • ci profile pins package."*" back to opt-level = 1, so the new dependency optimization does not leak in through inherits = "test" and slow CI's near-clean builds.

Why

The runtime hot path is inside snarkVM, not Leo's passes, so optimizing the workspace at -O2 on every edit cost compile time without buying meaningful runtime. This is the standard "optimize deps, not your code" dev-profile split.

Verification

cargo build -v confirms the resolved flags:

  • dev: leo_spanopt-level=1, fxhash/indexmapopt-level=3
  • ci: every crate → opt-level=1 (CI compile time unchanged)

Deliberately not in this PR (need benchmarking / sign-off)

  • Gating snarkVM's rocks feature off the default/test builds — would remove the RocksDB C++ + bindgen compile (and the CI libclang install) from builds that don't need persistent storage. Biggest cold-build win, but a behavior change.
  • Shrinking the full-snarkvm reach in parser/ast (they pull the umbrella crate but mostly need the lighter snarkvm-console subset they already depend on) — improves build-graph parallelism, but needs an import refactor + verification.
  • Faster linker (lld/mold) via .cargo/config.toml — left as a per-developer opt-in rather than forced repo-wide, since not every machine/CI image ships it.
  • The existing .cargo/config.toml has a malformed cfg(... not(feature = "noconfig))) (unterminated string) that silently disables its target-cpu=native rule — flagging separately since fixing it changes runtime codegen, not build speed.

🤖 Generated with Claude Code

Local iteration recompiled Leo's own crates at opt-level 2 on every edit.
Drop the workspace crates to opt-level 1 in the dev and test profiles while
building all dependencies (notably the large snarkVM tree, which is compiled
once and cached) at opt-level 3, so runtime — including snarkVM proving in the
test suite — stays fast while incremental rebuilds get much cheaper.

Also emit line-tables-only debuginfo for the test profile (enough for file/line
in backtraces, far cheaper to generate and link than full debuginfo), and pin
the ci profile's dependencies to opt-level 1 so the new dependency optimization
does not leak in via `inherits` and slow CI's near-clean builds.

Verified with `cargo build -v`: under dev, workspace crates resolve to
opt-level 1 and dependencies to opt-level 3; under ci, every crate stays at
opt-level 1.
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