Navigation Menu

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

Preprocess dominator tree to answer queries in O(1) #107157

Closed
wants to merge 2 commits into from

Conversation

tmiasko
Copy link
Contributor

@tmiasko tmiasko commented Jan 21, 2023

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. labels Jan 21, 2023
@rustbot
Copy link
Collaborator

rustbot commented Jan 21, 2023

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

@bors
Copy link
Contributor

bors commented Jan 21, 2023

☔ The latest upstream changes (presumably #106976) made this pull request unmergeable. Please resolve the merge conflicts.

There is a number of APIs that answer dominance queries. Previously they
were named either "dominates" or "is_dominated_by". Consistently use the
"dominates" form.

No functional changes.
@tmiasko
Copy link
Contributor Author

tmiasko commented Jan 22, 2023

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

bors commented Jan 22, 2023

⌛ Trying commit fff5775 with merge 9c8bbf49ba0cc73e86c499b73a28c0b60b2af24c...

@bors
Copy link
Contributor

bors commented Jan 22, 2023

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

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (9c8bbf49ba0cc73e86c499b73a28c0b60b2af24c): 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.2% [0.2%, 0.3%] 2
Regressions ❌
(secondary)
0.5% [0.2%, 0.8%] 4
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.2% [0.2%, 0.3%] 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.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
2.4% [2.4%, 2.4%] 1
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.

mean range count
Regressions ❌
(primary)
1.3% [0.7%, 1.8%] 14
Regressions ❌
(secondary)
2.9% [1.8%, 3.9%] 18
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 1.3% [0.7%, 1.8%] 14

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Jan 22, 2023
Copy link
Contributor

@bryangarza bryangarza left a comment

Choose a reason for hiding this comment

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

I'm not an official reviewer, but wanted to leave some feedback.

Just had one comment in the code itself, other than that, it'd be nice to see a unit test or two for the dominators function before merging.

e.start = m;
e.end = m;
}
let mut node = IndexVec::from_elem_n(Idx::new(0), m.try_into().unwrap());
Copy link
Contributor

Choose a reason for hiding this comment

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

if you make the m a usize from the start, you can avoid the try_into().unwrap()

@cjgillot cjgillot mentioned this pull request Feb 12, 2023
@pnkfelix
Copy link
Member

@tmiasko you wrote in a separate comment: #107449 (comment)

FYI: #107157 is intended for instrument coverage builds, where the cost of dominance queries often exceeds the cost of initial preprocessing - the opposite of a profile here, where at best it wouldn't be a regression.

I'm trying to connect that statement with the PR here.

Is the preprocessing done here supposed to be conditionally enabled? I haven't yet seen that in this PR, but I only did a quick skim so maybe I overlooked it.

@tmiasko
Copy link
Contributor Author

tmiasko commented Feb 24, 2023

Is the preprocessing done here supposed to be conditionally enabled?

The extra cost seems negligible, so it can be unconditional (one can't quite tell from last perf results alone, since the measurement is biased by a regression in obligation processing, which has unstable codegen for some reason).

This pull request isn't quite ready for review (hence no assigned reviewer). I also wanted to add a new benchmark that demonstrates perf aspect addressed here first.

Closing for now, maybe will return to this later.

@tmiasko tmiasko closed this Feb 24, 2023
bors added a commit to rust-lang-ci/rust that referenced this pull request May 24, 2023
…illot,tmiasko

Preprocess and cache dominator tree

Preprocessing dominators has a very strong effect for rust-lang#111344.
That pass checks that assignments dominate their uses repeatedly. Using the unprocessed dominator tree caused a quadratic runtime (number of bbs x depth of the dominator tree).

This PR also caches the dominator tree and the pre-processed dominators in the MIR cfg cache.

Rebase of rust-lang#107157
cc `@tmiasko`
saethlin pushed a commit to saethlin/miri that referenced this pull request May 26, 2023
…asko

Preprocess and cache dominator tree

Preprocessing dominators has a very strong effect for rust-lang/rust#111344.
That pass checks that assignments dominate their uses repeatedly. Using the unprocessed dominator tree caused a quadratic runtime (number of bbs x depth of the dominator tree).

This PR also caches the dominator tree and the pre-processed dominators in the MIR cfg cache.

Rebase of rust-lang/rust#107157
cc `@tmiasko`
@tmiasko tmiasko deleted the dominators-O(1) branch November 10, 2023 23:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
perf-regression Performance regression. 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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants