Remove itertools dependency from rustc_ast_pretty - #160333
Conversation
|
These commits modify the If this was unintentional then you should revert the changes before this PR is merged. |
|
Personally I don't think the difference looks good, it screams "hey, itertools has something for this", someone will do it, and then we're right back where we started.
Can you clarify what exactly is measured here? This is totally different from what I'm seeing. For reference, this is what my build timings look like:
Furthermore itertools is used later (rustc_trait_selection and rustc_passes are up next, iirc) so it's not like it is dropped completely. |
There was a problem hiding this comment.
r? me
As per ^ the "optimization" argument doesn't make much sense to me, can you clarify? Maybe there's something I'm missing or misunderstanding.
That said I also think the case for using itertools here is weak, so happy to drop it regardless.
@bors r+ rollup
|
Yeah, I am also not convinced by the build-time argument, but I think these particular uses of itertools are net-negative for clarity anyway, and being able to remove itertools from this crate is a nice bonus. |
…uwer Rollup of 12 pull requests Successful merges: - #157572 (stabilize size_of_val_raw, align_of_val_raw, Layout::for_value_raw) - #160012 (miri: ensure validity of references and pointers we dereference and cast) - #160294 (Update Enzyme to resolve one of the open bugs) - #159503 (allocations: document that they can be read-only) - #160179 (std: Update `wasip3` crate dependency) - #160250 (When issuing suggestions for missing trait items, label unstable items) - #160251 (Replace unsafe usage of `NonNull::new_unchecked` with `Box::into_non_null`) - #160311 (Remove final use of sealed traits from stdlib) - #160313 (Make the noundef-on-Cast size guard explicit) - #160323 (Box::leak: tell people to avoid unleaking) - #160328 (Move `check_track_caller` into the attribute parser) - #160333 (Remove itertools dependency from `rustc_ast_pretty`)
The time measurement is just by doing cargo depgraph --focus itertools > graph-itertools.dot
git switch reduce-deps
cargo depgraph --focus itertools > graph-itertools-reduced.dotComparing the So, the list of crates that exhibit performance improvements when built individually can be extracted from that graph:
|
|
That doesn't justify the "I shaved 3 seconds off compilation time" rhetoric.
So this is just the improvement of not building But even making For the sake of argument, say they're working on Anyway, I'd be interested to see your timing graphs with and without this change. For reference, this is mine: https://github.com/user-attachments/files/30619595/cargo-timing-clean%2Brustc_ast_pretty.html (as you can see, for my particular system, itertools is not bottlenecking anything and sits idle for ~10 seconds before actually being needed, so probably even this change on this particular benchmark does little for me) |
This is an improvement if they work on This also applies to other scenarios where a lot of things change at the same time, like changing Git branches or modifying Here are my timings: timings-clean+x_b_rustc_ast_pretty.html
If you don't think that the optimization has merit, I can agree. At the end of the day it was me trying out if I could find something cool with some metadata analysis of the compiler. |
Rollup merge of #160333 - blyxyas:reduce-deps, r=mejrs Remove itertools dependency from `rustc_ast_pretty` 3 Second optimization in the `rustc_ast_pretty` module compiletimes (13.57s -> 10.58s)! Not much, but it's honest work :) Found by an experiment I'm doing, related with Incremental Systems Rethought project goal. So, cc rust-lang/goals#641 r? @jackh726
|
Even if the build time argument is weak, this still means that the full build will use slightly less resources overall because at least one less crate will have to load and process We have the result from a rollup, which seems mildly positive on boostrap but below noise treshold and sadly there's a massive regression from other PR in that rollup. But the queue is empty and we have unrolled build, so we can check the effect on boostrap in isolation, I'm curious: @rust-timer build a0632a7 |
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (a0632a7): comparison URL. Overall result: no relevant changes - no action neededBenchmarking means the PR may be perf-sensitive. Consider adding rollup=never if this change is not fit for rolling up. @rustbot label: -S-waiting-on-perf -perf-regression Instruction countThis perf run didn't have relevant results for this metric. Max RSS (memory usage)Results (primary 1.2%, secondary 0.5%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary 0.7%, secondary 0.5%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeThis perf run didn't have relevant results for this metric. Bootstrap: 490.834s -> 497.836s (1.43%) |
|
Nice. We hit the infamous 7s noise spike on bootstrap, so this run also doesn't tell us much 😄 But |
…uwer Rollup of 12 pull requests Successful merges: - rust-lang/rust#157572 (stabilize size_of_val_raw, align_of_val_raw, Layout::for_value_raw) - rust-lang/rust#160012 (miri: ensure validity of references and pointers we dereference and cast) - rust-lang/rust#160294 (Update Enzyme to resolve one of the open bugs) - rust-lang/rust#159503 (allocations: document that they can be read-only) - rust-lang/rust#160179 (std: Update `wasip3` crate dependency) - rust-lang/rust#160250 (When issuing suggestions for missing trait items, label unstable items) - rust-lang/rust#160251 (Replace unsafe usage of `NonNull::new_unchecked` with `Box::into_non_null`) - rust-lang/rust#160311 (Remove final use of sealed traits from stdlib) - rust-lang/rust#160313 (Make the noundef-on-Cast size guard explicit) - rust-lang/rust#160323 (Box::leak: tell people to avoid unleaking) - rust-lang/rust#160328 (Move `check_track_caller` into the attribute parser) - rust-lang/rust#160333 (Remove itertools dependency from `rustc_ast_pretty`)
3 Second optimization in the
rustc_ast_prettymodule compiletimes (13.57s -> 10.58s)! Not much, but it's honest work :)Found by an experiment I'm doing, related with Incremental Systems Rethought project goal.
So, cc rust-lang/goals#641
r? @jackh726