Optimize png_do_expand_palette |
|||||||||
Issue descriptionLoading large PNG files using palettes could be made faster using SIMD instructions.
,
Mar 28 2017
,
Mar 28 2017
Palette optimization seems to be commonly used by PNG optimizers (e.g. http://compresspng.com/).
,
Mar 28 2017
,
Mar 28 2017
,
Mar 28 2017
I generated these traces with the attached image, run through a third-party PNG optimizer, with additional tracing in PNGImageReader::decode. It's also possible to see the effect of the optimization with the ImageFrameGenerator::decode event. Using this event, I've benchmarked a number of versions of the patch at https://codereview.chromium.org/2771903002/ and seen a 10-30% improvement in decode times, depending on the ARM Chromebook in use. Image originally sourced from https://commons.wikimedia.org/wiki/File:ZebraHighRes.png
,
Mar 28 2017
,
Mar 28 2017
,
Mar 28 2017
This is cool! Would be a really interesting change to consider in the context of SkPngCodec. SkPngCodec is used in Android and will eventually be used in Chrome ( crbug.com/702860 ). SkPngCodec tells libpng "just give us the indices", so the table lookups can be handled outside of libpng. That we can be fast without needing to upstream anything. But the Skia implementation is not clever enough for vectorized table lookups... Can we bring these optimizations to Skia? https://cs.chromium.org/chromium/src/third_party/skia/src/codec/SkSwizzler.cpp?l=271 See here for an example of how to hook opt code into the swizzler. https://cs.chromium.org/chromium/src/third_party/skia/src/codec/SkSwizzler.cpp?l=450
,
Mar 28 2017
@matt From a quick look in the Skia code you pointed, I think it should be doable to make the table lookups faster on ARM. I would say we could bring this optimizations to Skia as soon we are able to upstream the current optimizations (adler32, inflate_fast and palette). All that is blocked on upgrading the zlib in Chromium, which is WIP (Work In Progress).
,
Aug 24 2017
,
Oct 27 2017
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/f0dfc858de0d129a4e8a013ae9f870b710fc2d80 commit f0dfc858de0d129a4e8a013ae9f870b710fc2d80 Author: Richard Townsend <Richard.Townsend@arm.com> Date: Fri Oct 27 12:47:06 2017 Add a palettized PNG decoding case Sites often use custom palettes to optimize PNG images using space-saving (but accurate) indexed colours. Bug: 706134 Change-Id: Ie47296fb3d8552a884b86af1c9e3b92130011fd7 Reviewed-on: https://chromium-review.googlesource.com/739391 Reviewed-by: Ned Nguyen <nednguyen@google.com> Reviewed-by: Chris Blume <cblume@chromium.org> Commit-Queue: Chris Blume <cblume@chromium.org> Cr-Commit-Position: refs/heads/master@{#512159} [add] https://crrev.com/f0dfc858de0d129a4e8a013ae9f870b710fc2d80/third_party/WebKit/PerformanceTests/ImageDecoder/decode-png-palette.html [add] https://crrev.com/f0dfc858de0d129a4e8a013ae9f870b710fc2d80/third_party/WebKit/PerformanceTests/ImageDecoder/resources/palette.png
,
Nov 14 2017
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/2d0a36dac3c24e26f2e9a7537290ff321c0f36d7 commit 2d0a36dac3c24e26f2e9a7537290ff321c0f36d7 Author: Richard Townsend <Richard.Townsend@arm.com> Date: Tue Nov 14 21:53:59 2017 Add another palettized PNG decode case Sites often use lossy PNG compression techniques à la pngquant to reduce download size. droids.palette.png is an image prepared with this tool. This image doesn't have any transparency, so it uses a different libpng decode path. Bug: 706134 Change-Id: I27844651b1c9324b3186c977531eba7d1ad55dea Reviewed-on: https://chromium-review.googlesource.com/761516 Reviewed-by: Adenilson Cavalcanti <cavalcantii@chromium.org> Reviewed-by: Chris Blume <cblume@chromium.org> Reviewed-by: Ned Nguyen <nednguyen@google.com> Commit-Queue: Adenilson Cavalcanti <cavalcantii@chromium.org> Cr-Commit-Position: refs/heads/master@{#516443} [add] https://crrev.com/2d0a36dac3c24e26f2e9a7537290ff321c0f36d7/third_party/WebKit/PerformanceTests/ImageDecoder/decode-png-palette-opaque.html [modify] https://crrev.com/2d0a36dac3c24e26f2e9a7537290ff321c0f36d7/third_party/WebKit/PerformanceTests/ImageDecoder/decode-png-palette.html [add] https://crrev.com/2d0a36dac3c24e26f2e9a7537290ff321c0f36d7/third_party/WebKit/PerformanceTests/ImageDecoder/resources/droids.palette.png
,
Dec 8 2017
https://chromium-review.googlesource.com/c/chromium/src/+/817116 (subject to review) optimizes decoding for RGBA/RGB PNGs which use an 8-bit palette. Attached to this comment are some spreadsheets which detail the results: * Improvement on PNG140 (average of 5% improvement on A72 and 23% on A53 for RGBA/RGB images which use an 8-bit palette). * Performance is not seriously impacted for cases in the rest of PNG140, on a collection of Google Doodles, and on the Kodak PNG corpus which don't use a palette.
,
Dec 8 2017
,
Dec 8 2017
The doodles PNG corpus can be found at: https://drive.google.com/drive/folders/1BaqNYg9jUbuUlYLxaBDLCo8him30qyZV?usp=sharing
,
Jan 10 2018
Spreadsheet of various alternate ways of doing things to accompany patchset #5.
,
Jan 11 2018
Slightly updated spreadsheet.
,
Jan 12 2018
,
Jan 16 2018
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/c4811af6d72836d44a3630beecebb0ff55875ab1 commit c4811af6d72836d44a3630beecebb0ff55875ab1 Author: Richard Townsend <Richard.Townsend@arm.com> Date: Tue Jan 16 18:46:42 2018 libpng: Optimize png_do_expand_palette with NEON. ARM-specific optimization processes 8 or 4 pixels at once. * Without transparency: 22% performance gain on the A53 little core. * With transparency: 10% improvement on a big A72 core, 24% on little. (Numbers from image_decode_bench with PNG140 on the elm chromebook). Bug: 706134 Change-Id: I7b4a93d72a0afa2823f3bf9ff5f798b88c843e54 Reviewed-on: https://chromium-review.googlesource.com/817116 Reviewed-by: Adenilson Cavalcanti <cavalcantii@chromium.org> Reviewed-by: Mike Klein <mtklein@chromium.org> Reviewed-by: Leon Scroggins <scroggo@chromium.org> Reviewed-by: Chris Blume <cblume@chromium.org> Commit-Queue: Adenilson Cavalcanti <cavalcantii@chromium.org> Cr-Commit-Position: refs/heads/master@{#529473} [modify] https://crrev.com/c4811af6d72836d44a3630beecebb0ff55875ab1/third_party/libpng/BUILD.gn [add] https://crrev.com/c4811af6d72836d44a3630beecebb0ff55875ab1/third_party/libpng/arm/palette_neon_intrinsics.c [add] https://crrev.com/c4811af6d72836d44a3630beecebb0ff55875ab1/third_party/libpng/patches/0000-plte.patch [add] https://crrev.com/c4811af6d72836d44a3630beecebb0ff55875ab1/third_party/libpng/patches/README [modify] https://crrev.com/c4811af6d72836d44a3630beecebb0ff55875ab1/third_party/libpng/pngpriv.h [modify] https://crrev.com/c4811af6d72836d44a3630beecebb0ff55875ab1/third_party/libpng/pngrtran.c [modify] https://crrev.com/c4811af6d72836d44a3630beecebb0ff55875ab1/third_party/libpng/pngstruct.h [modify] https://crrev.com/c4811af6d72836d44a3630beecebb0ff55875ab1/third_party/libpng/pngwrite.c
,
Jan 16 2018
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/20a18ebc02429a40e4bc33fa28c4de29a39b609c commit 20a18ebc02429a40e4bc33fa28c4de29a39b609c Author: Jonathan Ross <jonross@chromium.org> Date: Tue Jan 16 19:11:04 2018 Revert "libpng: Optimize png_do_expand_palette with NEON." This reverts commit c4811af6d72836d44a3630beecebb0ff55875ab1. Reason for revert: This is failing to compile on ios-device-xcode-clang bot. https://uberchromegw.corp.google.com/i/chromium.mac/builders/ios-device-xcode-clang/builds/50225 Original change's description: > libpng: Optimize png_do_expand_palette with NEON. > > ARM-specific optimization processes 8 or 4 pixels at once. > > * Without transparency: 22% performance gain on the A53 little core. > * With transparency: 10% improvement on a big A72 core, 24% on little. > > (Numbers from image_decode_bench with PNG140 on the elm chromebook). > > Bug: 706134 > Change-Id: I7b4a93d72a0afa2823f3bf9ff5f798b88c843e54 > Reviewed-on: https://chromium-review.googlesource.com/817116 > Reviewed-by: Adenilson Cavalcanti <cavalcantii@chromium.org> > Reviewed-by: Mike Klein <mtklein@chromium.org> > Reviewed-by: Leon Scroggins <scroggo@chromium.org> > Reviewed-by: Chris Blume <cblume@chromium.org> > Commit-Queue: Adenilson Cavalcanti <cavalcantii@chromium.org> > Cr-Commit-Position: refs/heads/master@{#529473} TBR=scroggo@chromium.org,cavalcantii@chromium.org,richard.townsend@arm.com,cblume@chromium.org,mtklein@chromium.org Change-Id: I2cd943e15ceadf4311b1b49a56de00d10684e294 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: 706134 Reviewed-on: https://chromium-review.googlesource.com/868770 Reviewed-by: Jonathan Ross <jonross@chromium.org> Commit-Queue: Jonathan Ross <jonross@chromium.org> Cr-Commit-Position: refs/heads/master@{#529484} [modify] https://crrev.com/20a18ebc02429a40e4bc33fa28c4de29a39b609c/third_party/libpng/BUILD.gn [delete] https://crrev.com/ccd674c83551176374d45eea7a6b0bef07bd2f2e/third_party/libpng/arm/palette_neon_intrinsics.c [delete] https://crrev.com/ccd674c83551176374d45eea7a6b0bef07bd2f2e/third_party/libpng/patches/0000-plte.patch [delete] https://crrev.com/ccd674c83551176374d45eea7a6b0bef07bd2f2e/third_party/libpng/patches/README [modify] https://crrev.com/20a18ebc02429a40e4bc33fa28c4de29a39b609c/third_party/libpng/pngpriv.h [modify] https://crrev.com/20a18ebc02429a40e4bc33fa28c4de29a39b609c/third_party/libpng/pngrtran.c [modify] https://crrev.com/20a18ebc02429a40e4bc33fa28c4de29a39b609c/third_party/libpng/pngstruct.h [modify] https://crrev.com/20a18ebc02429a40e4bc33fa28c4de29a39b609c/third_party/libpng/pngwrite.c
,
Jan 16 2018
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/4173576b1600fb51d7166b17009b3a16dcfdddaf commit 4173576b1600fb51d7166b17009b3a16dcfdddaf Author: Chris Blume <cblume@chromium.org> Date: Tue Jan 16 23:48:47 2018 Revert "Revert "libpng: Optimize png_do_expand_palette with NEON."" This reverts commit 20a18ebc02429a40e4bc33fa28c4de29a39b609c. Reason for revert: The failing iOS build should be fixed. Original change's description: > Revert "libpng: Optimize png_do_expand_palette with NEON." > > This reverts commit c4811af6d72836d44a3630beecebb0ff55875ab1. > > Reason for revert: This is failing to compile on ios-device-xcode-clang bot. > > https://uberchromegw.corp.google.com/i/chromium.mac/builders/ios-device-xcode-clang/builds/50225 > > Original change's description: > > libpng: Optimize png_do_expand_palette with NEON. > > > > ARM-specific optimization processes 8 or 4 pixels at once. > > > > * Without transparency: 22% performance gain on the A53 little core. > > * With transparency: 10% improvement on a big A72 core, 24% on little. > > > > (Numbers from image_decode_bench with PNG140 on the elm chromebook). > > > > Bug: 706134 > > Change-Id: I7b4a93d72a0afa2823f3bf9ff5f798b88c843e54 > > Reviewed-on: https://chromium-review.googlesource.com/817116 > > Reviewed-by: Adenilson Cavalcanti <cavalcantii@chromium.org> > > Reviewed-by: Mike Klein <mtklein@chromium.org> > > Reviewed-by: Leon Scroggins <scroggo@chromium.org> > > Reviewed-by: Chris Blume <cblume@chromium.org> > > Commit-Queue: Adenilson Cavalcanti <cavalcantii@chromium.org> > > Cr-Commit-Position: refs/heads/master@{#529473} > > TBR=scroggo@chromium.org,cavalcantii@chromium.org,richard.townsend@arm.com,cblume@chromium.org,mtklein@chromium.org > > Change-Id: I2cd943e15ceadf4311b1b49a56de00d10684e294 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: 706134 > Reviewed-on: https://chromium-review.googlesource.com/868770 > Reviewed-by: Jonathan Ross <jonross@chromium.org> > Commit-Queue: Jonathan Ross <jonross@chromium.org> > Cr-Commit-Position: refs/heads/master@{#529484} TBR=scroggo@chromium.org,jonross@chromium.org,cavalcantii@chromium.org,richard.townsend@arm.com,cblume@chromium.org,mtklein@chromium.org Change-Id: I6baf17d35efbd5c6bc348d4f81264e8e1023be4f No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: 706134 Reviewed-on: https://chromium-review.googlesource.com/868396 Reviewed-by: Jonathan Ross <jonross@chromium.org> Reviewed-by: Adenilson Cavalcanti <cavalcantii@chromium.org> Reviewed-by: Chris Blume <cblume@chromium.org> Commit-Queue: Chris Blume <cblume@chromium.org> Cr-Commit-Position: refs/heads/master@{#529521} [modify] https://crrev.com/4173576b1600fb51d7166b17009b3a16dcfdddaf/third_party/libpng/BUILD.gn [add] https://crrev.com/4173576b1600fb51d7166b17009b3a16dcfdddaf/third_party/libpng/arm/palette_neon_intrinsics.c [add] https://crrev.com/4173576b1600fb51d7166b17009b3a16dcfdddaf/third_party/libpng/patches/0000-plte.patch [add] https://crrev.com/4173576b1600fb51d7166b17009b3a16dcfdddaf/third_party/libpng/patches/README [modify] https://crrev.com/4173576b1600fb51d7166b17009b3a16dcfdddaf/third_party/libpng/pngpriv.h [modify] https://crrev.com/4173576b1600fb51d7166b17009b3a16dcfdddaf/third_party/libpng/pngrtran.c [modify] https://crrev.com/4173576b1600fb51d7166b17009b3a16dcfdddaf/third_party/libpng/pngstruct.h [modify] https://crrev.com/4173576b1600fb51d7166b17009b3a16dcfdddaf/third_party/libpng/pngwrite.c
,
Feb 7 2018
This was reverted due to an unrelated bug, but was relanded with https://chromium-review.googlesource.com/902145. This looks to be done. Is there more work planned here or can this bug be closed?
,
Feb 7 2018
No more work is planned for the time being, thanks for all your help!
,
Feb 12 2018
For reference, upstream merge request is: https://github.com/glennrp/libpng/pull/203 |
|||||||||
►
Sign in to add a comment |
|||||||||
Comment 1 by cavalcantii@chromium.org
, Mar 28 2017Status: Started (was: Unconfirmed)