Skip to content

Only inherit local hash for paths #142903

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

Merged
merged 3 commits into from
Jul 17, 2025
Merged

Conversation

cjgillot
Copy link
Contributor

@cjgillot cjgillot commented Jun 23, 2025

DefPathHash, as the counterpart of DefId that is stable across compiler invocations, is comprised of 2 parts. The first one is the StableCrateId, stable form of CrateNum. The second is 64 complementary bits to identify the crate-local definition.

The current implementation always hashes the full 128 bits when (1) trying to create a new child DefPathHash or (2) hashing a CrateNum or a LocalDefId. But we only need half that information: LocalDefId means that the StableCrateId is always the current crate's ; CrateNum means that we do not care about the local part.

As stable hashing is very hot in the query system, in particular hashing definitions, this is a big deal.

We still want the local part to change when the StableCrateId changes, to make incr-compilation errors less painful, ie. increase the likelihood that if will magically disappear by changing some code.

This PR sprinkles some #[inline] attributes on small functions that appeared in profiles.

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Jun 23, 2025
@cjgillot
Copy link
Contributor Author

@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 Jun 23, 2025
bors added a commit that referenced this pull request Jun 23, 2025
Only inherit local hash for paths

r? `@ghost`
@bors
Copy link
Collaborator

bors commented Jun 23, 2025

⌛ Trying commit 1b4a19d with merge 6e20539...

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Collaborator

bors commented Jun 23, 2025

☀️ Try build successful - checks-actions
Build commit: 6e20539 (6e20539f56d631fb16fbe744f76d3de64b76e278)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (6e20539): comparison URL.

Overall result: ✅ 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.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.4% [-0.9%, -0.2%] 140
Improvements ✅
(secondary)
-0.5% [-1.2%, -0.1%] 80
All ❌✅ (primary) -0.4% [-0.9%, -0.2%] 140

Max RSS (memory usage)

Results (secondary 3.0%)

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

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
3.0% [2.7%, 3.2%] 2
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Cycles

Results (secondary -2.1%)

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

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

Binary size

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

Bootstrap: 688.673s -> 689.15s (0.07%)
Artifact size: 371.94 MiB -> 372.00 MiB (0.02%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jun 23, 2025
@cjgillot cjgillot marked this pull request as ready for review June 24, 2025 04:23
@rustbot
Copy link
Collaborator

rustbot commented Jun 24, 2025

r? @fee1-dead

rustbot has assigned @fee1-dead.
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 the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 24, 2025
@fee1-dead
Copy link
Member

r? compiler

@rustbot rustbot assigned compiler-errors and unassigned fee1-dead Jun 24, 2025
@compiler-errors
Copy link
Member

@bors r+ rollup=never

@bors
Copy link
Collaborator

bors commented Jul 16, 2025

📌 Commit 068f3ac has been approved by compiler-errors

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 16, 2025
@bors
Copy link
Collaborator

bors commented Jul 17, 2025

⌛ Testing commit 068f3ac with merge 8c12d76...

@bors
Copy link
Collaborator

bors commented Jul 17, 2025

☀️ Test successful - checks-actions
Approved by: compiler-errors
Pushing 8c12d76 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jul 17, 2025
@bors bors merged commit 8c12d76 into rust-lang:master Jul 17, 2025
11 checks passed
@rustbot rustbot added this to the 1.90.0 milestone Jul 17, 2025
Copy link
Contributor

What is this? This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.

Comparing f8f6997 (parent) -> 8c12d76 (this PR)

Test differences

Show 2 test diffs

2 doctest diffs were found. These are ignored, as they are noisy.

Test dashboard

Run

cargo run --manifest-path src/ci/citool/Cargo.toml -- \
    test-dashboard 8c12d76304fcceaeaad0d67209e5727e94f5f2b8 --output-dir test-dashboard

And then open test-dashboard/index.html in your browser to see an overview of all executed tests.

Job duration changes

  1. x86_64-apple-1: 7195.6s -> 10214.9s (42.0%)
  2. aarch64-apple: 4085.0s -> 5214.7s (27.7%)
  3. dist-aarch64-apple: 5942.4s -> 5100.5s (-14.2%)
  4. x86_64-gnu-stable: 7269.3s -> 8258.0s (13.6%)
  5. x86_64-apple-2: 6696.5s -> 5787.5s (-13.6%)
  6. dist-x86_64-apple: 10639.1s -> 11615.2s (9.2%)
  7. tidy: 65.8s -> 69.9s (6.3%)
  8. x86_64-gnu-llvm-19-1: 3622.5s -> 3399.8s (-6.1%)
  9. dist-sparcv9-solaris: 4793.3s -> 5068.3s (5.7%)
  10. aarch64-msvc-2: 4654.7s -> 4879.0s (4.8%)
How to interpret the job duration changes?

Job durations can vary a lot, based on the actual runner instance
that executed the job, system noise, invalidated caches, etc. The table above is provided
mostly for t-infra members, for simpler debugging of potential CI slow-downs.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (8c12d76): comparison URL.

Overall result: ✅ improvements - no action needed

@rustbot label: -perf-regression

Instruction count

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

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.4% [-1.0%, -0.2%] 140
Improvements ✅
(secondary)
-0.5% [-1.2%, -0.1%] 105
All ❌✅ (primary) -0.4% [-1.0%, -0.2%] 140

Max RSS (memory usage)

Results (secondary 2.0%)

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

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
4.8% [3.0%, 6.6%] 2
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-3.5% [-3.5%, -3.5%] 1
All ❌✅ (primary) - - 0

Cycles

Results (secondary 2.1%)

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

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

Binary size

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

Bootstrap: 463.571s -> 463.461s (-0.02%)
Artifact size: 374.76 MiB -> 374.76 MiB (-0.00%)

@cjgillot cjgillot deleted the local-def-path-hash branch July 17, 2025 16:49
Muscraft pushed a commit to Muscraft/rust that referenced this pull request Jul 21, 2025
…iler-errors

Only inherit local hash for paths

`DefPathHash`, as the counterpart of `DefId` that is stable across compiler invocations, is comprised of 2 parts. The first one is the `StableCrateId`, stable form of `CrateNum`. The second is 64 complementary bits to identify the crate-local definition.

The current implementation always hashes the full 128 bits when (1) trying to create a new child `DefPathHash` or (2) hashing a `CrateNum` or a `LocalDefId`. But we only need half that information: `LocalDefId` means that the `StableCrateId` is always the current crate's ; `CrateNum` means that we do not care about the local part.

As stable hashing is very hot in the query system, in particular hashing definitions, this is a big deal.

We still want the local part to change when the `StableCrateId` changes, to make incr-compilation errors less painful, ie. increase the likelihood that if will magically disappear by changing some code.

This PR sprinkles some `#[inline]` attributes on small functions that appeared in profiles.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

7 participants