Repository navigation
perf(desktop): ship a class data sharing archive with desktop app images - #421
Merged
Merged
Conversation
Every launch parsed the same ~12,000 classes into about 100 MB of metaspace and symbols. createDistributable and createReleaseDistributable now dump an AppCDS archive, ketch.jsa, into the app image, and the launcher maps the classes from it; its read-only part stays clean memory the system shares. - The image's own launcher dumps the archive, since one only works with the JVM that wrote it, from app/desktop/cds/app.classlist. For release images the list gets ProGuard's names from mapping.txt, which kept 99% of it. recordCdsClassList records the list again. - JDK 21 maps the archive at a random address by default, which moves every pointer in it and leaves little shared, so the launcher passes -XX:ArchiveRelocationMode=0 (diagnostic) and macOS archives are dumped for 0x7000000000, as the JVM's default address isn't free there. - Adding a file breaks the ad-hoc seal jpackage puts on macOS bundles, so the bundle is signed again the same way, keeping its hardened runtime and entitlements. - A JVM that finds no archive, as in ./gradlew run, loads classes as before. Release app on Apple Silicon: 167 -> 117 MB in the background, 575-583 -> 512-513 MB with the window shown, and the window in 1.0-1.3 s instead of about 1.5 s. It adds about 70 MB to the installed app and 15 MB to the DMG.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e38a58137c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Desktop app images now ship an AppCDS archive,
ketch.jsa, beside their jars. The JVM maps the classes a launch needs from it instead of parsing them again. Its read-only part stays clean memory the system shares.createDistributableandcreateReleaseDistributabledump it in adoLast, through the image's own launcher, since an archive only works with the JVM that wrote it. Packages and the portable zip pick it up from the image.app/desktop/cds/app.classlist, recorded from an unobfuscated build. For release images they're renamed through ProGuard'smapping.txt(99% of entries survive)../gradlew :app:desktop:recordCdsClassListrecords the list again; classes it misses still load from the jars.-XX:SharedArchiveFile=$APPDIR/ketch.jsa -XX:+UnlockDiagnosticVMOptions -XX:ArchiveRelocationMode=0. JDK 21 maps the archive at a random address by default, which rewrites most of it and erased most of the saving in measurements. On macOS the archive is dumped for0x7000000000, because the JVM's default address isn't free there../gradlew run, loads classes as before.Results
Release (ProGuard) app, Apple Silicon, physical footprint:
--backgroundBefore merging
Ketch.exe,bin/Ketch) for the first time in the release workflow, the only place desktop packages are built. Please push an rc tag from this branch first. A failed dump fails the build, so a broken platform shows up there rather than shipping without the archive.-XX:ArchiveRelocationMode=0is a diagnostic flag, and it means the archive's class metadata is not address-randomized, as was the default up to JDK 19. Revisit it when the bundled JDK moves past 21.Testing
codesign --verify --strictpasses with the originaladhoc,runtimeflags and entitlements.recordCdsClassListruns the app against an isolated profile underbuild/cds/profileand writes the list once the app is quit../gradlew :app:desktop:testpasses.Independent of #420; the two merge cleanly in either order.