-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Conversation
Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt |
☔ 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.
01e1cc6
to
fff5775
Compare
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
⌛ Trying commit fff5775 with merge 9c8bbf49ba0cc73e86c499b73a28c0b60b2af24c... |
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (9c8bbf49ba0cc73e86c499b73a28c0b60b2af24c): comparison URL. Overall result: ❌ regressions - ACTION NEEDEDBenchmarking 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 @bors rollup=never Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)ResultsThis 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.
CyclesResultsThis 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.
|
There was a problem hiding this 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()); |
There was a problem hiding this comment.
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()
@tmiasko you wrote in a separate comment: #107449 (comment)
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. |
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. |
…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`
…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`
r? @ghost