-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
8321620: Optimize JImage decompressors #17405
Conversation
👋 Welcome back Glavo! A progress list of the required criteria for merging this PR into |
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. Should wait for @cl4es review as he looked at the previous version.
@Glavo 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 9 new commits pushed to the
Please see this link for an up-to-date comparison between the source branch of this pull request and the 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 (@mlchung, @cl4es) but any other Committer may sponsor as well. ➡️ To flag this PR as ready for integration with the above commit message, type |
I ran tier1~tier2 tests and there were no new failures. |
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!
Pre-existing issue here is that it seems we don't handle compressed resources that can't fit in a single byte[]
, yet we take the overhead of storing uncompressed/compressed size as longs (4+4 byte overhead per entry). I guess we should either add code to handle huge entries or optimize the compressed header to store int sizes.
/integrate |
This limitation is so deep-rooted that it is difficult to resolve it for the time being. But I don't think this is causing any problems for the time being. There is no need to put an overly large resource in a jimage file, it will be better placed elsewhere. But even so, I think it's appropriate to store the size as 64 bits, which will make it easier to lift this restriction in the future. If you want the size of the metadata, I think it is more appropriate to compress the metadata. I tried using zstd to compress the metadata in JApp and got good results. We might be able to do this in jimage as well. |
I'd very much welcome support for zstd, both for resource content and metadata. A larger JEP-sized project, that. I have run a quick experiment with adding a more compact header format (16-bit sizes for the four fields) and on a |
/sponsor |
Going to push as commit a03eb6d.
Your commit was automatically rebased without conflicts. |
@cl4es The command |
For reference here's my draft idea on a backwards-compatible compressed compressed header (heh): #17433 No significant difference on micros but a modest saving on the archive size. |
From my experience on the JApp project, if compressed metadata is implemented, the size of these fields may be irrelevant. In the early development stage of JApp, I used 32-bit integers to store metadata such as resource size. But after using zstd to compress the metadata, I was surprised to find that storing them as 64-bit integers can actually reduce the file size for some test cases. The compression algorithm does the work for me, so I no longer need to care about these details. |
Sorry, I re-looked at the test data and found that I was wrong. Switching 32-bit fields to 64-bit still slightly increased the file size, although I still feel this is inconsequential. |
It'd be very interesting to see zstd compression applied in this context to see how it'd stack up w.r.t archive size, speed of decompression and so on. In this specific case we'd probably have to keep the 4-byte magic marker intact (it might be possible to rid us of this), then compress the remainder (25 bytes) and store the size (a byte might be enough). For reference with regular zip on representative data I can squeeze headers down then from 29 to 22-24 bytes. In #17433 I'm down to 12 bytes (including marker) with little to no overhead. I'm not going to pursue getting #17433 integrated (for now), but it might be a nice little piece of a larger puzzle. |
I generated runtime images using
jlink --compress 2 --add-modules java.se,jdk.unsupported,jdk.management
and then ran the following JMH benchmark:This is the result:
The results show that memory allocation is reduced by 70% while decompression speed is significantly improved.
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/17405/head:pull/17405
$ git checkout pull/17405
Update a local copy of the PR:
$ git checkout pull/17405
$ git pull https://git.openjdk.org/jdk.git pull/17405/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 17405
View PR using the GUI difftool:
$ git pr show -t 17405
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/17405.diff
Webrev
Link to Webrev Comment