acruise opened a new pull request, #7354:
URL: https://github.com/apache/datafusion-comet/pull/7354

   Reading a native shuffle block built a new decompressor for every block: 
zstd allocated a decompression context and window buffers, lz4_flex allocated 
block-sized input and output buffers as it read the frame, and snap allocated 
and zero-filled about 140 KiB up front. For the small blocks a reduce task 
reads by the thousand, that setup was a large share of the decode (#7067, step 
one).
   
   The decompressors now live in the reader's per-thread state next to the 
schema cache. The zstd context is kept and reset per frame, as the writer 
already does with its compression context, and dropped when it outgrows the 
writer's 8 MiB cap. The lz4_flex and snap decoders own their reader, so a 
`BlockInput` lends them the block for one decode through a `Loan` guard that 
revokes the loan, and discards the decoder if the decode did not finish, so a 
broken frame cannot carry into the next block. lz4_flex sizes its buffers to 
the frame's block size and asserts they keep it, so one lz4 decoder is kept per 
block size (64 KiB to 4 MiB, about 11 MiB at most); frames of any other layout 
get a decoder for that block only. snap only checks for the stream identifier 
on a decoder's first chunk, so the reader checks it itself to keep the same 
strictness.
   
   `shuffle_reader` bench, decode_block, Apple M3, median of before -> after:
   
   | block            | lz4                | zstd               | snappy        
      |
   
|------------------|--------------------|--------------------|---------------------|
   | 5 col, 64 rows   | 2.24 -> 1.99 µs    | 4.69 -> 4.37 µs    | 4.13 -> 2.73 
µs     |
   | 5 col, 512 rows  | 6.13 -> 5.93 µs    | 11.90 -> 11.56 µs  | 14.15 -> 
12.49 µs   |
   | 50 col, 64 rows  | 12.44 -> 12.05 µs  | 12.01 -> 11.66 µs  | 19.98 -> 
18.30 µs   |
   | 50 col, 8192 rows| 976 -> 956 µs      | 328 -> 328 µs      | 2.72 -> 2.64 
ms     |
   
   The uncompressed path is unchanged within noise. The bench now covers zstd 
and snappy as well as none and lz4.
   
   ## Which issue does this PR close?
   
   <!--
   We generally require a GitHub issue to be filed for all bug fixes and 
enhancements and this helps us generate change logs for our releases. You can 
link an issue to this PR using the GitHub syntax. For example `Closes #123` 
indicates that this PR will close issue #123.
   -->
   
   Closes #.
   
   ## Rationale for this change
   
   <!--
    Why are you proposing this change? If this is already explained clearly in 
the issue then this section is not needed.
    Explaining clearly why changes are proposed helps reviewers understand your 
changes and offer better suggestions for fixes.
   -->
   
   ## What changes are included in this PR?
   
   <!--
   There is no need to duplicate the description in the issue here but it is 
sometimes worth providing a summary of the individual changes in this PR.
   -->
   
   ## How are these changes tested?
   
   <!--
   We typically require tests for all PRs in order to:
   1. Prevent the code from being accidentally broken by subsequent changes
   2. Serve as another way to document the expected behavior of the code
   
   If tests are not included in your PR, please explain why (for example, are 
they covered by existing tests)?
   -->
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to