On Fri, 2 Jan 2026 02:34:55 GMT, Jeremy Wood <[email protected]> wrote:
>> When decoding an uninterlaced 8-bit PNG image, the PNGImageDecoder is >> basically copying one byte at a time. >> >> This PR uses System.arraycopy instead, and it shows approx a 10% improvement. >> >> This graph shows the time it takes different decoders to convert a byte >> array into a BufferedImage as the size of the PNG image increases: >> >> <img width="596" height="366" alt="Screenshot 2025-12-27 at 9 14 19 PM" >> src="https://github.com/user-attachments/assets/73583cb2-eda0-47a8-b818-735a1835f1e8" >> /> >> >> (This originally came to my attention when looking at an image in Java 1.8. >> There the ImageConsumer model took approx 400% longer than ImageIO. I was >> happy to see in recent JDKs that gap narrowed significantly, but there was >> still a noticeable 10% discrepancy.) >> >> I haven't tried submitting a performance enhancement PR before; I'm not sure >> if this issue meets this group's threshold for being worth addressing. And >> if it does: I'm not sure how to structure a unit test for it. > > Jeremy Wood has updated the pull request incrementally with one additional > commit since the last revision: > > 8374377: test correctness of non-interlaced PNGs too > > Also this removes the performance comparison. (As of this writing there's a > separate > `test/micro/org/openjdk/bench/sun/awt/image/PNGImageDecoder_8bit_uninterlaced.java` > file used to demonstrate that this change is more performant.) Product change looks good to me. Some changes are needed to make the JMH test run. I have also given full functional test run after this update. Will update once i have results. test/micro/org/openjdk/bench/sun/awt/image/PNGImageDecoder_8bit_uninterlaced.java line 23: > 21: * questions. > 22: */ > 23: package org.openjdk.bench.sun.misc; package should be `org.openjdk.bench.sun.awt.image` test/micro/org/openjdk/bench/sun/awt/image/PNGImageDecoder_8bit_uninterlaced.java line 33: > 31: import org.openjdk.jmh.annotations.State; > 32: import org.openjdk.jmh.annotations.Warmup; > 33: import org.openjdk.jmh.infra.Blackhole; We need to import `import org.openjdk.jmh.annotations.Benchmark;` and `import org.openjdk.jmh.annotations.Setup;` also. Otherwise i am seeing compilation errors. ------------- PR Review: https://git.openjdk.org/jdk/pull/29004#pullrequestreview-3622415433 PR Review Comment: https://git.openjdk.org/jdk/pull/29004#discussion_r2657041047 PR Review Comment: https://git.openjdk.org/jdk/pull/29004#discussion_r2657043086
