RFR: 8346239: Improve memory efficiency of JimageDiffGenerator

Severin Gehwolf sgehwolf at openjdk.org
Thu Dec 19 18:20:08 UTC 2024


Please review this fairly simple change to improve how the `JimageDiffGenerator` works. The original implementation is pretty naive and read all bytes into memory and then compared them. This improved version only reads bytes on a bound buffer into memory compares those bytes and if equal continues on to reading the next bytes (`2k` at most) at a time. Previously it was `2*N` (where `N` is the file size of a file in bytes) part of the JDK. Ouch.

There is still the off-chance of reading a full file into memory when the generator detects a change, but this shouldn't happen for large files since the total diff should be around `600K` as of today.

This also reverts changes from [JDK-8344036](https://bugs.openjdk.org/browse/JDK-8344036) other than the `/timeout` change to the test, which is preserved as I think this bump is no longer needed.

Testing:
- [ ] GHA
- [x] jlink tests on a fastdebug build with `--with-native-debug-symbols=internal` (so as to have a large libjvm.so).
- [x] Manual reproducer from the bug which fails with OOM before the patch and passes after

Thoughts?

-------------

Commit messages:
 - Fixup.
 - Bump timeout of test
 - Revert "8344036: Tests tools/jlink/runtimeImage fail on AIX after JDK-8311302"
 - 8346239: Improve memory efficiency of JimageDiffGenerator

Changes: https://git.openjdk.org/jdk/pull/22835/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=22835&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8346239
  Stats: 77 lines in 16 files changed: 57 ins; 3 del; 17 mod
  Patch: https://git.openjdk.org/jdk/pull/22835.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/22835/head:pull/22835

PR: https://git.openjdk.org/jdk/pull/22835


More information about the core-libs-dev mailing list