Skip to content
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

Unify SourceFile::name_hash and StableSourceFileId #119139

Merged

Conversation

michaelwoerister
Copy link
Member

This PR adapts the existing StableSourceFileId type so that it can be used instead of the name_hash field of SourceFile. This simplifies a few things that were kind of duplicated before.

The PR should also fix issues #112700 and #115835, but I was not able to reproduce these issues in a regression test. As far as I can tell, the root cause of these issues is that the id of the originating crate is not hashed in the HashStable impl of Span and thus cache entries that should have been considered invalidated were loaded. After this PR, the stable_id field of SourceFile includes information about the originating crate, so that ICE should not occur anymore.

@rustbot
Copy link
Collaborator

rustbot commented Dec 19, 2023

r? @davidtwco

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) 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 Dec 19, 2023
@michaelwoerister
Copy link
Member Author

@bors try @rust-timer queue

The changes here cause more SourceFiles to be cloned during crate metadata generation. Let's see if this has an impact on performance.

@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 Dec 19, 2023
@bors
Copy link
Contributor

bors commented Dec 19, 2023

⌛ Trying commit fa8ef25 with merge 1b4168c...

bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 19, 2023
…ce-file-id, r=<try>

Unify SourceFile::name_hash and StableSourceFileId

This PR adapts the existing `StableSourceFileId` type so that it can be used instead of the `name_hash` field of `SourceFile`. This simplifies a few things that were kind of duplicated before.

The PR should also fix issues rust-lang#112700 and rust-lang#115835, but I was not able to reproduce these issues in a regression test. As far as I can tell, the root cause of these issues is that the id of the originating crate is not hashed in the `HashStable` impl of `Span` and thus cache entries that should have been considered invalidated were loaded. After this PR, the `stable_id` field of `SourceFile` includes information about the originating crate, so that ICE should not occur anymore.
@bors
Copy link
Contributor

bors commented Dec 19, 2023

☀️ Try build successful - checks-actions
Build commit: 1b4168c (1b4168c7abb8e0170307e77560ff396321dce94d)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (1b4168c): comparison URL.

Overall result: ❌✅ regressions and improvements - 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.

Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @rustbot label: +perf-regression-triaged along with sufficient written justification. If you cannot justify the regressions please fix the regressions and do another perf run. If the next run shows neutral or positive results, the label will be automatically removed.

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

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
1.2% [1.2%, 1.2%] 1
Regressions ❌
(secondary)
0.2% [0.2%, 0.2%] 1
Improvements ✅
(primary)
-0.2% [-0.3%, -0.1%] 4
Improvements ✅
(secondary)
-1.0% [-1.0%, -1.0%] 1
All ❌✅ (primary) 0.1% [-0.3%, 1.2%] 5

Max RSS (memory usage)

Results

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.8% [0.7%, 0.8%] 2
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.7% [-0.8%, -0.5%] 2
Improvements ✅
(secondary)
-3.7% [-4.2%, -3.1%] 3
All ❌✅ (primary) 0.0% [-0.8%, 0.8%] 4

Cycles

Results

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.4% [-0.4%, -0.4%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.4% [-0.4%, -0.4%] 1

Binary size

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

Bootstrap: 671.988s -> 671.084s (-0.13%)
Artifact size: 312.43 MiB -> 312.49 MiB (0.02%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Dec 20, 2023
@michaelwoerister
Copy link
Member Author

I don't think the unicode-normalization-0.1.19 | opt | full regression is real. The only thing that could be slower due to this PR is exporting SourceFiles to crate metadata, and that should be the same for all build kinds (check, debug, opt / incr. and non-incr.). All the other instances of unicode-normalization-0.1.19 show an improvement.

I'm going to tag this as:
@rustbot label: +perf-regression-triaged

but cc @rust-lang/wg-compiler-performance, just in case

@rustbot rustbot added the perf-regression-triaged The performance regression has been triaged. label Dec 20, 2023
@lqd
Copy link
Member

lqd commented Dec 20, 2023

I don't think the unicode-normalization-0.1.19 | opt | full regression is real.

agreed (and so does cachegrind)

@cjgillot
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Dec 24, 2023

📌 Commit fa8ef25 has been approved by cjgillot

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 Dec 24, 2023
@bors
Copy link
Contributor

bors commented Dec 24, 2023

⌛ Testing commit fa8ef25 with merge bf8716f...

@bors
Copy link
Contributor

bors commented Dec 24, 2023

☀️ Test successful - checks-actions
Approved by: cjgillot
Pushing bf8716f to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Dec 24, 2023
@bors bors merged commit bf8716f into rust-lang:master Dec 24, 2023
12 checks passed
@rustbot rustbot added this to the 1.77.0 milestone Dec 24, 2023
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (bf8716f): comparison URL.

Overall result: ✅ improvements - no action needed

@rustbot label: -perf-regression

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.2% [-0.2%, -0.1%] 3
Improvements ✅
(secondary)
-0.8% [-0.9%, -0.6%] 3
All ❌✅ (primary) -0.2% [-0.2%, -0.1%] 3

Max RSS (memory usage)

Results

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.6% [1.6%, 1.6%] 1
Improvements ✅
(primary)
-0.6% [-0.6%, -0.6%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.6% [-0.6%, -0.6%] 1

Cycles

Results

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)
3.3% [3.3%, 3.3%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 3.3% [3.3%, 3.3%] 1

Binary size

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

Bootstrap: 669.342s -> 669.392s (0.01%)
Artifact size: 312.60 MiB -> 312.50 MiB (-0.03%)

@rustbot rustbot removed the perf-regression Performance regression. label Dec 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) merged-by-bors This PR was explicitly merged by bors. perf-regression-triaged The performance regression has been triaged. 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