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 syntax context updates in spans #125017

Merged
merged 1 commit into from
Jun 10, 2024

Conversation

petrochenkov
Copy link
Contributor

@petrochenkov petrochenkov commented May 11, 2024

By updating inline contexts in place, without touching span interner, when possible.

@rustbot
Copy link
Collaborator

rustbot commented May 11, 2024

r? @jieyouxu

rustbot has assigned @jieyouxu.
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 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 May 11, 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 May 11, 2024
@petrochenkov petrochenkov 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 May 11, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request May 11, 2024
rustc_span: Optimize syntax context updates in spans

By updating inline contexts in place, without touching span interner, when possible.

TODO: Run benchmarks and cleanup code if the results are good.
@bors
Copy link
Contributor

bors commented May 11, 2024

⌛ Trying commit 05a4539 with merge dcefc53...

@bors
Copy link
Contributor

bors commented May 11, 2024

☀️ Try build successful - checks-actions
Build commit: dcefc53 (dcefc53a1dd4bffbe21f41f1cd334d3770fa9783)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (dcefc53): 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
Regressions ❌
(secondary)
0.3% [0.2%, 0.4%] 2
Improvements ✅
(primary)
-0.4% [-1.8%, -0.2%] 77
Improvements ✅
(secondary)
-1.1% [-9.2%, -0.2%] 31
All ❌✅ (primary) -0.4% [-1.8%, -0.2%] 77

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)
1.4% [1.0%, 1.7%] 3
Regressions ❌
(secondary)
2.7% [2.7%, 2.7%] 1
Improvements ✅
(primary)
-1.2% [-1.5%, -0.9%] 4
Improvements ✅
(secondary)
-4.0% [-4.0%, -4.0%] 1
All ❌✅ (primary) -0.1% [-1.5%, 1.7%] 7

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)
-2.1% [-2.8%, -1.2%] 8
Improvements ✅
(secondary)
-2.3% [-4.8%, -1.3%] 6
All ❌✅ (primary) -2.1% [-2.8%, -1.2%] 8

Binary size

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

Bootstrap: 673.271s -> 673.179s (-0.01%)
Artifact size: 315.86 MiB -> 315.78 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 May 11, 2024
Copy link
Member

@jieyouxu jieyouxu left a comment

Choose a reason for hiding this comment

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

A question regarding the significance of a u32::MAX SyntaxContext, but otherwise looks good to me.

compiler/rustc_span/src/span_encoding.rs Outdated Show resolved Hide resolved
compiler/rustc_span/src/span_encoding.rs Outdated Show resolved Hide resolved
@petrochenkov
Copy link
Contributor Author

I still need to clean up the code and factor out the common part from inline_ctxt and update_ctxt, that's why it's waiting on author.

@petrochenkov
Copy link
Contributor Author

petrochenkov commented May 16, 2024

I've found an issue - the old logic may turn a partially-interned format into an inline-parent format on ctxt update (when ctxt is updated to zero), but the new logic doesn't reproduce that behavior.
It's a bug an not just a missed optimization, because it may result in two different Spans referring to the same SpanData.

UPD: This issue is fixed in the last update.

@rust-log-analyzer

This comment has been minimized.

@petrochenkov
Copy link
Contributor Author

Blocked on #125829.
@rustbot blocked

@rustbot rustbot added S-blocked Status: Marked as blocked ❌ on something else such as an RFC or other implementation work. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels May 31, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request May 31, 2024
rustc_span: Add conveniences for working with span formats

Also
- Centralize span ctxt updates in `Span::update_ctxt`
- Stop requiring inline and interned ctxts in partially interned format to be synchronized.

This is the refactoring part of rust-lang#125017.
bors added a commit to rust-lang-ci/rust that referenced this pull request Jun 1, 2024
rustc_span: Add conveniences for working with span formats

Also
- Centralize span ctxt updates in `Span::update_ctxt`
- Stop requiring inline and interned ctxts in partially interned format to be synchronized.

This is the refactoring part of rust-lang#125017.
bors added a commit to rust-lang-ci/rust that referenced this pull request Jun 2, 2024
rustc_span: Add conveniences for working with span formats

Also
- Centralize span ctxt updates in `Span::update_ctxt`
- Stop requiring inline and interned ctxts in partially interned format to be synchronized.

This is the refactoring part of rust-lang#125017.
@rust-log-analyzer
Copy link
Collaborator

The job aarch64-gnu failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
[401/3315] Building CXX object lib/InterfaceStub/CMakeFiles/LLVMInterfaceStub.dir/IFSHandler.cpp.o
[402/3315] Building CXX object lib/InterfaceStub/CMakeFiles/LLVMInterfaceStub.dir/ELFObjHandler.cpp.o
[403/3315] Building CXX object lib/IR/CMakeFiles/LLVMCore.dir/Verifier.cpp.o

Session terminated, killing shell...::group::Clock drift check
  local time: Mon Jun 10 00:05:31 UTC 2024
##[error]The runner has received a shutdown signal. This can happen when the runner service is stopped, or a manually started runner is canceled.
##[endgroup]
[404/3315] Building CXX object lib/IRPrinter/CMakeFiles/LLVMIRPrinter.dir/IRPrintingPasses.cpp.o
[405/3315] Building CXX object lib/FuzzMutate/CMakeFiles/LLVMFuzzMutate.dir/RandomIRBuilder.cpp.o
[406/3315] Building CXX object lib/IRReader/CMakeFiles/LLVMIRReader.dir/IRReader.cpp.o

@petrochenkov
Copy link
Contributor Author

@bors retry

@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 10, 2024
@bors
Copy link
Contributor

bors commented Jun 10, 2024

⌛ Testing commit d5dd2d8 with merge a316785...

@bors
Copy link
Contributor

bors commented Jun 10, 2024

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

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

Finished benchmarking commit (a316785): comparison URL.

Overall result: ❌✅ regressions and improvements - ACTION NEEDED

Next Steps: If you can justify the regressions found in this perf run, please indicate this with @rustbot label: +perf-regression-triaged along with sufficient written justification. If you cannot justify the regressions please open an issue or create a new PR that fixes the regressions, add a comment linking to the newly created issue or PR, and then add the perf-regression-triaged label to this PR.

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

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.5% [0.2%, 0.6%] 6
Regressions ❌
(secondary)
0.7% [0.4%, 1.0%] 10
Improvements ✅
(primary)
-0.4% [-1.5%, -0.2%] 37
Improvements ✅
(secondary)
-1.5% [-9.3%, -0.2%] 33
All ❌✅ (primary) -0.3% [-1.5%, 0.6%] 43

Max RSS (memory usage)

Results (primary -1.7%)

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)
-1.7% [-2.7%, -1.0%] 3
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -1.7% [-2.7%, -1.0%] 3

Cycles

Results (primary -1.8%, secondary -4.9%)

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)
-1.8% [-2.3%, -1.2%] 5
Improvements ✅
(secondary)
-4.9% [-5.1%, -4.6%] 2
All ❌✅ (primary) -1.8% [-2.3%, -1.2%] 5

Binary size

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

Bootstrap: 672.142s -> 675.838s (0.55%)
Artifact size: 319.14 MiB -> 320.09 MiB (0.30%)

@Kobzol
Copy link
Contributor

Kobzol commented Jun 11, 2024

Nice win across the board, wins outweigh the losses.

@rustbot label: +perf-regression-triaged

@rustbot rustbot added the perf-regression-triaged The performance regression has been triaged. label Jun 11, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Jun 11, 2024
rustc_span: Add conveniences for working with span formats

This is the refactoring part of rust-lang#125017.
bors added a commit to rust-lang-ci/rust that referenced this pull request Jun 11, 2024
rustc_span: Add conveniences for working with span formats

This is the refactoring part of rust-lang#125017.
bors added a commit to rust-lang-ci/rust that referenced this pull request Jun 13, 2024
rustc_span: Add conveniences for working with span formats

This is the refactoring part of rust-lang#125017.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jun 14, 2024
…rister

rustc_span: Add conveniences for working with span formats

This is the refactoring part of rust-lang#125017.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jun 14, 2024
…rister

rustc_span: Add conveniences for working with span formats

This is the refactoring part of rust-lang#125017.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jun 15, 2024
…rister

rustc_span: Add conveniences for working with span formats

This is the refactoring part of rust-lang#125017.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jun 15, 2024
…rister

rustc_span: Add conveniences for working with span formats

This is the refactoring part of rust-lang#125017.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jun 15, 2024
…rister

rustc_span: Add conveniences for working with span formats

This is the refactoring part of rust-lang#125017.
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Jun 15, 2024
Rollup merge of rust-lang#125829 - petrochenkov:upctxt2, r=michaelwoerister

rustc_span: Add conveniences for working with span formats

This is the refactoring part of rust-lang#125017.
bors added a commit to rust-lang-ci/rust that referenced this pull request Jun 16, 2024
rustc_span: Optimize more hygiene operations using `Span::map_ctxt`

I missed these in rust-lang#125017.
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 added a commit to rust-lang-ci/rust that referenced this pull request Jun 16, 2024
rustc_span: Optimize more hygiene operations using `Span::map_ctxt`

I missed these in rust-lang#125017.
bors added a commit to rust-lang-ci/rust that referenced this pull request Jun 16, 2024
rustc_span: Optimize more hygiene operations using `Span::map_ctxt`

I missed these in rust-lang#125017.
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Jun 17, 2024
rustc_span: Optimize more hygiene operations using `Span::map_ctxt`

I missed these in rust-lang/rust#125017.
bors added a commit to rust-lang-ci/rust that referenced this pull request Jun 20, 2024
rustc_span: Optimize span parent get/set methods

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

r? `@cjgillot`
flip1995 pushed a commit to flip1995/rust-clippy that referenced this pull request Jun 28, 2024
rustc_span: Optimize span parent get/set methods

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

r? `@cjgillot`
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. 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.

9 participants