-
Notifications
You must be signed in to change notification settings - Fork 5.9k
8337505: Footprint and startup regressions up to 20% in GUI apps #21748
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
Conversation
👋 Welcome back prr! A progress list of the required criteria for merging this PR into |
❗ This change is not yet ready to be integrated. |
private static VarHandle cellInfoHandle; | ||
private static VarHandle imageHandle; | ||
|
||
private static VarHandle getXAdvanceHandle() { |
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.
Quick question: is there no concern with multi-threading / race conditions for these lazy creation methods? (e.g. requiring double-checked locking or similar)
This looks like a good use case for StableValue
, if it were ready!
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 won't be multiple threads except in some really unusual case so I don't think it is a problem
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 suspect dropping static final
from these VarHandle
-s would degrade performance, as some internal checks in VHs
would not constant-fold.
Do you need these in isolation, or can you lazily-initialize them all at once? You can use "holder class" pattern like:
static class VHHolder {
static final VarHandle xAdvanceHandle = ...
}
I've been told about this static final optimisation but I've never observed any measurable benefit in other code where I've tried hard to see it. |
@prrace even if not perf critical, every cpu cycle count, do not waste if possible! I do recomment using the lazy holder singleton pattern:
Or something like that... My 2 cents |
I would have to create a class per-varhandle. I really don't want to do that. |
Why ? You can group vh in holder class... if you need several, why not? |
I am not baking in the specifics of the grouping that "happens" to be what I see today on whatever tests I run on Windows. |
The similar argument can be applied to the expectation that non-foldable VHs do not affect performance, right? Since we are dealing with a performance regression already, it would be nice not to introduce another one. I think holder classes are a fair compromise here until Stable Values arrive. Look at this variant (untested): 8337505-v1.patch. This is also arguably more straight-forward than lazy initialization with runtime null-checks and extra (mutable) fields, I think. |
In a previous fix I spent ages trying to see any improvement in perf of this over literally 100 of thousands of invocations
In the case where they are all needed then this fix surely makes it worse. |
Is |
I don't know and don't see much precedent. |
What I think @merykitty means here is taking your lazy-initialization patch, and then stamp |
Thanks for the suggestion, but it isn't a path I want to go. The patch is still fine as it is. |
Well, the point of the review process is to get at least some reviewers to agree. I do not see anyone agreeing so far. My problem with current version is that exposing non-constant-foldable I do not quite understand what is the problem with stamping
|
A dependency on the internals of the base module is another reason not to do this. |
Are you sure all these var handles are rarely used (not on hot code path)? This current patch can slow down the use of these var handles by many times. If this is startup-only, we can probably just create the vh once, invoke it, and discard it, or look into FFM API and see if we have better one-time invocation solutions. |
I don't know what you are thinking. Or perhaps you are overthinking it. |
From the FFM API pov, we might be able to make the VarHandle lazy, that it contains symbolic information and is fully expanded upon first use, effectively the same as the laziness here. Don't know if this works for FFM, but this is how java lang invoke ones work if they have to initialize classes. If such laziness is implemented, we can always revisit the existing uses later. This patch is fine as long as there is no bad side effects. |
So some day this patch may be obsolete ? So no reason to make it more complex. |
Phil, I don’t understand your resistance to using the You could well be correct in saying that run-time performance is a complete non-issue, for all users at all times, but why not apply |
Stable annotation requires the class to be loaded by the boot loader. Need to verify that for java.desktop first. |
jdk/make/conf/module-loader-map.conf Line 36 in 4966419
|
Thanks for the verification Mark. |
@prrace This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration! |
Do we have a chance to reproduce the 20% numbers, and how it is comparable to the initial unsafe implementation? As a mentioned in the initial PR the new ffm implementation may add up to 100ms on startup(I tested it in the cmm). So taking that into account and 20% on some perftests(which one?) I assume migration back to unsafe could be an option as well. |
@prrace This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration! |
@prrace This pull request has been inactive for more than 8 weeks and will now be automatically closed. If you would like to continue working on this pull request in the future, feel free to reopen it! This can be done using the |
https://bugs.openjdk.org/browse/JDK-8338677 already improved things for this so that's good.
This fix adds to it lazy initialisation of VarHandles in StrikeCache at the cost of some extra code.
Since these VarHandles get used more or less immediately on Linux this new fix won't further improve matters there
But should help on Mac where they aren't usually needed at startup
And Windows is somewhere in between.
Progress
Issue
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/21748/head:pull/21748
$ git checkout pull/21748
Update a local copy of the PR:
$ git checkout pull/21748
$ git pull https://git.openjdk.org/jdk.git pull/21748/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 21748
View PR using the GUI difftool:
$ git pr show -t 21748
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/21748.diff
Using Webrev
Link to Webrev Comment