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

Extend SCC construction to enable extra functionality #125069

Merged
merged 12 commits into from
Jun 13, 2024

Conversation

amandasystems
Copy link
Contributor

Do YOU feel like your SCC construction doesn't do enough? Then I have a patch for you! SCCs can now do everything! Well, almost.

This patch has been extracted from #123720. It specifically enhances
Sccs to allow tracking arbitrary commutative properties (think min/max mappings on nodes vs arbitrary closures) of strongly connected components, including

  • reachable values (max/min)
  • SCC-internal values (max/min)

This helps with among other things universe computation. We can now identify
SCC universes as a reasonably straightforward "find max/min" operation during SCC construction. This is also included in this patch.

It's also more or less zero-cost; don't use the new features, don't pay for them.

This commit also vastly extends the documentation of the SCCs module, which I had a very hard time following. It may or may not have gotten easier to read for someone else.

I believe this logic can also be used in leak check, but haven't checked. Ha. ha. Ha.

@rustbot
Copy link
Collaborator

rustbot commented May 13, 2024

r? @pnkfelix

rustbot has assigned @pnkfelix.
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 13, 2024
@amandasystems
Copy link
Contributor Author

r? Lqd

@rustbot rustbot assigned lqd and unassigned pnkfelix May 13, 2024
@lqd
Copy link
Member

lqd commented May 13, 2024

@bors try @rust-timer queue

As discussed on zulip, until I have more time let's also temporarily redirect to niko for review or reassignment, and discuss at this week's meeting: r? nikomatsakis

@rust-timer

This comment has been minimized.

@rustbot rustbot assigned nikomatsakis and unassigned lqd May 13, 2024
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label May 13, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request May 13, 2024
Extend SCC construction to enable extra functionality

Do YOU feel like your SCC construction doesn't do enough? Then I have a patch for you! SCCs can now do *everything*! Well, almost.

This patch has been extracted from rust-lang#123720. It specifically enhances
`Sccs` to allow tracking arbitrary commutative properties (think min/max mappings on nodes vs arbitrary closures) of strongly connected components, including
- reachable values (max/min)
- SCC-internal values (max/min)

This helps with among other things universe computation. We can now identify
SCC universes as a reasonably straightforward "find max/min" operation during SCC construction. This is also included in this patch.

It's also more or less zero-cost; don't use the new features, don't pay for them.

This commit also vastly extends the documentation of the SCCs module, which I had a very hard time following. It may or may not have gotten easier to read for someone else.

I believe this logic can also be used in leak check, but haven't checked. Ha. ha. Ha.
@bors
Copy link
Contributor

bors commented May 13, 2024

⌛ Trying commit 609a202 with merge 6c7f0a6...

@bors
Copy link
Contributor

bors commented May 13, 2024

☀️ Try build successful - checks-actions
Build commit: 6c7f0a6 (6c7f0a6914780a8bd5240c26e668f7b0625b66dc)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (6c7f0a6): comparison URL.

Overall result: ❌ regressions - 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.5% [0.2%, 1.6%] 45
Regressions ❌
(secondary)
1.4% [0.1%, 4.0%] 32
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.5% [0.2%, 1.6%] 45

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)
2.8% [2.4%, 3.2%] 2
Regressions ❌
(secondary)
2.2% [2.2%, 2.2%] 2
Improvements ✅
(primary)
-2.6% [-2.6%, -2.6%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 1.0% [-2.6%, 3.2%] 3

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

Binary size

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

Bootstrap: 675.291s -> 676.941s (0.24%)
Artifact size: 315.98 MiB -> 316.29 MiB (0.10%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels May 13, 2024
@Kobzol
Copy link
Contributor

Kobzol commented May 17, 2024

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

bors commented May 17, 2024

⌛ Trying commit c510e73 with merge 1805d8a...

bors added a commit to rust-lang-ci/rust that referenced this pull request May 17, 2024
Extend SCC construction to enable extra functionality

Do YOU feel like your SCC construction doesn't do enough? Then I have a patch for you! SCCs can now do *everything*! Well, almost.

This patch has been extracted from rust-lang#123720. It specifically enhances
`Sccs` to allow tracking arbitrary commutative properties (think min/max mappings on nodes vs arbitrary closures) of strongly connected components, including
- reachable values (max/min)
- SCC-internal values (max/min)

This helps with among other things universe computation. We can now identify
SCC universes as a reasonably straightforward "find max/min" operation during SCC construction. This is also included in this patch.

It's also more or less zero-cost; don't use the new features, don't pay for them.

This commit also vastly extends the documentation of the SCCs module, which I had a very hard time following. It may or may not have gotten easier to read for someone else.

I believe this logic can also be used in leak check, but haven't checked. Ha. ha. Ha.
@amandasystems
Copy link
Contributor Author

amandasystems commented May 17, 2024

My guess is 0.3% primary regressions and 0.84% in secondary, let's see how wrong I am!

Also, you can't edit on GitHub so there is no way for me to remove this if I'm enormously off. Too bad!

@lqd
Copy link
Member

lqd commented May 17, 2024

@rust-timer build 1805d8a

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (1805d8a): comparison URL.

Overall result: ❌ regressions - 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.2%, 0.8%] 23
Regressions ❌
(secondary)
1.5% [0.1%, 3.9%] 20
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.3% [0.2%, 0.8%] 23

Max RSS (memory usage)

Results (primary -0.4%)

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.3% [1.3%, 1.3%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-1.3% [-2.4%, -0.2%] 2
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.4% [-2.4%, 1.3%] 3

Cycles

Results (primary -0.2%, secondary -1.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)
7.2% [7.2%, 7.2%] 1
Regressions ❌
(secondary)
2.0% [1.8%, 2.2%] 5
Improvements ✅
(primary)
-2.1% [-4.3%, -0.8%] 4
Improvements ✅
(secondary)
-2.6% [-3.8%, -2.0%] 10
All ❌✅ (primary) -0.2% [-4.3%, 7.2%] 5

Binary size

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

Bootstrap: 669.422s -> 671.224s (0.27%)
Artifact size: 316.04 MiB -> 316.26 MiB (0.07%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label May 17, 2024
@bors bors added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Jun 12, 2024
@nikomatsakis
Copy link
Contributor

Actually that was slightly premature. Let me finish the read :)

@bors r-

@bors bors 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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jun 12, 2024
Copy link
Contributor

@nikomatsakis nikomatsakis left a comment

Choose a reason for hiding this comment

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

r=me modulo nits

I love all the comments you added! 💜

compiler/rustc_borrowck/src/region_infer/mod.rs Outdated Show resolved Hide resolved
compiler/rustc_data_structures/src/graph/scc/mod.rs Outdated Show resolved Hide resolved
This patch has been extracted from rust-lang#123720. It specifically enhances
`Sccs` to allow tracking arbitrary commutative properties of SCCs, including
- reachable values (max/min)
- SCC-internal values (max/min)

This helps with among other things universe computation: we can now identify
SCC universes as a straightforward "find max/min" operation during SCC construction.

It's also more or less zero-cost; don't use the new features, don't pay for them.

This commit also vastly extends the documentation of the SCCs module, which I had a very hard time following.
Note that this changes no executing code. The change is 100% in documentation.
This version shaves off ca 2% of the cycles in my experiments
and makes the control flow easier to follow for me and hopefully
others, including the compiler.

Someone gave me a working profiler and by God I'm using it.
This shaves off ca 6% of the cycles in `start_walk_from()` in my
experiments.
Apparently this interferes with inlining and murders performance
on `wg-grammar`.
This commit addresses @lqd's code review and resurrects
a lost comment and removes some dead code.
In terms of code organisation, this is a lot cleaner and allows
tighter access modifiers.
@amandasystems
Copy link
Contributor Author

Rebased!

@jackh726
Copy link
Member

@bors r=nikomatsakis

@bors
Copy link
Contributor

bors commented Jun 12, 2024

📌 Commit d63708b has been approved by nikomatsakis

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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jun 12, 2024
@bors
Copy link
Contributor

bors commented Jun 12, 2024

⌛ Testing commit d63708b with merge 8cf5101...

@bors
Copy link
Contributor

bors commented Jun 13, 2024

☀️ Test successful - checks-actions
Approved by: nikomatsakis
Pushing 8cf5101 to master...

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

Finished benchmarking commit (8cf5101): 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.2% [0.2%, 0.3%] 6
Regressions ❌
(secondary)
0.5% [0.1%, 1.0%] 10
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.3% [-0.3%, -0.3%] 2
All ❌✅ (primary) 0.2% [0.2%, 0.3%] 6

Max RSS (memory usage)

Results (primary -3.2%, secondary -5.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)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-3.2% [-4.4%, -2.0%] 2
Improvements ✅
(secondary)
-5.0% [-5.0%, -5.0%] 1
All ❌✅ (primary) -3.2% [-4.4%, -2.0%] 2

Cycles

Results (secondary -1.8%)

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.9% [2.0%, 3.6%] 4
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-8.1% [-9.1%, -7.5%] 3
All ❌✅ (primary) - - 0

Binary size

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

Bootstrap: 671.52s -> 672.648s (0.17%)
Artifact size: 320.35 MiB -> 320.29 MiB (-0.02%)

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. 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.

None yet

9 participants