Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass image data directly to ZlibStream, bypassing ChunkState::raw_bytes #424

Merged
merged 6 commits into from
Nov 14, 2023

Commits on Nov 9, 2023

  1. Configuration menu
    Copy the full SHA
    e8b6482 View commit details
    Browse the repository at this point in the history
  2. Handle fdAT sequence numbers via U32 state.

    This helps with unifying how image data from IDAT and fdAT is handled.
    This unification is a prerequisite for the follow-up commit where we
    will avoid temporarily copying compressed image data into
    `current_chunk.raw_bytes`.
    anforowicz committed Nov 9, 2023
    Configuration menu
    Copy the full SHA
    93b7ffa View commit details
    Browse the repository at this point in the history
  3. Pass image data directly to ZlibStream, bypassing `ChunkState::raw_…

    …bytes`.
    
    Before these changes we would store all image data in
    `ChunkState::raw_bytes` before attempting to decompress them via
    `ZlibStream`.  This is undesirable for performance, because 1) it copies
    data unnecessarily into and out of `raw_bytes` and 2) by the time we
    have stored all the image data, the start of it may be already gone from
    the L1 cache.
    
    After these changes, the image data is passed directly into
    `ZlibStream`.
    
    This commit is part of a bigger set of changes that avoids copying image
    pixels across different buffers.  This commit alone gives notable
    although relatively small performance improvements, but the real
    motivation here is to make progress toward merging the bigger set of
    changes and realizing their performance gains.  For more information
    see the "Revisiting copy avoidance" part of the discussion at
    image-rs#416 (comment)
    
    Performance impact of this commit (2 measurement attempts):
    
    * `decode/8x8-noncompressed.png` - runtime improved by 9.18% - 9.99%
    * `128x128-noncompressed.png` - runtime improved by 7.89% - 8.51%
    * `decode/Transparency.png` - runtime improved by 1.92% - 2.69%
    
    No impact on the other test inputs:
    
    * `decode/kodim02.png` - change within noise threshold (same result when
      rerun)
    * `decode/kodim07.png` - no change detected (p = 0.06 or 0.17 > 0.05)
    * `decode/kodim17.png` - runtime improved by 1.75%
      (change within noise threshold when rerun)
    * `decode/kodim23.png` - runtime regressed by 2.15%
      (no change detected when rerun - p = 0.86 > 0.05)
    * `Lohengrin_-_Illustrated_Sporting_and_Dramatic_News.png` - change
      within noise threshold (no change detected when rerun - p = 0.14 >
      0.05)
    anforowicz committed Nov 9, 2023
    Configuration menu
    Copy the full SHA
    c65cb64 View commit details
    Browse the repository at this point in the history

Commits on Nov 14, 2023

  1. Move benches/png_generator.rs to src/test_utils.rs.

    The move will help with follow-up work, where we want to use generated
    PNGs in unit tests of `src/decoder/stream.rs`.
    anforowicz committed Nov 14, 2023
    Configuration menu
    Copy the full SHA
    f4bc666 View commit details
    Browse the repository at this point in the history
  2. Fix handling of fdAT chunks shorter than 4 bytes.

    This has accidentally regressed in a recent commit and was caught during
    PR review.
    anforowicz committed Nov 14, 2023
    Configuration menu
    Copy the full SHA
    a568f6c View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    e75843f View commit details
    Browse the repository at this point in the history