Repository navigation
Conversation
…ay under the split serialization threshold
|
| <artifactId>hive-exec</artifactId> | ||
| </dependency> | ||
| <dependency> | ||
| <!-- the codecs of the split payloads; zstd-jni comes with ORC, and hive-exec bundles it --> |
There was a problem hiding this comment.
but snappy is not shaded in hive-exec , zstd is part of sharding here https://github.com/apache/hive/blob/master/ql/pom.xml#L1097-L1161
its not a big problem as tez project has direct dependency on snappy unless snappy version has incompatiblity but better to add in ql/pom.xml or we can leverage aircompressor which is already shaded like trino uses but artifactId (import) needs to be changed then.
WDYT?
|
|
||
| @Override | ||
| byte[] decompress(byte[] stored) { | ||
| return Zstd.decompress(stored, (int) Zstd.getFrameContentSize(stored)); |
There was a problem hiding this comment.
Zstd.getFrameContentSize(stored)); can return negative as well as per its javadoc:
/**
* Return the original size of a compressed buffer (if known)
*
* @param src the compressed buffer
* @return the number of bytes of the original buffer
* 0 if the original size is not known,
* negative if there is an error decoding the frame header
*/
and returnign -ve in decompress can throw exception
public byte[] decompress(byte[] src, int srcOffset, int srcSize, int originalSize) throws ZstdException {
if (originalSize < 0) {
throw new ZstdException(Zstd.errGeneric(), "Original size should not be negative");
}
| this.id = (byte) id; | ||
| } | ||
|
|
||
| static Codec of(byte id) throws IOException { |
There was a problem hiding this comment.
a switch can be used as codec are fixed rather than for loop?



What changes were proposed in this pull request?
IcebergSplit compresses its payload with the codec named by the new
hive.iceberg.split.compression.codec(
snappyby default,zstdornone). The payload is[codec id][stored length][stored bytes]; the task group isstill Java-serialized as before, only the bytes are compressed. The reader takes the codec from the payload, so only the
split generator reads the setting.
Why are the changes needed?
HiveSplitGenerator keeps split payloads in the Tez AM until their total reaches
hive.tez.input.fs.serialization.threshold(256 MiB); every split after that is written to the staging file system asa file of its own and read back by its task. IcebergSplit serializes each task group as a separate stream, so every split
repeats the class descriptors and the schema and partition spec of its tasks: ~5.5 KB per split, of which only
264-568 bytes are unique to it.
On a 1TRC table with ~49.6k splits the scan before the DML stays just under the threshold (258 MB in memory, events in
0.1 s); the scans after a V2 / V3 merge-on-read DML go over it (70 / 51 MB written to the file system) and split
generation grows from ~3 s to ~18 / ~12 s (cluster table below).
Does this PR introduce any user-facing change?
A new configuration,
hive.iceberg.split.compression.codec. Split payloads are smaller; a split written by anotherHive version cannot be read (AM and tasks run the same build).
How was this patch tested?
TestIcebergSplit: round trip with every codec on a task group with position deletes (locations, start/length, sequence
numbers), compression smaller than none, a split without configuration using the default, an unknown codec id failing.
TestIcebergInputFormats, TestInputFormatReaderDeletes, TestHiveIcebergSelects, TestHiveIcebergDeletionVectors and
TestHiveIcebergVectorization pass with the snappy default (the Tez local runs serialize the split events).
Per split, measured locally on the 1TRC table layout: snappy 1.75-1.9x smaller (12x for splits carrying 300
partition-scoped delete files) at ~5 us of AM time per split; zstd 2.1-2.35x (41x) at ~12-15 us.
On a 40-node LLAP cluster with that table, split generation (Map 1 initialization in the Tez AM) and split payloads,
without -> with this patch (snappy):
No split is written to the staging file system any more. Compression costs ~5 us of AM time per split (measured
locally), ~0.2 s for the 43.5k splits of the scan before the DML. Most of what remains on the delete-heavy scan is the
Java serialization of its task groups (~6 s for 1.75M delete file references), which this patch does not change. Query
results are identical to those of a build without the patch.