Skip to content

Optimize release builds and preserve profiling symbols - #77

Merged
mveril merged 2 commits into
mainfrom
perf/optimize-release-profiles
Sep 18, 2026
Merged

mveril merged 2 commits into
mainfrom
perf/optimize-release-profiles

Conversation

@mveril

@mveril mveril commented Sep 18, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Optimize release builds with thin LTO, one codegen unit, and symbol stripping.
  • Keep the profiling profile optimized while retaining full debug information and symbols.
  • Document all Cargo profiles and the stable-Rust command for targeting the build machine's CPU. There is no redundant native profile.

Before/after benchmarks

Both variants use the same source and default features. "Before" uses Cargo's default release settings (lto=false, codegen-units=16, strip="none") through cargo --config overrides; "after" uses this PR's release profile. Benchmarks ran on the same 12-logical-CPU host with fixed Rayon thread counts.

End-to-end RHF: samples/ethanol/6-31g/calculation.toml, local basis fixture, downloads disabled, JSON output. The 1-thread data uses Hyperfine with 2 warmups and 10 runs per binary. The 4-thread data uses 10 alternating before/after pairs to control for run-order effects.

Rayon threads Before, mean ± SD After, mean ± SD Time reduction
1 2.254 ± 0.022 s 2.155 ± 0.008 s 4.4%
4 0.785 ± 0.034 s 0.754 ± 0.036 s 4.0%

The JSON results are identical, including the RHF total energy of -153.9984834558699 Hartree. The release binary shrinks from 22.56 MB to 13.44 MB (40.5%).

MP2 kernel: The existing benches/mp2_timings.rs benchmark runs synthetic RHF MP2 at 80 AO functions, 26 occupied orbitals, and a fixed 1 GB memory budget. Each invocation warms up and reports the median of three blocked-contraction timings; the table summarizes five alternating invocations per variant. The benchmark also checks blocked and dense energies agree.

Rayon threads Before blocked MP2, mean ± SD After blocked MP2, mean ± SD
1 466.7 ± 4.6 ms 467.0 ± 5.1 ms
4 460.2 ± 15.5 ms 454.0 ± 8.0 ms

The MP2 differences are small relative to their variation, so this benchmark does not establish a kernel speedup. Four threads matter substantially for the full calculation; the original 1-thread-only benchmark was insufficient. Fat LTO with one codegen unit was tested first and regressed the 4-thread HF workload by roughly 27%; thin LTO was selected based on the multithreaded result.

Verification

  • cargo fmt --all -- --check
  • cargo clippy --workspace --all-targets --all-features -- -D warnings
  • Baseline and optimized cargo build --release --locked builds
  • Baseline and optimized cargo build --release --bench mp2_timings --features bench-support --locked builds
  • Identical HF JSON outputs; the MP2 benchmark's dense/blocked energy assertions pass
  • RUSTIQ_MP2_SIZES=80 RUSTIQ_MP2_MEMORY=1GB RAYON_NUM_THREADS=4 for the MP2 comparison

The full Cargo test suite was not run to completion; validation focused on execution time as requested.

@mveril
mveril merged commit 9a6f229 into main Sep 18, 2026
8 checks passed
@mveril
mveril deleted the perf/optimize-release-profiles branch September 18, 2026 11:37
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