Skip to content

Conversation

@JonathanBrouwer
Copy link
Contributor

@JonathanBrouwer JonathanBrouwer commented Dec 31, 2025

Hashes spans relatively to their parent, even if they are not contained inside their parent.

Fixes #150400

Closes #143882, as this is a successor PR
This PR is very closely based on that PR with a few minor changes, so to give proper credit I made @cjgillot coauthor of the commit.

@rustbot rustbot added A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Dec 31, 2025
@JonathanBrouwer
Copy link
Contributor Author

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

rust-bors bot added a commit that referenced this pull request Dec 31, 2025
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Dec 31, 2025
@rust-log-analyzer

This comment has been minimized.

@JonathanBrouwer
Copy link
Contributor Author

@bors try cancel

@rust-bors
Copy link
Contributor

rust-bors bot commented Dec 31, 2025

Try build cancelled. Cancelled workflows:

@JonathanBrouwer

This comment was marked as outdated.

@rust-bors

This comment has been minimized.

rust-bors bot added a commit that referenced this pull request Dec 31, 2025
@rust-bors

This comment was marked as outdated.

@rust-timer

This comment has been minimized.

@rust-timer

This comment was marked as outdated.

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Dec 31, 2025
@JonathanBrouwer
Copy link
Contributor Author

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

rust-bors bot added a commit that referenced this pull request Jan 1, 2026
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jan 1, 2026
@rust-bors
Copy link
Contributor

rust-bors bot commented Jan 1, 2026

☀️ Try build successful (CI)
Build commit: 5702844 (570284477cc4354ae13d7effa889ba163bdab31f, parent: cc08b553b899821331ddbfb970e243a7dd0957a3)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (5702844): 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.

mean range count
Regressions ❌
(primary)
0.2% [0.1%, 0.4%] 9
Regressions ❌
(secondary)
0.4% [0.0%, 0.7%] 19
Improvements ✅
(primary)
-1.6% [-6.5%, -0.1%] 13
Improvements ✅
(secondary)
-0.3% [-0.4%, -0.1%] 6
All ❌✅ (primary) -0.8% [-6.5%, 0.4%] 22

Max RSS (memory usage)

Results (primary -0.1%)

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

mean range count
Regressions ❌
(primary)
1.4% [1.4%, 1.4%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.9% [-0.9%, -0.9%] 2
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.1% [-0.9%, 1.4%] 3

Cycles

Results (primary 4.7%, secondary 18.3%)

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

mean range count
Regressions ❌
(primary)
8.9% [3.4%, 13.1%] 9
Regressions ❌
(secondary)
20.6% [11.9%, 32.3%] 10
Improvements ✅
(primary)
-4.8% [-6.4%, -1.7%] 4
Improvements ✅
(secondary)
-3.8% [-3.8%, -3.8%] 1
All ❌✅ (primary) 4.7% [-6.4%, 13.1%] 13

Binary size

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

Bootstrap: 475.256s -> 475.638s (0.08%)
Artifact size: 390.83 MiB -> 390.83 MiB (0.00%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jan 1, 2026
@JonathanBrouwer
Copy link
Contributor Author

JonathanBrouwer commented Jan 1, 2026

That's a funny race condition in rustbot, fixed it manually :)

@Kobzol
Copy link
Member

Kobzol commented Jan 2, 2026

@bors try @rust-timer queue

The cycle results looked quite weird, rerunning to see if it was noise or not.

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

rust-bors bot added a commit that referenced this pull request Jan 2, 2026
Also hash spans inside the same file as relative (V2)
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jan 2, 2026
@rust-bors
Copy link
Contributor

rust-bors bot commented Jan 2, 2026

☀️ Try build successful (CI)
Build commit: 5b25251 (5b25251e673dbd33683e6317e1a307bbc1b74e30, parent: 8a24a202aa02f677fc2a3e0e1a69af7545803952)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (5b25251): 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.

mean range count
Regressions ❌
(primary)
0.2% [0.1%, 0.4%] 14
Regressions ❌
(secondary)
0.4% [0.1%, 0.7%] 16
Improvements ✅
(primary)
-1.6% [-6.5%, -0.2%] 13
Improvements ✅
(secondary)
-0.2% [-0.4%, -0.1%] 12
All ❌✅ (primary) -0.7% [-6.5%, 0.4%] 27

Max RSS (memory usage)

Results (secondary -3.9%)

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)
-3.9% [-6.3%, -2.1%] 5
All ❌✅ (primary) - - 0

Cycles

Results (primary -4.9%, secondary 5.2%)

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)
5.2% [5.2%, 5.2%] 1
Improvements ✅
(primary)
-4.9% [-5.2%, -4.5%] 3
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -4.9% [-5.2%, -4.5%] 3

Binary size

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

Bootstrap: 473.485s -> 472.607s (-0.19%)
Artifact size: 390.77 MiB -> 390.79 MiB (0.01%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jan 2, 2026
@JonathanBrouwer
Copy link
Contributor Author

The cycles look better this time I think, so was spurious :)

@cjgillot
Copy link
Contributor

cjgillot commented Jan 7, 2026

This PR is very closely based on that PR with a few minor changes, so to give proper credit I made @cjgillot coauthor of the commit.

Do you mind explaining what are those minor changes?
Thank you for the co-author courtesy :)

Co-authored-by: Camille Gillot <gillot.camille@gmail.com>
Copy link
Contributor Author

@JonathanBrouwer JonathanBrouwer left a comment

Choose a reason for hiding this comment

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

@cjgillot Yes ofc, should've explained the changes, sorry :)
Explained the changes in some comments on the code

View changes since this review

if let Some(parent) = parent
&& file_lo.contains(parent.lo)
{
TAG_RELATIVE_SPAN.encode(self);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Your PR introduces a new TAG_RELATIVE_OUTER_SPAN tag here for encoding spans which are outside their parent span, this PR instead reuses the TAG_RELATIVE_SPAN tag. This can be done by encoding the positions in the span (which are u32s) subtracted from their parent, wrapping if necessary. This change seems to be most of the performance gained relative to your PR.

// This span is relative to another span in the same file,
// only hash the relative position.
Hash::hash(&TAG_RELATIVE_SPAN, hasher);
Hash::hash(&(span.lo.0.wrapping_sub(parent.lo.0)), hasher);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

When hashing, your PR hashes an isize here, this PR instead hashes a u32 by using a wrapping_sub. Haven't explored if this makes any perf difference


Hash::hash(&TAG_VALID_SPAN, hasher);
Hash::hash(&file, hasher);
Hash::hash(&file.stable_id, hasher);
Copy link
Contributor Author

@JonathanBrouwer JonathanBrouwer Jan 8, 2026

Choose a reason for hiding this comment

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

Your PR hashed the TAG_VALID_SPAN and stable_id if file.contains(parent.lo), this PR doesn't. Again, Haven't explored if this makes any perf difference

@cjgillot
Copy link
Contributor

Great! I agree, we did not need to make much more of a difference in hashing and encoding between the "contained in parent span" and the "in same file" cases.

@bors r+ rollup=never

@rust-bors rust-bors bot added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Jan 10, 2026
@rust-bors
Copy link
Contributor

rust-bors bot commented Jan 10, 2026

📌 Commit dc505a5 has been approved by cjgillot

It is now in the queue for this repository.

@rust-bors rust-bors bot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 10, 2026
@Zalathar
Copy link
Member

Scheduling: Encourage a mixture of rollup and non-rollup PRs.

@bors p=5

@rust-bors

This comment has been minimized.

@rust-bors rust-bors bot added the merged-by-bors This PR was explicitly merged by bors. label Jan 11, 2026
@rust-bors
Copy link
Contributor

rust-bors bot commented Jan 11, 2026

☀️ Test successful - CI
Approved by: cjgillot
Pushing 08f833a to main...

@rust-bors rust-bors bot merged commit 08f833a into rust-lang:main Jan 11, 2026
12 checks passed
@rustbot rustbot added this to the 1.94.0 milestone Jan 11, 2026
@github-actions
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 9bc8b40 (parent) -> 08f833a (this PR)

Test differences

Show 3 test diffs

3 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 08f833aa179952037d5d0c5d949d4c3ec18ec212 --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. aarch64-apple: 10551.8s -> 8759.5s (-17.0%)
  2. x86_64-gnu-llvm-20-2: 5055.0s -> 5900.1s (+16.7%)
  3. x86_64-gnu-tools: 3274.3s -> 3777.4s (+15.4%)
  4. pr-check-1: 1687.3s -> 1937.2s (+14.8%)
  5. x86_64-gnu-gcc: 3291.1s -> 3775.8s (+14.7%)
  6. x86_64-rust-for-linux: 2770.2s -> 3176.5s (+14.7%)
  7. aarch64-gnu-llvm-20-2: 2769.2s -> 3151.9s (+13.8%)
  8. arm-android: 5733.4s -> 6513.6s (+13.6%)
  9. pr-check-2: 2356.1s -> 2637.1s (+11.9%)
  10. aarch64-gnu-debug: 3868.3s -> 4309.3s (+11.4%)
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 (08f833a): comparison URL.

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

Our benchmarks found a performance regression caused by this PR.
This might be an actual regression, but it can also be just noise.

Next Steps:

  • If the regression was expected or you think it can be justified,
    please write a comment with sufficient written justification, and add
    @rustbot label: +perf-regression-triaged to it, to mark the regression as triaged.
  • If you think that you know of a way to resolve the regression, try to create
    a new PR with a fix for the regression.
  • If you do not understand the regression or you think that it is just noise,
    you can ask the @rust-lang/wg-compiler-performance working group for help (members of this group
    were already notified of this PR).

@rustbot label: +perf-regression
cc @rust-lang/wg-compiler-performance

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.3% [0.1%, 0.4%] 6
Regressions ❌
(secondary)
0.3% [0.1%, 0.7%] 27
Improvements ✅
(primary)
-1.2% [-6.5%, -0.2%] 20
Improvements ✅
(secondary)
-0.3% [-0.5%, -0.2%] 8
All ❌✅ (primary) -0.9% [-6.5%, 0.4%] 26

Max RSS (memory usage)

Results (secondary -2.4%)

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

Cycles

Results (primary -3.2%, 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)
2.6% [2.6%, 2.6%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-5.1% [-5.8%, -3.9%] 3
Improvements ✅
(secondary)
-2.1% [-2.1%, -2.1%] 1
All ❌✅ (primary) -3.2% [-5.8%, 2.6%] 4

Binary size

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

Bootstrap: 473.122s -> 474.227s (0.23%)
Artifact size: 391.33 MiB -> 391.32 MiB (-0.00%)

@JonathanBrouwer
Copy link
Contributor Author

@rustbot label: +perf-regression-triaged
Matches the expected performance, net positive

@rustbot rustbot added the perf-regression-triaged The performance regression has been triaged. label Jan 11, 2026
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 Performance regression. 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.

Outer attribute spans on items are never lowered correctly

8 participants