Skip to content

Reserve HashSet capacity before inserting cfgs/check-cfgs #137069

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

Urgau
Copy link
Member

@Urgau Urgau commented Feb 15, 2025

This PR reserve capacity before inserting cfgs/check-cfgs into their different hashsets.

Related to #137005, mostly an experiment, but even if perf is neutral it still a good practice.

@rustbot
Copy link
Collaborator

rustbot commented Feb 15, 2025

r? @nnethercote

rustbot has assigned @nnethercote.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Feb 15, 2025
@Urgau
Copy link
Member Author

Urgau commented Feb 15, 2025

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Feb 15, 2025
@bors
Copy link
Collaborator

bors commented Feb 15, 2025

⌛ Trying commit 5a01c94 with merge 8c9c6b3...

bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 15, 2025
Reserve `HashSet` capacity before inserting cfgs/check-cfgs

This PR tries to reserve capacity before inserting cfgs/check-cfgs into their hashset.

Related to rust-lang#137005, mostly an experiment, but even if perf is neutral it still a good practice.
@bors
Copy link
Collaborator

bors commented Feb 15, 2025

☀️ Try build successful - checks-actions
Build commit: 8c9c6b3 (8c9c6b31e6fac10dd47adacbb9a3398f8f19bd36)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (8c9c6b3): comparison URL.

Overall result: ❌✅ regressions and improvements - no action needed

Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf.

@bors rollup=never
@rustbot label: -S-waiting-on-perf -perf-regression

Instruction count

This is the most reliable metric that we have; it was used to determine the overall result at the top of this comment. However, even this metric can sometimes exhibit noise.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
0.3% [0.2%, 0.4%] 4
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.2% [-0.2%, -0.2%] 2
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results (secondary -2.9%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.9% [-2.9%, -2.9%] 1
All ❌✅ (primary) - - 0

Cycles

Results (secondary -7.3%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
1.7% [1.7%, 1.7%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-8.8% [-9.1%, -8.5%] 6
All ❌✅ (primary) - - 0

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 788.977s -> 789.944s (0.12%)
Artifact size: 347.33 MiB -> 347.33 MiB (-0.00%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Feb 15, 2025
@nnethercote
Copy link
Contributor

even if perf is neutral it still a good practice.

I've gotta be honest: I totally disagree with this, and I don't like this approach at all. The comments mention that there are a few dozen cfgs. Resizing those hashmaps is going to be utterly negligible, time-wise. Only the very largest hashmaps, with 10s or 100s of thousands of entries, maybe millions, are going to be worth pre-sizing. It's additional code and comments for zero benefit.

Sorry, I'm going to nip this one in the bud, and comment on #137005.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants