Mono item collection microoptimizations - #162480
Conversation
|
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Mono item collection microoptimizations
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (bfad934): comparison URL. Overall result: ❌✅ regressions and improvements - please read:Benchmarking means the PR may be perf-sensitive. It's automatically marked not fit for rolling up. Overriding is possible but disadvised: it risks changing compiler perf. Next, please: If you can, justify the regressions found in this try perf run in writing along with @bors rollup=never rustc-perf Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary 0.5%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary 0.2%, secondary -3.4%)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: 478.441s -> 477.072s (-0.29%) |
|
If you open the non-relevant results, it is very slightly green across the board, but the effect is very small. Anyway, I'll let the reviewer judge whether this is worth it or not :) |
|
rustbot has assigned @petrochenkov. Use Why was this reviewer chosen?The reviewer was selected based on:
|
| def_path_str, | ||
| }); | ||
| }; | ||
| used_items.reserve(used.len()); |
There was a problem hiding this comment.
Instead of reserving outside of the extend call which is easily forgotten, how about this implementation:
#162495
| // from multiple root items within a CGU, which is fine, it just means | ||
| // the `insert` will be a no-op. | ||
| for inlined_item in reachable_inlined_items { | ||
| for inlined_item in &reachable_inlined_items { |
There was a problem hiding this comment.
An alternative which might be slightly nicer as it doesn't need a copy:
reachable_inlined_items.drain(..)
and remove the .clear() above
The current implementation is also fine by me tho, if you prefer it. I think both of our options should be identical for performance
There was a problem hiding this comment.
I think that iter + clear is generally faster than drain, because the implementation of drain tends to be complicated.
|
Closing in favor of #162495. |
|
That pr only replaces one of the two commits from this PR tho |
…d, r=Kobzol Reserve items in `Extend` implementations This might be a perf win, inspired by @Kobzol's approach in this PR: rust-lang#162480
|
Yeah, but the perf. effect was essentially zero, so I didn't consider it to be worth it. |
Found this while staring at the mono item collection code. I kinda doubt it will even show up on our benchmarks, but it seems like a reasonable improvement nonetheless.