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

use Vec for region constraints instead of BTreeMap #118824

Merged
merged 2 commits into from
Dec 22, 2023

Conversation

aliemjay
Copy link
Member

@aliemjay aliemjay commented Dec 11, 2023

~1% perf gain

Diagnostic regressions need more investigation.

r? @ghost

@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. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Dec 11, 2023
@aliemjay aliemjay changed the title use Vec for region constraints instead for BTreeMap use Vec for region constraints instead of BTreeMap Dec 11, 2023
@rustbot
Copy link
Collaborator

rustbot commented Dec 11, 2023

Failed to set assignee to ghost: invalid assignee

Note: Only org members with at least the repository "read" role, users with write permissions, or people who have commented on the PR may be assigned.

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

bors commented Dec 11, 2023

⌛ Trying commit fb14cf7 with merge 2fc4795...

bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 11, 2023
use Vec for region constraints instead of BTreeMap

~1% perf gain

Diagnostic regressions need more investigation.

r? `@ghost`
@@ -273,7 +272,7 @@ pub(crate) enum UndoLog<'tcx> {
AddVar(RegionVid),

/// We added the given `constraint`.
AddConstraint(Constraint<'tcx>),
AddConstraint(usize),
Copy link
Member

Choose a reason for hiding this comment

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

Could be an IndexVec :)

Copy link
Member Author

Choose a reason for hiding this comment

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

or simply remove the index from AddConstraint? 🤷‍♂️ It is useless and I only added it for consistency with AddVerify.

Copy link
Member Author

@aliemjay aliemjay Dec 15, 2023

Choose a reason for hiding this comment

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

It is useless and I only added it for consistency with AddVerify.

This is wrong. The index was actually needed in in leak_check code, but now I have removed the UndoLog altogether so it doesn't matter anymore (*edit: I reverted this commit).

Copy link
Member Author

Choose a reason for hiding this comment

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

Adding a newtype index seems incompatible with sorting and deduplicating the IdexVec IMO.

@bors
Copy link
Contributor

bors commented Dec 11, 2023

☀️ Try build successful - checks-actions
Build commit: 2fc4795 (2fc4795b87dcc533a38f9e9507ed9c7e5a782446)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (2fc4795): comparison URL.

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

@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
Improvements ✅
(primary)
-0.6% [-1.4%, -0.2%] 44
Improvements ✅
(secondary)
-0.7% [-1.8%, -0.1%] 30
All ❌✅ (primary) -0.6% [-1.4%, -0.2%] 44

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)
6.9% [6.9%, 6.9%] 1
Regressions ❌
(secondary)
4.9% [4.2%, 5.5%] 2
Improvements ✅
(primary)
-1.2% [-1.2%, -1.2%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 2.8% [-1.2%, 6.9%] 2

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)
-1.1% [-1.3%, -1.0%] 2
Improvements ✅
(secondary)
-2.2% [-2.6%, -1.9%] 8
All ❌✅ (primary) -1.1% [-1.3%, -1.0%] 2

Binary size

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

Bootstrap: 668.867s -> 668.905s (0.01%)
Artifact size: 314.18 MiB -> 314.18 MiB (0.00%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Dec 11, 2023
@michaelwoerister
Copy link
Member

This looks similar to SortedMap. Using that might simplify the code.

@aliemjay
Copy link
Member Author

another experiment: remove undo log
@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 Dec 15, 2023
@bors
Copy link
Contributor

bors commented Dec 15, 2023

⌛ Trying commit f388f23 with merge e499e7a...

bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 15, 2023
use Vec for region constraints instead of BTreeMap

~1% perf gain

Diagnostic regressions need more investigation.

r? `@ghost`
@aliemjay
Copy link
Member Author

aliemjay commented Dec 15, 2023

This looks similar to SortedMap. Using that might simplify the code.

@michaelwoerister A downside is that it incurs a perf penalty for every insert operation when in practice most inserted region constraints end up being removed either by rolling back to a previous snapshot or by ignoring region resolution entirely.

@michaelwoerister
Copy link
Member

Ah OK, that makes sense!

@bors
Copy link
Contributor

bors commented Dec 15, 2023

☀️ Try build successful - checks-actions
Build commit: e499e7a (e499e7ae9f0bbf4e31d9098449d41b915437833e)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (e499e7a): 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.4% [0.2%, 0.8%] 8
Regressions ❌
(secondary)
0.8% [0.1%, 1.6%] 12
Improvements ✅
(primary)
-0.7% [-1.6%, -0.2%] 36
Improvements ✅
(secondary)
-0.8% [-2.1%, -0.2%] 27
All ❌✅ (primary) -0.5% [-1.6%, 0.8%] 44

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)
2.4% [2.0%, 2.7%] 2
Improvements ✅
(primary)
-1.6% [-2.7%, -0.6%] 2
Improvements ✅
(secondary)
-2.2% [-3.1%, -0.4%] 6
All ❌✅ (primary) -1.6% [-2.7%, -0.6%] 2

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)
1.4% [1.4%, 1.4%] 1
Improvements ✅
(primary)
-1.3% [-2.2%, -0.6%] 12
Improvements ✅
(secondary)
-2.2% [-3.1%, -0.6%] 12
All ❌✅ (primary) -1.3% [-2.2%, -0.6%] 12

Binary size

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

Bootstrap: 672.135s -> 670.525s (-0.24%)
Artifact size: 312.47 MiB -> 312.34 MiB (-0.04%)

@rustbot rustbot added the perf-regression Performance regression. label Dec 15, 2023
@aliemjay
Copy link
Member Author

I reverted the UndoLog experiment, so this is no longer a perf regression as per the original perf run.
@rustbot label: -perf-regression

The diagnostic regression is fixed by the last commit.

r? compiler
@rustbot ready

@rustbot rustbot removed the perf-regression Performance regression. label Dec 17, 2023
@aliemjay aliemjay marked this pull request as ready for review December 17, 2023 07:37
@@ -4,8 +4,8 @@ error[E0308]: mismatched types
LL | assert_all::<_, &String>(id);
| ^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other
|
= note: expected reference `&String`
found reference `&String`
= note: expected trait `for<'a> <for<'a> fn(&'a String) -> &'a String {id} as FnMut<(&'a String,)>>`
Copy link
Member

Choose a reason for hiding this comment

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

Why did this change 🤔

Copy link
Member

Choose a reason for hiding this comment

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

Ah, it's the second commit.

@compiler-errors
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Dec 21, 2023

📌 Commit 8c215e7 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 Dec 21, 2023
@bors
Copy link
Contributor

bors commented Dec 21, 2023

⌛ Testing commit 8c215e7 with merge 8b30243...

bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 21, 2023
…r-errors

use Vec for region constraints instead of BTreeMap

~1% perf gain

Diagnostic regressions need more investigation.

r? `@ghost`
@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)
[RUSTC-TIMING] serde test:false 8.189
[RUSTC-TIMING] rustdoc_json_types test:false 3.137
[RUSTC-TIMING] basic_toml test:false 1.412
   Compiling askama_derive v0.12.1
##[error]The runner has received a shutdown signal. This can happen when the runner service is stopped, or a manually started runner is canceled.
##[group]Clock drift check
  local time: Fri Dec 22 00:02:06 UTC 2023
  local time: Fri Dec 22 00:02:06 UTC 2023
Session terminated, killing shell... ...killed.
##[error]The operation was canceled.
Cleaning up orphan processes

@bors
Copy link
Contributor

bors commented Dec 22, 2023

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Dec 22, 2023
@compiler-errors
Copy link
Member

Unrelated

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

bors commented Dec 22, 2023

⌛ Testing commit 8c215e7 with merge d6d7a93...

@bors
Copy link
Contributor

bors commented Dec 22, 2023

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

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

Finished benchmarking commit (d6d7a93): 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.5% [-1.3%, -0.2%] 39
Improvements ✅
(secondary)
-0.7% [-1.7%, -0.2%] 29
All ❌✅ (primary) -0.5% [-1.3%, -0.2%] 39

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)
0.5% [0.5%, 0.6%] 2
Improvements ✅
(primary)
-1.4% [-1.4%, -1.4%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -1.4% [-1.4%, -1.4%] 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)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-1.4% [-1.5%, -1.2%] 2
Improvements ✅
(secondary)
-2.7% [-2.8%, -2.6%] 2
All ❌✅ (primary) -1.4% [-1.5%, -1.2%] 2

Binary size

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

Bootstrap: 674.597s -> 672.389s (-0.33%)
Artifact size: 312.79 MiB -> 312.74 MiB (-0.02%)

bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 21, 2024
Stop sorting via `DefId`s in region resolution

hopefully maintains the perf improvement from rust-lang#118824

works towards rust-lang#90317
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 22, 2024
…ichaelwoerister

Stop sorting via `DefId`s in region resolution

hopefully maintains the perf improvement from rust-lang#118824

works towards rust-lang#90317
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. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants