Repository navigation
Conversation
|
Workflow [PR], commit [90d833c] Summary: ❌
AI ReviewSummaryThis PR adds a Findings
Final Verdict
|
| Optional parameter `posting_list_codec` (default: `none`) specifies the codec for posting list: | ||
| - `none` - the posting lists are stored without additional compression. | ||
| - `bitpacking` - apply [differential (delta) coding](https://en.wikipedia.org/wiki/Delta_encoding), followed by [bit-packing](https://dev.to/madhav_baby_giraffe/bit-packing-the-secret-to-optimizing-data-storage-and-transmission-m70) (each within blocks of fixed-size). Slows down SELECT queries, not recommended at the moment. | ||
| - `fastpfor` - apply differential (delta) coding, followed by [FastPFOR](https://github.com/fast-pack/FastPFOR) (patched frame-of-reference) coding within blocks of fixed size. Compared to `bitpacking` it compresses better when most deltas are small but a few are large (bursty or sparse posting lists), because the large outliers are coded as exceptions rather than widening every value. `fastpfor` is only available when ClickHouse is built with the FastPFOR library (`x86-64-v2` or higher, and `AArch64`); on builds without it, both creating and reading a `fastpfor` posting list fail with `SUPPORT_IS_DISABLED`. Posting lists written with `fastpfor` therefore cannot be read on a build that lacks FastPFOR. |
There was a problem hiding this comment.
I'm curious whether the hypothesis holds true for this scenario: can the posting list guarantee a small delta?
Additionally, please include the benchmark results for this optimization.
There was a problem hiding this comment.
Benchmark (mixed 2M-row corpus: bursty + uniform-stride + random-sparse tokens): total text-index size is fastpfor 10.84 MiB vs bitpacking 12.52 MiB vs none 11.59 MiB — fastpfor is the smallest overall, and on a bursty-only token set it is 813 KiB vs bitpacking 2.72 MiB (~3.3x). The hypothesis isn't that the posting list guarantees small deltas: fastpfor codes the few large gaps as exceptions instead of widening every value, so it beats bitpacking precisely on bursty/sparse lists; versus uncompressed none the win is data-dependent. Query latency was comparable across the three codecs in these runs.
There was a problem hiding this comment.
Sorry if I'm misunderstanding something, but why are the index sizes between none and either compressed codec so similar? I would have guessed any compression would make the index significantly smaller (e.g. the data from the PR that introduced bitpacking). Can you help me understand how these work?
|
@fastio Please split the commits into smaller pieces: One that refactors the existing infrastructure and one that adds fastpfor as a codec (right now, it's one huge commit). |
Generalize the bitpacking-only segment codec into a pluggable per-block framework (IPostingListBlockCodec); no behavior change.
Add the fastpfor posting_list_codec (delta + FastPFOR per block); decode is bounded so corrupted .pst input raises CORRUPTED_DATA instead of reading OOB.
302ab17 to
490f30f
Compare
|
@rschu1ze Done — split into two commits: one that refactors the infrastructure into a pluggable per-block codec framework, and one that adds the |
|
Hi @fastio, thanks for this PR. I'm currently working on a similar pfor based compression for follow-up of #103172. I suppose we should use the same integer compression for both posting list and positions since that new pfor compression performs better that FastPfor in my benchmarks. I'll push it soon and let you know. |
|
Hi @ahmadov, Thanks for the heads-up! The codec here is intentionally pluggable. Once you merge, I can build a posting list codec on top of the new PFOR -- hoping it gives us better compression. |
| return createPostingListCodec(IPostingListCodec::Type::Bitpacking); | ||
|
|
||
| #if USE_FASTPFOR | ||
| if (codec_name == PostingListCodecFastPFOR::getName()) |
There was a problem hiding this comment.
The table-level text_index_posting_list_codec = 'fastpfor' path is still rejected. This branch handles a literal posting_list_codec = 'fastpfor' index argument, but the table setting goes through TextIndexPostingListCodec (settings[...].toString() in MergeTreeIndexText.cpp), and src/Core/SettingsEnums.h / src/Core/SettingsEnums.cpp still only declare and map none and bitpacking. As a result, CREATE TABLE ... SETTINGS text_index_posting_list_codec = 'fastpfor' fails before it reaches this factory, even though the docs say these advanced parameters can be set at table level. Please add FastPFOR / "fastpfor" to the setting enum and cover the table-setting path in the stateless test.
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered by tests: 430/487 (88.30%) | Lost baseline coverage: none · Uncovered code |
`master` moved the documentation from the Docusaurus tree under `docs/en/**/*.md` to the Mintlify tree at `docs/**/*.mdx`, deleting every file this branch edits. The edits are replayed at the new paths: - `docs/en/engines/table-engines/mergetree-family/textindexes.md` -> `docs/reference/engines/table-engines/mergetree-family/textindexes.mdx`
|
Implemented in #84435 |
This pull request adds a new
fastpforposting list codec for the (experimental) text index, selectable viaposting_list_codec = 'fastpfor'alongside the existingnoneandbitpacking.Implementation.
PostingListCodecBitpackingImplinto a genericSegmentedPostingListCodecImplthat keeps the shared segment / block / Index Section layout and delegates only the per-block payload to a pluggableIPostingListBlockCodec(bitpackingorfastpfor). The lazy posting cursor keeps random per-block access unchanged.FastPFORBlockCodec, a pimpl wrapper around FastPFOR'sCompositeCodec<SIMDFastPFor<4>, VariableByte>. The header stays free of SIMD/FastPFOR includes so it is include-safe on builds without the library.ch_contrib::fastpforonx86-64-v2+ (SSE4.2) andAArch64(NEON). On builds without FastPFOR, creating or reading afastpforposting list fails withSUPPORT_IS_DISABLED; lists written withfastpforcannot be read on such builds.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Add a new
fastpforoption for the text indexposting_list_codecparameter. It applies delta coding followed by FastPFOR (patched frame-of-reference) compression per block, compressing better thanbitpackingfor bursty or sparse posting lists.Documentation entry for user-facing changes
Reopen: #95517