Repository navigation
Conversation
apache#15454 stopped re-validating spill files on read. apache#21882 moved the reader to `StreamDecoder`, whose `with_skip_validation` only applies to dictionary batches, so every offset and string of a spilled record batch is validated again. Decode the framed messages with `RecordBatchDecoder` instead, which honors the flag.
Closes apache#26627. Offsets are a running total, so zstd keeps about 2.5 of every 4 bytes and lz4 all of them, while the lengths of similar values repeat. Compressed spill files now hold the lengths of `Utf8`, `Binary`, `List` and `Map` arrays, their large variants included, at any nesting depth through `Struct` and `FixedSizeList`. The reader rebuilds the offsets with a running sum, in place in the decompressed buffer.
Contributor
Author
|
doesn't seem to benefit a lot |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
Utf8offsets, which zstd and lz4 barely compress #26627.Stacked on #26688, because lengths are not valid offsets and only read back when spill reads skip validation. Only the last commit is new here.
Rationale for this change
See #26627: spill files are mostly
Utf8offsets, which zstd and lz4 barely compress, while lengths repeat.What changes are included in this PR?
lz4_frameandzstd) hold lengths instead of offsets forUtf8,Binary,List,Mapand their large variants, at any depth throughStructandFixedSizeList. The buffer is[0, len_0, ..., len_(n-2), total]. The IPC writer reads only its first and last entries, to slice the values, so the stock encoder writes it as is.The issue's reproducer (
datafusion-cli -m 100m, median of 7 interleaved runs):TPC-H SF1 sorts with
Utf8columns (schema_force_view_types = false, one partition,-m 200m, median of 5 runs):In the
spill_iobenchmark against #26688, files with strings are 27% to 41% smaller. Writing plus reading them takes up to 7% less time with zstd and about 8.5% more with lz4, because lz4 stored the incompressible offsets raw and now compresses the lengths.Open question: should
lz4_framekeep this, or onlyzstd?What is the testing strategy for this PR?
test_spill_offsets_as_lengths_round_tripspills every rewritten type, nested and sliced, with all three codecs. Its empty and two-row batches cover buffers the IPC writer stores raw.test_spill_offsets_as_lengths_compresschecks that a zstd spill of similar strings is under a quarter of plain zstd IPC.test_restore_offsets_in_place_unless_sharedchecks that the restore reuses an unshared buffer.Are there any user-facing changes?
Smaller spill files with
lz4_frameorzstd. No configuration or API changes.