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

rustc_span: Optimize span parent get/set methods #126544

Merged
merged 1 commit into from
Jun 21, 2024

Conversation

petrochenkov
Copy link
Contributor

Like #125017, but for span parents.

r? @cjgillot

@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 Jun 16, 2024
@petrochenkov
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 16, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Jun 16, 2024
rustc_span: Optimize span parent get/set methods

Like rust-lang#125017, but for span parents.

r? `@cjgillot`
@bors
Copy link
Contributor

bors commented Jun 16, 2024

⌛ Trying commit 90b72b5 with merge eab5a5b...

@bors
Copy link
Contributor

bors commented Jun 16, 2024

☀️ Try build successful - checks-actions
Build commit: eab5a5b (eab5a5bd74528e95727f5e553f1d0fe06bcac85e)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (eab5a5b): 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)
0.3% [0.3%, 0.3%] 2
Regressions ❌
(secondary)
0.3% [0.2%, 0.4%] 8
Improvements ✅
(primary)
-0.3% [-0.4%, -0.2%] 6
Improvements ✅
(secondary)
-2.0% [-2.0%, -2.0%] 1
All ❌✅ (primary) -0.1% [-0.4%, 0.3%] 8

Max RSS (memory usage)

Results (primary -2.6%)

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

Cycles

Results (primary 2.0%)

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

Binary size

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

Bootstrap: 672.776s -> 671.266s (-0.22%)
Artifact size: 319.83 MiB -> 320.50 MiB (0.21%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Jun 16, 2024
@petrochenkov
Copy link
Contributor Author

Statistics (similar to #125017 (comment)).

// from standard library
// apparently incremental is not enabled for stdlib despite `rust.incremental = true` in the config
91546 inline_ctxt: None -> None
   41 partially_interned: None -> None

// from ui test suite
// incremental is typically disabled
364420 inline_ctxt: None -> None
  3957 inline_ctxt: None -> Some
   188 inline_parent: Some -> Some
    93 partially_interned: Some -> Some
    13 partially_interned: None -> None
    11 inline_parent: Some -> None
     2 partially_interned: Some -> None

// from incremental test suite
107656 inline_ctxt: None -> Some
  8983 inline_ctxt: None -> None
  3642 inline_parent: Some -> Some
  2789 partially_interned: Some -> Some
    90 partially_interned: Some -> None
    42 inline_parent: Some -> None
     5 partially_interned: None -> Some

@petrochenkov
Copy link
Contributor Author

petrochenkov commented Jun 17, 2024

The main conclusion from the statistics here and in #125017 (comment) is that we don't get much perf improvements from avoiding the interner (partially_interned cases are rare).

We instead get the improvements from avoiding the span.data() -> Span::new() arithmetic in the most common inline_ctxt cases, which don't involve accessing the interner at all.

So it's likely that we can optimize just inline_ctxt: zero|small -> zero|small for ctxt updates, and inline_ctxt: None -> None|Some for parent updates, and everything else can just go through the fallback logic to avoid blowing up code size.
Upd: benchmarked in #126591.
Upd2: the benchmarks in #126591 confirm the hypothesis.

bors added a commit to rust-lang-ci/rust that referenced this pull request Jun 17, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Jun 17, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Jun 18, 2024
@petrochenkov
Copy link
Contributor Author

Updated in accordance with #126544 (comment).
I also added some comment updates for map_ctxt missing from the accidentally merged #126591.
The questions about dependency tracking are still relevant though.

@petrochenkov petrochenkov force-pushed the upparent branch 2 times, most recently from c06b68d to a6c7958 Compare June 18, 2024 15:34
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Jun 19, 2024
@cjgillot
Copy link
Contributor

r=me with the points about tracking resolved.

@petrochenkov
Copy link
Contributor Author

@bors r=cjgillot

@bors
Copy link
Contributor

bors commented Jun 20, 2024

📌 Commit 4d3b617 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 Jun 20, 2024
@bors
Copy link
Contributor

bors commented Jun 20, 2024

⌛ Testing commit 4d3b617 with merge a9c8887...

@bors
Copy link
Contributor

bors commented Jun 21, 2024

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

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jun 21, 2024
@bors bors merged commit a9c8887 into rust-lang:master Jun 21, 2024
7 checks passed
@rustbot rustbot added this to the 1.81.0 milestone Jun 21, 2024
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (a9c8887): comparison URL.

Overall result: ❌ regressions - 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.7% [0.6%, 0.8%] 4
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Max RSS (memory usage)

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

Cycles

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

Binary size

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

Bootstrap: 700.231s -> 701.948s (0.25%)
Artifact size: 324.89 MiB -> 325.02 MiB (0.04%)

@rustbot rustbot removed the perf-regression Performance regression. label Jun 21, 2024
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.

5 participants