You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ZFile already compresses data blocks, but stores the block-length index uncompressed. This PR adds optional index compression using the existing format’s flag bit 5.
Changes:
Add CompressArgs::compress_index and the --compress-index CLI flag, disabled by default.
Share index writing across the whole-file writer and both streaming builders.
Support LZ4 and ZSTD, retaining raw indexes when compression provides no space savings or exceeds codec limits.
Validate metadata, sizes, checksums and decoded block lengths before exposing the file for reads.
Handle short source reads and enforce index limits before buffering additional input.
Format choices:
With bit 5 clear, index_size remains the entry count.
With bit 5 set, it records compressed bytes; the decoded entry count is derived from the original file size and block size.
The index checksum covers the stored bytes.
Existing raw indexes remain supported. Older readers cannot read compressed indexes, so compression remains opt-in. I have not compared these format choices with the historical ease implementation.
Validation:
Debug build with QAT disabled.
Full zfile_test suite: all 12 tests passed.
Coverage includes both codecs, all writers, header/trailer paths, raw fallback, short reads and malformed inputs.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
The size-limit check can block indefinitely on an open pipe after overflow is already known because it waits for a full batch or EOF instead of checking after each successful read.
No open issues 🎉
1 previously missed issue
In code that hasn't changed since last review
Check input size after each read to avoid blocking on overflow
src/overlaybd/zfile/zfile.cpp:1375
The size-limit check runs only after a full batch or EOF. If the accepted input has reached the maximum and a pipe supplies one extra byte but remains open, this loop attempts another read and can block indefinitely instead of returning EFBIG, even though the overflow is already known. Check the accumulated batch size after each successful read before requesting more input.
Allow ZFile writers to compress the block-length index with LZ4 or
ZSTD when requested. Keep the raw index when compression does not
reduce its size. Validate stored and decoded indexes before use.
Signed-off-by: Willis Wu <willis060510@gmail.com>
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
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.
ZFile already compresses data blocks, but stores the block-length index uncompressed. This PR adds optional index compression using the existing format’s flag bit 5.
Changes:
CompressArgs::compress_indexand the--compress-indexCLI flag, disabled by default.Format choices:
index_sizeremains the entry count.Existing raw indexes remain supported. Older readers cannot read compressed indexes, so compression remains opt-in. I have not compared these format choices with the historical ease implementation.
Validation:
zfile_testsuite: all 12 tests passed.git diff --checkpassed.