Minor changes to improve compilation speed#137
Open
Aeledfyr wants to merge 5 commits intoseanmonstar:masterfrom
Open
Minor changes to improve compilation speed#137Aeledfyr wants to merge 5 commits intoseanmonstar:masterfrom
Aeledfyr wants to merge 5 commits intoseanmonstar:masterfrom
Conversation
Iterator combinators have a noticable compilation time overhead because they must be monomorphized and end up passing more code to LLVM. This code does get optimized out, but that takes time and slows down the overall build.
I'm not sure how much of a compile time impact this makes, but this prevents the compiler from having to generate formatting code when the debug macro is not in use.
The current implementation uses a HashMap to deduplicate the output from each core of the same cpu. This commit instead collects the output for each core in to a Vec, and then sorts it to deduplicate physical CPUs. This reduces the code size processed by LLVM by 15-20%, as counted by `cargo llvm-lines --lib -p num_cpus` on both debug and release. These implementations have different performance characteristics: - the HashMap must hash each key, and SipHash is slow on small keys - the number of cores will be small (<1024) so sorting the list should be very fast - the list will likely already be sorted I have not benchmarked this code, but it should be around the same speed or slightly faster (from testing against randomized lists).
Author
|
Improved benchmarks, only compiling
|
Author
|
It looks like most of the CI failures are due to an updated Rust toolchain:
The only test that actually fails is |
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.
This crate is small and compiles quickly, but it's also used everywhere, so trying to improve the compilation speed is worth it.
This PR has a number of optimizations; each commit is independent, so feel free to cherry-pick and take whichever changes you want. This PR preserves the current MSRV of 1.13.
Changes:
rust-version = "1.13"to theCargo.toml, to partially document the current MSRVAsRef<Path>to just take&Pathdebug!macro generate no code when not in useVecinstead of aHashMapwhen counting physical cores; using theHashMaprequires compiling a lot more code. (TheVecshould also be faster.)My non-scientific benchmarks of a clean build of the library (
libc+num_cpus)Measuring the amount of code passed to LLVM, using cargo-llvm-lines:
cargo llvm-lines --lib -p num_cpus(with--releasefor release builds)