Skip to content

Prehash visibilities in resolver - #143371

Open
cjgillot wants to merge 1 commit into
rust-lang:mainfrom
cjgillot:prehash-visibilities
Open

Prehash visibilities in resolver#143371
cjgillot wants to merge 1 commit into
rust-lang:mainfrom
cjgillot:prehash-visibilities

Conversation

@cjgillot

Copy link
Copy Markdown
Contributor

Based on #143247
r? @ghost for perf

@rustbotrustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Jul 3, 2025
@cjgillot
cjgillotforce-pushed the prehash-visibilities branch from aaaefd1 to 17c75cbCompareJuly 3, 2025 14:06
@petrochenkovpetrochenkov self-assigned this Jul 4, 2025
@petrochenkovpetrochenkov added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Jul 4, 2025
@cjgillot
cjgillotforce-pushed the prehash-visibilities branch from 17c75cb to 11751ceCompareJuly 4, 2025 14:01
@cjgillot

Copy link
Copy Markdown
ContributorAuthor

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbotrustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jul 4, 2025
bors added a commit that referenced this pull request Jul 4, 2025
Prehash visibilities in resolver
Based on #143247
r? `@ghost` for perf
@bors

bors commented Jul 4, 2025

Copy link
Copy Markdown
Collaborator

⌛ Trying commit 11751ce with merge 556648c...

@bors

bors commented Jul 4, 2025

Copy link
Copy Markdown
Collaborator

☀️ Try build successful - checks-actions
Build commit: 556648c (556648c0fadc2403580e32dad35144435e964fcc)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (556648c): comparison URL.

Overall result: ❌✅ regressions and improvements - please read the text below

Benchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf.

Next Steps: If you can justify the regressions found in this try perf run, please do so in sufficient writing along with @rustbot label: +perf-regression-triaged. If not, please fix the regressions and do another perf run. If its results are neutral or positive, the label will be automatically removed.

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

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

meanrangecount
Regressions ❌
(primary)
3.0%[3.0%, 3.0%]1
Regressions ❌
(secondary)
0.4%[0.3%, 0.4%]2
Improvements ✅
(primary)
-0.3%[-0.3%, -0.3%]1
Improvements ✅
(secondary)
--0
All ❌✅ (primary)1.4%[-0.3%, 3.0%]2

Max RSS (memory usage)

Results (primary -1.9%, secondary -2.0%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

meanrangecount
Regressions ❌
(primary)
--0
Regressions ❌
(secondary)
--0
Improvements ✅
(primary)
-1.9%[-2.7%, -1.3%]4
Improvements ✅
(secondary)
-2.0%[-3.3%, -0.5%]4
All ❌✅ (primary)-1.9%[-2.7%, -1.3%]4

Cycles

Results (secondary -0.9%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

meanrangecount
Regressions ❌
(primary)
--0
Regressions ❌
(secondary)
1.0%[1.0%, 1.0%]1
Improvements ✅
(primary)
--0
Improvements ✅
(secondary)
-1.8%[-3.0%, -0.6%]2
All ❌✅ (primary)--0

Binary size

Results (primary 1.1%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

meanrangecount
Regressions ❌
(primary)
1.1%[1.1%, 1.1%]1
Regressions ❌
(secondary)
--0
Improvements ✅
(primary)
--0
Improvements ✅
(secondary)
--0
All ❌✅ (primary)1.1%[1.1%, 1.1%]1

Bootstrap: 461.146s -> 462.46s (0.28%)
Artifact size: 372.20 MiB -> 372.16 MiB (-0.01%)

@rustbotrustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Jul 4, 2025
@cjgillot
cjgillotforce-pushed the prehash-visibilities branch from 11751ce to 2a49c4cCompareJuly 20, 2025 13:26
@petrochenkovpetrochenkov added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 21, 2025
let visibilities_hash = {
let mut hasher = StableHasher::new();
let mut hcx = self.create_stable_hashing_context();
self.visibilities_for_hashing.hash_stable(&mut hcx, &mut hasher);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about doing this operation in fn feed_visibility and keeping only the hash in Resolver instead of the whole visibilities_for_hashing table.

Is creating the hashing context a more or less expensive operation than adding a table element?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Creating a hashing context is very cheap. It's just moving some pointers around. I guess we could keep a StableHasher around, feed it the individual items, and finish into a hash here.

Comment threadcompiler/rustc_middle/src/hir/map.rs
@petrochenkov
petrochenkov marked this pull request as ready for review July 21, 2025 15:07
@petrochenkovpetrochenkov added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 21, 2025
@bors

This comment was marked as resolved.

@cjgillot
cjgillotforce-pushed the prehash-visibilities branch from 2a49c4c to df4ffb9CompareAugust 3, 2025 20:13
@cjgillot

Copy link
Copy Markdown
ContributorAuthor

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors

rust-borsBot commented Aug 3, 2025

Copy link
Copy Markdown
Contributor

⌛ Trying commit df4ffb9 with merge a723f79

To cancel the try build, run the command @bors try cancel.

rust-borsBot added a commit that referenced this pull request Aug 3, 2025
@rustbotrustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Aug 3, 2025
@rust-bors

rust-borsBot commented Aug 3, 2025

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: a723f79 (a723f792ac789ddf0784e86ea790d02add42793b, parent: f34ba774c78ea32b7c40598b8ad23e75cdac42a6)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (a723f79): comparison URL.

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

Benchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf.

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

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

meanrangecount
Regressions ❌
(primary)
--0
Regressions ❌
(secondary)
0.2%[0.1%, 0.3%]4
Improvements ✅
(primary)
--0
Improvements ✅
(secondary)
-0.1%[-0.1%, -0.1%]4
All ❌✅ (primary)--0

Max RSS (memory usage)

Results (primary 0.6%, secondary 2.2%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

meanrangecount
Regressions ❌
(primary)
1.3%[1.1%, 1.5%]2
Regressions ❌
(secondary)
3.8%[2.3%, 5.3%]8
Improvements ✅
(primary)
-0.8%[-0.8%, -0.8%]1
Improvements ✅
(secondary)
-1.9%[-2.7%, -0.6%]3
All ❌✅ (primary)0.6%[-0.8%, 1.5%]3

Cycles

Results (primary -2.7%, secondary -2.2%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

meanrangecount
Regressions ❌
(primary)
--0
Regressions ❌
(secondary)
--0
Improvements ✅
(primary)
-2.7%[-2.7%, -2.6%]2
Improvements ✅
(secondary)
-2.2%[-2.2%, -2.2%]1
All ❌✅ (primary)-2.7%[-2.7%, -2.6%]2

Binary size

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

Bootstrap: 467.629s -> 467.313s (-0.07%)
Artifact size: 376.97 MiB -> 376.93 MiB (-0.01%)

@rustbotrustbot removed S-waiting-on-perf Status: Waiting on a perf run to be completed. perf-regression Performance regression. labels Aug 4, 2025
@cjgillotcjgillot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 5, 2025
@petrochenkov

Copy link
Copy Markdown
Contributor

@cjgillot
Could you answer #143371 (comment)?
r=me otherwise.
@rustbot author

@rustbotrustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 6, 2025
@rustbot

Copy link
Copy Markdown
Collaborator

Reminder, once the PR becomes ready for a review, use @rustbot ready.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-authorStatus: This is awaiting some action (such as code changes or more information) from the author.T-compilerRelevant 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

@cjgillot@rust-timer@bors@petrochenkov@rustbot