-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
8305995: Footprint regression from JDK-8224957 #13453
Conversation
Hi @catap, welcome to this OpenJDK project and thanks for contributing! We do not recognize you as Contributor and need to ensure you have signed the Oracle Contributor Agreement (OCA). If you have not signed the OCA, please follow the instructions. Please fill in your GitHub username in the "Username" field of the application. Once you have signed the OCA, please let us know by writing If you already are an OpenJDK Author, Committer or Reviewer, please click here to open a new issue so that we can record that fact. Please use "Add GitHub user catap" as summary for the issue. If you are contributing this work on behalf of your employer and your employer has signed the OCA, please let us know by writing |
/signed |
Thank you! Please allow for up to two weeks to process your OCA, although it is usually done within one to two business days. Also, please note that pull requests that are pending an OCA check will not usually be evaluated, so your patience is appreciated! |
@catap Please do not rebase or force-push to an active PR as it invalidates existing review comments. Note for future reference, the bots always squash all changes into a single commit automatically as part of the integration. See OpenJDK Developers’ Guide for more information. |
I've minimized my code to a trivial benchmark https://gist.github.com/catap/3ac65ba878048cca0132e6cba17d86ba which shown that effect of this patch is reducing memory footprint 20 times. |
Thanks for reporting this, Kirill. I filed JDK-8305995 for tracking. It would be great if you could add your benchmark (to |
Webrevs
|
First, please update PR's title, it should match JBS's title. So before 8224957 code looks through in(1) for req() > 3 (and == 2). After 8224957 we bailout for >3 inputs. I assume, based on description, x4 increase is in Java heap due to not unboxing some Java objects. Or is it memory consumed by C2 Jit compiler during benchmark execution? |
This is a fix for the regression introduced by da43cb5 in fix 8224957. This regression was found while attempting to migrate an application from JDK 1.8 to JDK 17, by running internal benchmarks, and while investigating abnormal memory usage for about 4 times more from one of them. The regression appears in provided JMH benchmark, which builds a RB-tree based map which contains 780 entries with primitive integers. This benchmark was run with `ParallelGC` on different JVMs: `JDK 1.8.0_362`, `JDK 11.0.18`, `JDK 13.0.13`, `JDK 15.0.9`, `JDK 17.0.6`, `JDK 19.0.2` and `JDK 20`. This allows to see that something has changed between 13 and 15, and that the memory footprint for this code has increased from nothing `≈ 10⁻³ ` to `7536` bytes per operation. Proposed fix reduces the memory footprint expected value.
@vnkozlov after spending some time to simplify my benchmark and to include it into PR as the next commit, I'd like to conclude that boxing / unboxing aren't doing anything with it. I just made a force push which contains the benchmark. JMH reports that it almost hasn't got memory footprint in runtime So, in fact it isn't x4, I was wrong on the first assumption. It is much bigger. P.S. I've also rewrite the commit message and include issue ID into it. |
@catap Please do not rebase or force-push to an active PR as it invalidates existing review comments. Note for future reference, the bots always squash all changes into a single commit automatically as part of the integration. See OpenJDK Developers’ Guide for more information. |
Thank you for adding benchmark. Please use meaningful name for benchmark and add copyright header to it. See other benchmarks there as example. |
And add benchmark's output as comment and what machine you used to run it. |
@vnkozlov may you suggest any meaningful name? :) |
Renamed. I've run it as
if I revert my changes by
As you may see memory footprint quite different. As test machine I use right now macOS 12.6.3. I may find some linux, but I doubt that this logic is os specific. |
New test's name is fine. Please, update copyright year (first line) to 2023. Thank you for data. It shows that C2 did not eliminate Integer boxing allocations without your fix. As result they consume Java heap. With your fix C2's Escape Analysis eliminated these allocations. Good! I will submit internal testing for your changes. |
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.
My testing passed.
@catap 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 39 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. As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@vnkozlov, @TobiHartmann) but any other Committer may sponsor as well. ➡️ To flag this PR as ready for integration with the above commit message, type |
/integrate |
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.
Looks good to me too. Thanks for fixing this!
/sponsor |
Going to push as commit 7551529.
Your commit was automatically rebased without conflicts. |
@TobiHartmann @catap Pushed as commit 7551529. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
/backport jdk17u-dev |
@catap To use the |
@TobiHartmann / @vnkozlov may it also be backported to jdk17? |
We (Oracle) will backport it to Oracle JDK 17u after some bake time in mainline. It's then up to the OpenJDK community to backport it to OpenJDK 17u as well but I think it's likely that they will do so. |
@TobiHartmann thanks, it's clear. But can I expect that this fix will be the next release of JDK17? |
This will most likely go into JDK 17.0.8 but it depends on if and when the fix is backported. |
…me JVM version are available
This is a fix for the regression introduced by da43cb5 in fix 8224957.
This regression was found while attempting to migrate an application from JDK 1.8 to JDK 17, by running internal benchmarks, and while investigating abnormal memory usage for about 4 times more from one of them.
The regression appears in the JMH benchmark, which builds a huge tree which contains boxed integers from 0 to a few thousand. A tree has very complex structure and the same objects are reused a lot.
When an
integer
is found it's collected asInteger
and unboxed inside the collector callback.This benchmark was run with
ParallelGC
on different JVMs:JDK 1.8.0_362
,JDK 11.0.18
,JDK 13.0.13
,JDK 15.0.9
,JDK 17.0.6
,JDK 19.0.2
andJDK 20
. This allows to see that something has changed between 13 and 15, and that the memory footprint for this code has increased from3152
to11828
bytes per operation.After that I've done a
git bisect
which allows me to locate the introducer.So the current fix reduces the memory footprint on the local root 425ef06 to
2960
bytes per operation.Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/13453/head:pull/13453
$ git checkout pull/13453
Update a local copy of the PR:
$ git checkout pull/13453
$ git pull https://git.openjdk.org/jdk.git pull/13453/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 13453
View PR using the GUI difftool:
$ git pr show -t 13453
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/13453.diff
Webrev
Link to Webrev Comment