RFR: 8321620: Optimize JImage decompressors

Claes Redestad redestad at openjdk.org
Mon Jan 15 16:13:37 UTC 2024


On Fri, 12 Jan 2024 18:45:39 GMT, Glavo <duke at openjdk.org> wrote:

> I generated runtime images using `jlink --compress 2 --add-modules java.se,jdk.unsupported,jdk.management` and then ran the following JMH benchmark:
> 
> 
> @Warmup(iterations = 10, time = 2)
> @Measurement(iterations = 5, time = 3)
> @Fork(value = 1, jvmArgsAppend = {"-XX:+UseG1GC", "-Xms8g", "-Xmx8g", "--add-exports=java.base/jdk.internal.jimage=ALL-UNNAMED"})
> @BenchmarkMode(Mode.AverageTime)
> @OutputTimeUnit(TimeUnit.NANOSECONDS)
> @State(Scope.Benchmark)
> public class Decompress {
> 
>     private static final ImageReader READER = ImageReaderFactory.getImageReader();
>     private static final ImageLocation LOC = READER.findLocation("java.base", "java/lang/String.class");
> 
>     @Benchmark
>     public ByteBuffer test() {
>         return READER.getResourceBuffer(LOC);
>     }
> 
> }
> 
> 
> 
> This is the result:
> 
> 
> Zip
> 
> Benchmark                           Mode  Cnt       Score       Error   Units        Score       Error   Units
> Decompress.test                     avgt    5  194237.534 ±  1026.180   ns/op   152855.728 ± 16058.780   ns/op   (-21.30%)
> Decompress.test:gc.alloc.rate       avgt    5    1197.700 ±     6.306  MB/sec      464.278 ±    47.465  MB/sec
> Decompress.test:gc.alloc.rate.norm  avgt    5  243953.338 ±     5.810    B/op    74376.291 ±     2.175    B/op   (-69.51%)
> Decompress.test:gc.count            avgt    5       2.000              counts        1.000              counts
> Decompress.test:gc.time             avgt    5       4.000                  ms        3.000                  ms
> 
> 
> The results show that memory allocation is reduced by 70% while decompression speed is significantly improved.

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 `jlink --compress 2 --add-modules java.se,jdk.unsupported,jdk.management` it reduces the jimage size by about 0.9% (33279195 vs 32983412 bytes). Throughput might take a small hit. I'm not sure I have time right now to get tested and PR'd but I'll post the draft after sponsoring this.

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

PR Comment: https://git.openjdk.org/jdk/pull/17405#issuecomment-1892445590


More information about the core-libs-dev mailing list