Skip to content

Use Set instead of Vec in transitive_relation #103214

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

Merged
merged 1 commit into from
Oct 19, 2022

Conversation

Noratrieb
Copy link
Member

Helps with #103195. It doesn't fix the underlying quadraticness but it makes it a lot faster to an extent where even doubling the amount of nested references still takes less than two seconds (50s on nightly).

I want to see whether this causes regressions (because the vec was usually quite small) or improvements (as lookup for bigger sets is now much faster) in real code.

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Oct 18, 2022
@rust-highfive
Copy link
Contributor

r? @petrochenkov

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 18, 2022
@thomcc
Copy link
Member

thomcc commented Oct 18, 2022

@bors try @rust-timer queue

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion.

@rustbot label: +S-waiting-on-perf

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Oct 18, 2022
@bors
Copy link
Collaborator

bors commented Oct 18, 2022

⌛ Trying commit 04ab19fbde3eb5cc061ff6b026cc1b542d0c400d with merge cfee159701a9bf8017cebf2b31f22fae454b0c54...

@bors
Copy link
Collaborator

bors commented Oct 18, 2022

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

@rust-timer
Copy link
Collaborator

Queued cfee159701a9bf8017cebf2b31f22fae454b0c54 with parent a24a020, future comparison URL.

@rust-timer
Copy link
Collaborator

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

mean1 range count2
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.6% [-0.7%, -0.5%] 2
Improvements ✅
(secondary)
-1.2% [-1.6%, -0.6%] 7
All ❌✅ (primary) -0.6% [-0.7%, -0.5%] 2

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.

mean1 range count2
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
3.4% [2.0%, 5.3%] 10
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

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.

mean1 range count2
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.9% [-2.9%, -2.9%] 1
All ❌✅ (primary) - - 0

Footnotes

  1. the arithmetic mean of the percent change 2 3

  2. number of relevant changes 2 3

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Oct 19, 2022
@est31
Copy link
Member

est31 commented Oct 19, 2022

Tbh the freeze function also looks pretty inefficient. A proper BFS would be better I think. Edit: you'd have to watch out for cycles, but there are ways to do that I think. Or can we assume cycle freedom?

@petrochenkov
Copy link
Contributor

This is a perf improvement so r=me unless you want to address other comments like #103214 (comment).
@rustbot author

@rustbot rustbot 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 Oct 19, 2022
@Noratrieb
Copy link
Member Author

Noratrieb commented Oct 19, 2022

The potential perf improvement for freeze sounds interesting, but I don't want to do this in this PR since it requires some more investigation. I'd prefer to land it as-is.
@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 19, 2022
@Dylan-DPC
Copy link
Member

@bors r=petrochenkov

@bors
Copy link
Collaborator

bors commented Oct 19, 2022

📌 Commit d45f025 has been approved by petrochenkov

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 Oct 19, 2022
@bors
Copy link
Collaborator

bors commented Oct 19, 2022

⌛ Testing commit d45f025 with merge 4b8f431...

@bors
Copy link
Collaborator

bors commented Oct 19, 2022

☀️ Test successful - checks-actions
Approved by: petrochenkov
Pushing 4b8f431 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Oct 19, 2022
@bors bors merged commit 4b8f431 into rust-lang:master Oct 19, 2022
@rustbot rustbot added this to the 1.66.0 milestone Oct 19, 2022
@rust-timer
Copy link
Collaborator

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

mean1 range count2
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.6% [-0.7%, -0.6%] 2
Improvements ✅
(secondary)
-1.2% [-1.6%, -0.6%] 7
All ❌✅ (primary) -0.6% [-0.7%, -0.6%] 2

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.

mean1 range count2
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
2.4% [2.1%, 2.8%] 3
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Cycles

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

Footnotes

  1. the arithmetic mean of the percent change 2

  2. number of relevant changes 2

@Noratrieb Noratrieb deleted the set-theory branch October 19, 2022 18:19
Aaron1011 pushed a commit to Aaron1011/rust that referenced this pull request Jan 6, 2023
Use Set instead of Vec in transitive_relation

Helps with rust-lang#103195. It doesn't fix the underlying quadraticness but it makes it _a lot_ faster to an extent where even doubling the amount of nested references still takes less than two seconds (50s on nightly).

I want to see whether this causes regressions (because the vec was usually quite small) or improvements (as lookup for bigger sets is now much faster) in real code.
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.

9 participants