perf: reduce test build time by 4.4x via profile optimization#2654
Open
perf: reduce test build time by 4.4x via profile optimization#2654
Conversation
Self-profiling revealed that 97% of miden-testing's build time was spent in LLVM codegen/optimization. The previous `opt-level = 1` for all crates in test-dev caused LLVM to optimize the large amount of monomorphized code from Plonky3-backed generics. Split the optimization strategy: workspace crates compile at opt-level 0 (fast compilation, code is mostly test setup/glue) while external dependencies compile at opt-level 2 (crypto/ZK operations need optimization for acceptable test execution speed). Results (clean build, 60-core machine): - Total build time: 7m 39s -> 1m 45s (4.4x faster) - miden-testing lib: 390s -> 25s (15.6x faster) - All 778 tests pass, slowest test takes ~90s Closes #2643 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
|
Thank you for looking into this! On my machine (16-core M4 Max), I'm getting somewhat different results. Running
Running
So, while building definitely go faster, I see significant degradation in test times. For |
Contributor
|
Thanks! I checked test execution times and ran
I don't think I understand why compiling the protocol crates with opt-level = 0 degrades performance that much, but it looks like we can't skip all optimizations? Maybe we need to have two configs:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
miden-testing's build time was spent in LLVM codegen/optimization, not in Rust compilation phasesopt-level = 1for all crates intest-devcaused LLVM to optimize the large amount of monomorphized code from Plonky3-backed genericsopt-level = 0(fast compilation, code is mostly test setup/glue) while external dependencies compile atopt-level = 2(crypto/ZK operations need optimization for acceptable test execution speed)Results (clean build, 60-core machine)
Profiling methodology
cargo build --timingsfor per-crate compilation timescargo llvm-linesfor monomorphization analysisRUSTFLAGS="-Zself-profile"withsummarizefor detailed breakdown of compiler phasesThe self-profile data showed that for
miden-testing lib (test):finish_ongoing_codegen: 268s (25.5%)LLVM_module_codegen_emit_obj: 187s (17.9%)LLVM_module_optimize: 154s (14.7%)LLVM_thinlto: 152s (14.5%)LLVM_passes: 125s (11.9%)LLVM_lto_optimize: 88s (8.4%)All Rust-level compilation (typeck, monomorphization, MIR) was <5s total.
Test plan
make lintpassesmake test-devpasses (778 tests, no regressions)Closes #2643
🤖 Generated with Claude Code