-
Notifications
You must be signed in to change notification settings - Fork 6.1k
8370077: C2: make Compile::_major_progress a boolean #27912
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
base: master
Are you sure you want to change the base?
Conversation
|
👋 Welcome back mchevalier! A progress list of the required criteria for merging this PR into |
|
@marc-chevalier This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be: You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 106 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. ➡️ To integrate this PR with the above commit message to the |
|
@marc-chevalier The following label will be automatically applied to this pull request:
When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command. |
Webrevs
|
src/hotspot/share/opto/compile.hpp
Outdated
| bool _allow_macro_nodes; // True if we allow creation of macro nodes. | ||
|
|
||
| int _major_progress; // Count of something big happening | ||
| bool _major_progress; // Count of something big happening |
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.
Perhaps the comment should be updated too?
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.
That makes sense. A suggestion? Maybe "Whether something big happened"?
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.
It is kind of scary that there is basically no documentation on this. But it is quite important actually. The current comment is really not very helpful.
My understanding is that the flag is set if the loop-opts data-structures are invalid (or at least there is no guarantee that they are valid). So we need to re-build the loop tree.
If we ever set the flag, we don't continue with more loop-opts, but spin back to IGVN, clean the graph, and maybe come back to a new loop-opts round.
There may be others who have a better understanding / definition though.
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 don't think it's the right place for this kind of comment. It's quite hidden, far from where it's actually useful to know we need to set or check that. I'd say it should rather be on PhaseIdealLoop for instance, or PhaseIdealLoop::optimize, something like that, as a part of a more global overview of how things work.
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.
There should just be some documentation around the major_progress family of field/methods. Or at least link from there to where the documentation resides ;)
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 don't think anyone is saying we should not have such comments. I just think it's out of scope here and mainly I just don't know enough to write anything useful and correct. But if somebody more knowledgeable in this gives me a patch that adds such documentation, I can sneak it in this PR. Otherwise, it will be another time.
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.
Absolutely, it should not hold up this PR. It was more meant to be an endorsement that we should definitely add some documentation some point.
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.
Yes, I'd say just file an RFE, and link to the conversation here. Feel free to assign it to me if you don't want to own it ;)
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.
Let's ask @vnkozlov , @TobiHartmann and @rwestrel , do any of you have a good definition for the major_progress concept?
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.
Until jdk11, there were comments in the code like this:
"If _major_progress, then more loop optimizations follow"
but those uses of major_progress() have been changed to !post_loop_opts_phase(). So "major progress" seems to imply "expect more loop opts".
|
Thanks for working on this. I agree that the old I know that all your testing passed... but if there was a bug we may not notice purely with testing. There could also be performance regressions, in cases where we then don't continue optimizing because we messed up and set |
|
Or you can keep temporary (just for testing this PR and remove it before integration) original logic in debug VM to compare result of |
|
@vnkozlov I fear I don't understand what you're suggesting. I've tried to add in my |
|
Here is what I am proposing to check if functionality is preserved and answer @eme64 concern.
|
My understanding of major_progress is to mark major change to graph which may invalidate built loop tree and dominators information and requires exit current round of loop optimization (build_and_optimize()) and run IGVN to clean graph before starting next round of loop optimizations. |
|
It doesn't look safe to me to change the restore_major_progress() behavior in build_and_optimize(). It certainly looks possible to call set_major_progress() in the do_max_unroll case (lines 5146 - 5163) at least. |
|
Given @dean-long and @vnkozlov 's answers, I would suggest something like this: Suggestions for improvements? |
|
I've filed this JDK-8370443 forgot to post. |
|
There are 2 things:
void set_major_progress(bool progress) { precond(!(!progress && _major_progress)); _major_progress = progress; }To see if we are ever in the case that the Here is what I've tested with: |
|
Thanks for the suggestion above @eme64!
Is it really invalid or just not as accurate as it could be but still correct? At least during a major loop optimizations like Loop Peeling etc. we try to keep things right and even recompute broken things when we are done, as for example after Loop Unswitching (which seems unnecessary if we assume things can really be invalid when major progress is set): jdk/src/hotspot/share/opto/loopUnswitch.cpp Line 314 in ffcb158
I think "made progress" is somewhat hard to quantify. We could do plenty of progress in IGVN but not decide to do another loop opts round. But we could remove one useless bool in IGVN and decide to set major progress: jdk/src/hotspot/share/opto/ifnode.cpp Line 1449 in ffcb158
Given that, I would rephrase it to something like: "It also indicates that the graph was changed in a way that is promising to be able to apply more loop optimizations." It seems that "major progress" is probably the wrong term since it not only indicates a major progress but also a "please apply more loop opts". Another good example for that: jdk/src/hotspot/share/opto/loopnode.cpp Lines 5291 to 5298 in ffcb158
What do you think? |
That is a good question. I'm sure there are places where it is indeed invalid, and not just "not as accurate as it could be". What is an example of "not as accurate as it could be" where the information is not invalid? I suppose we would have to continue the work on Still: it could be worth to at least add some documentation, even if we do not have 100% confidence. We should at least write down what we do think we know, and put a caveat that we are not sure, and need to improve the situation in the future. |
|
Thank you, @marc-chevalier, for confirming that new logic works as old one by running different experiments. @eme64, I agree with you suggested comment. @chhagedorn, yes, in most cases setting major_progress indicates that calculated loop information (get_ctrl, idom, get_loop, etc) is invalid anymore and needs to be recalculated. I agree that in some cases we indeed too conservative by setting major_progress. But the only downside is compilation time. |
|
I've added a comment, also using Christian's input.
I've pushed that to tier 4-6, with success. |
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.
Good.
|
I did some experiements, and it looks like we don't hit case 3 in build_and_optimize() because when not verifying, major progress is already set. But I'm concerned about ShenandoahBarrierC2Support::expand(), which clears major progress before calling build_and_optimize(). |
Simply change
Compile::_major_progressfrominttoboolsince we are only checking if it's non-zero.There is one detail, we used to have
It is used after some verification code (maybe not only?) that may reset the major progress, using the progress saved before the said code.
It has a weird semantics:
It is rather a or than a restore, and a proper boolean version of that would be
but then, I'd argue the name is confusing. It also doesn't fit so well the idea that we just want to be back to the situation before the verification code. I suspect the unsaid assumption, is that the 3rd line (progress clear before, set by verification) is not possible. Anyway, I've tried with this or-semantics, or with a more natural
that actually restore what we saved. Both pass (tier1-6 + some internal tests). Thus, I prefered the simpler semantics.
Thanks,
Marc
Progress
Issue
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/27912/head:pull/27912$ git checkout pull/27912Update a local copy of the PR:
$ git checkout pull/27912$ git pull https://git.openjdk.org/jdk.git pull/27912/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 27912View PR using the GUI difftool:
$ git pr show -t 27912Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/27912.diff
Using Webrev
Link to Webrev Comment