Skip to content

Commit 611434f

Browse files
committed
perf: enable thin LTO and single codegen unit for release builds
Release builds ran on cargo's defaults (16 codegen units, no LTO), so the optimizer never saw across crate boundaries. The hot paths are spread over several workspace crates and their dependencies -- SSZ encode/decode, hashing, fork choice traversal -- which is exactly the shape that loses the most to per-crate codegen units. Adopt the same release profile ethrex uses: opt-level 3, thin LTO, one codegen unit. Clean `cargo build --release --bin ethlambda`, aarch64-apple-darwin, 11 cores, isolated target dirs: wall CPU binary before 315.9s 1714s 30.6 MiB after 377.8s 1516s 26.6 MiB +20% -12% -13% Wall clock grows because a single codegen unit serializes per-crate codegen, even though total CPU work drops. CI's test job builds in release, so its cold-cache builds get the same increase. Runtime effect is not measured here: the repo has no benchmarks, and the meaningful comparison (block build and aggregation latency) needs a devnet A/B.
1 parent 4daf481 commit 611434f

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

Cargo.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,16 @@ repository = "https://github.com/lambdaclass/ethlambda"
2626
rust-version = "1.92.0"
2727
version = "0.1.0"
2828

29+
# Cross-crate inlining matters here: the hot paths (SSZ encode/decode, hashing,
30+
# fork choice traversal) are split across workspace crates and their
31+
# dependencies, so keeping every crate in its own codegen unit leaves inlining
32+
# opportunities on the table. Thin LTO plus a single codegen unit trades build
33+
# time for that, matching ethrex's release profile.
34+
[profile.release]
35+
opt-level = 3
36+
lto = "thin"
37+
codegen-units = 1
38+
2939
[workspace.dependencies]
3040
ethlambda-blockchain = { path = "crates/blockchain" }
3141
ethlambda-fork-choice = { path = "crates/blockchain/fork_choice" }

0 commit comments

Comments
 (0)