Repository navigation
[GPU] GDeflate compression codec on the CPU - #127422
Conversation
`CODEC(GDeflate[(level)])`, behind `enable_gdeflate_codec`, levels 1..12, default 6, method byte 0xa1. GDeflate is a variant of Deflate whose bit stream is split into 32 interleaved sub-streams, the format that nvcomp and DirectStorage expand on a GPU, many chunks in parallel. A block is compressed in independent chunks of 64 KiB, each a GDeflate page, from a multiple of 4 bytes, after the number of chunks and a descriptor of each. Of a column of integers, `Int*`, `UInt*`, `Decimal32`, `Decimal64`, `Date*` or `DateTime*`, a chunk is also bit-packed before it is compressed: each integer as its difference from the least of the chunk, in as many bits as the largest difference takes, up to 56. The smaller of the two forms is kept, and the block says which. The format is that of the GPU codec of #119502, so that a GPU can expand the chunks of a column written by this codec. The codec uses the GDeflate pages of NVIDIA's fork of libdeflate (`contrib/gdeflate`), whose compressed pages nvcomp expands on the GPU, and whose expansion reads what nvcomp compresses, as checked on the columns of TPC-H `lineitem` at every level. The fork exports the same symbols as libdeflate, so `contrib/gdeflate-cmake` builds only its GDeflate parts and renames them. `contrib/gdeflate` points at the upstream repository; it must be replaced with a fork under github.com/ClickHouse before merging.
GDeflate compression codec on the CPUGDeflate compression codec on the CPU
|
Workflow [PR], commit [ca28d67] Summary: ✅
AI ReviewSummaryThis PR adds an experimental PR Metadata
Findings❌ Blockers
Final Verdict❌ Request changes before merge: the still-open reserve-size overflow is a real correctness issue, and the new user-facing docs currently describe behavior the implementation does not provide. |
Values read back as they were written for each kind of column, with chunks of integers that are packed and chunks that are not, at several levels, and in `CODEC(Delta, GDeflate)`; an integer column takes fewer bytes than the same bytes in a `FixedString`, which is not packed; the setting and the arguments are checked.
The Fast test initializes only a whitelist of submodules, so the CMake configuration failed: `clickhouse_compression` links `ch_contrib::gdeflate`, which is not defined without the submodule. `GDeflate` is linked unconditionally, like `ZXC`, so it is added to the list the same way. CI report: https://s3.amazonaws.com/clickhouse-test-reports/PRs/127422/eb67af8c4379872cf484890a65f39b55b6caca23/pr/fast_test/cmake_configuration/cmake_configuration.log PR: #127422 Co-Authored-By: Claude Opus 5.5 <[email protected]>
The width of an integer is dispatched once per chunk to templates over the type, as in `Delta` and `T64`, instead of a `switch` per integer in `integerAt` and `storeInteger`, which are removed. The differences from the least integer are taken in the unsigned type of the same width, so they need no widening to 64 bits; unpacking does not depend on the signedness at all. The format does not change: the reference of a chunk of signed integers is now stored zero-extended instead of sign-extended, and the expansion adds the differences to it modulo the width of the type, so blocks written before read the same. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Instead of a template for each signed type, a chunk is packed as unsigned integers of its width with the sign bit flipped where the type is signed, which orders them as the signed type does. Flipping the sign bit adds half the range modulo the width, so the reference, flipped back, expands to the same integers, and the format does not change. Co-Authored-By: Claude Opus 5.5 <[email protected]>
`Header` is the number of chunks with the flag of packed descriptors and knows where each descriptor is; `Chunk` is a descriptor with the compression and the expansion of its chunk, plain or packed. `doCompressData` and `doDecompressData` are loops over them. The functions of one GDeflate page are renamed to `compressPage` and `decompressPage`. The format does not change. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Object file sizes10 object files changed (+180.95 KiB total), 8 added.
719 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only Compile time of recompiled translation units774 translation units recompiled, 6451 s compile time in total, 766 of them have a recent master baseline. Translation units without a recent master baseline:
Symbol sizes
|
`pack`, `unpack`, `compressPage` and `decompressPage` become private methods of `Chunk`; packing sets `bits` and `reference` of the chunk, and unpacking and expansion read them and `compressed_size`, so `PackedChunk` is removed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A block is now only the number of chunks, the compressed size of each, and the chunks, each a GDeflate page. Without packing the codec does not depend on the column type, so it is registered without one, which also makes `updateHash` complete: two columns of different types with `CODEC(GDeflate)` behave the same and may share a codec in a Compact part. Related: #127422 Co-Authored-By: Claude Opus 5.5 <[email protected]>
….codecs` `isCompressionCodec` tells a codec declaration by a static list of family names, which `CompressionCodecFamilyNames.ParserKnowsEveryRegisteredFamily` checks against the factory; and `01222_system_codecs` lists every registered codec. PR: #127422 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Related: #127422 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Preview deployment for your docs. Learn more about Mintlify Previews.
|
|
|
||
| `GDeflate[(level)]` — [GDeflate](https://github.com/NVIDIA/libdeflate/tree/gdeflate), a variant of Deflate whose bit stream is split into 32 interleaved sub-streams, with configurable `level`. Possible levels: \[1, 12\]. Default level: 6. | ||
|
|
||
| A block is compressed in independent chunks of 64 KiB, each a GDeflate page, the format that nvcomp and DirectStorage expand on a GPU, many chunks in parallel. On the CPU, it compresses and decompresses about as fast as Deflate, slower than `LZ4` and `ZSTD`. For columns of integers (`Int*`, `UInt*`, `Decimal32`, `Decimal64`, `Date`, `Date32`, `DateTime`, `DateTime64`), a chunk whose values lie close together is bit-packed before it is compressed, each value as its difference from the least value of the chunk, where that makes the chunk smaller. |
There was a problem hiding this comment.
This paragraph still promises integer-specific bit-packing, but the current CompressionCodecGDeflate implementation no longer has any type-dependent packing path: it just splits the input into 64 KiB chunks and feeds each chunk directly to libdeflate_gdeflate_compress.
That leaves the public contract of the new codec inconsistent with the code users will actually run. Please either restore the numeric packing path or trim this description to match the current generic page codec.
|
Please, do not ignore AI reviews. The CI is finding issues and external reviews are finding security problems Reverting |
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
GDeflatecompression codec on the CPU. ~SOTA codec for GPU decompression - highly important for our future pipeline https://docs.nvidia.com/cuda/nvcomp/gdeflate.htmlWorkflow [PR]
Sync PR [sync-upstream/pr/127422]
Version info
26.11.1.772-master(included in26.11and later)