Repository navigation
tests: type-erase hash_batch consumer under cfg(test) (-76% test compile time, -79% peak RSS) - #322
Merged
Merged
Conversation
…ed_cell bloat Every test that calls hash_batch() passed its own unique closure type, causing rustc to monomorphize all Algorithm::ALL x UseCase::ALL timed_cell<A, U, Closure> instances once per test closure (14 distinct consumers = 2,455 timed_cell symbols, 5.41 MB of .text, 54.6 MB test binary). Under fat LTO + codegen-units=1 + line-tables-only, that drove peak rustc RSS to 7.33 GiB—exceeding the 7 GiB RAM of GitHub-hosted macos-latest runners and pushing cargo nextest run --release into heavy swap thrashing (17-55 min per run). Keep production hash_batch() completely unchanged under cfg(not(test)) so benchmark binaries keep direct monomorphized use_digest calls, and erase the consumer to &mut dyn FnMut(&[u8]) under cfg(test) inside hash_batch() itself so every current and future test shares one set of 210 timed_cell symbols: - Local x86-64 release test build: 198.9s -> 46.9s (-76.4% faster) - Peak rustc RSS: 7.33 GiB -> 1.51 GiB (-79.4%) - timed_cell symbols in test binary: 2,455 (5.41 MB) -> 210 (0.42 MB) - Test binary size: 54.6 MB -> 27.1 MB - cargo nextest run --release --workspace --locked: 246/246 passed
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.
Follow-up root-cause fix for the hosted
macos-latestcargo nextest run --releasecompile blowup seen onnext(5b4c6d08, cancelled at 40 min) and #321 (46856012371, took 55m 49s).Root cause
hash_batch()was generic overconsume: impl FnMut(&[u8]). Production calls it from one site (use_digest), producing 210timed_cellsymbols (0.41 MB,1.24 GiBpeak RSS). Thirteen unit tests each passed a distinct closure type intohash_batch(), monomorphizing allAlgorithm::ALL × UseCase::ALLtimed_cellinstances 14 times over (2,455timed_cellsymbols, 5.41 MB = 52.9% of.text, 54.6 MB test binary). Under[profile.release](lto = "fat",codegen-units = 1), peakrustcRSS hit 7.33 GiB—exceeding GitHub-hostedmacos-latestRAM and causing severe swap thrashing.Fix
Keep
hash_batch()unchanged under#[cfg(not(test))](zero change to production benchmark binaries ortimed_cellinlining ofuse_digest), and type-eraseconsumeto&mut dyn FnMut(&[u8])inside#[cfg(test)] fn hash_batch()so all current and future test callers share onetimed_cellmonomorphization.Measured impact (
CARGO_PROFILE_RELEASE_DEBUG=line-tables-only cargo test --release --no-run --locked)rustcRSStimed_cellsymbols in test binarycargo nextest run --release --workspace --lockedNext move: devonjonte (watch CI including
macos-latest, then merge tonext).