sunchao commented on code in PR #7606:
URL: https://github.com/apache/datafusion-comet/pull/7606#discussion_r4746933702


##########
native/shuffle/src/lz4_frame.rs:
##########
@@ -0,0 +1,325 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+//! LZ4 frames written with buffers and a hash table kept from one frame to 
the next.
+//!
+//! Every compressed shuffle block is one LZ4 frame. [`Lz4FrameEncoder`] 
writes the frame format
+//! itself around lz4_flex's block compressor, compressing whole blocks 
straight from the
+//! caller's buffer and writing each block out as soon as it is compressed. One
+//! `lz4_flex::frame::FrameEncoder<Vec<u8>>` kept from frame to frame would 
reuse its state too,
+//! but it measured no faster than a new encoder per frame on 8192-row blocks
+//! (`benches/shuffle_writer.rs`), and it holds each whole compressed frame 
until it is copied out.
+//!
+//! The frames have independent blocks of at most 64 KiB, no block or content 
checksums, no
+//! content size and an end mark. A block that does not get smaller is stored 
uncompressed, as
+//! `FrameEncoder` does.
+
+use lz4_flex::block::{compress_into_with_table, get_maximum_output_size, 
CompressTable};
+use std::io::{self, Write};
+
+/// Uncompressed bytes per block: the frame format's smallest block maximum, 
which every LZ4
+/// reader decodes with the least memory.
+const BLOCK_SIZE: usize = 64 * 1024;

Review Comment:
   I also varied only the value distribution to isolate when the local 
block-size change matters. In an Arrow IPC frame probe (1,300 Int32 columns, 
8,192 rows, 67,328-byte schema), `c_i[row] = row + i` grew from 10,865,552 to 
21,516,805 compressed bytes. Independent pseudorandom columns on the same 
schema were essentially flat at 42,638,627 vs 42,640,109. So a random-only wide 
benchmark can miss the added I/O even when it shows the CPU win. Please include 
both inputs and report frame bytes alongside encode time when evaluating the 
local fallback.



-- 
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