Repository navigation
Add experimental PIVCO wavelet-tree integer encoding in UNSTABLE - #12103
lwwmanning wants to merge 6 commits into
Conversation
Adds the vortex-pivco crate implementing Pow2-Bin + PIVCO wavelet-tree integer compression (PH, PHA, OP-PHA) with canonical 32-lane static byte-rANS bitmaps, 3-buffer split wire layout, L1-resident in-place ping-pong decoding, x86_64/NEON SIMD kernels, O(depth) top-down scalar_at, zero-sync windowed SliceReduce, Filter/Take/Compare/ZigZag kernels, narrow estimate_compressed_bits cost estimation, strict wire/bounds/dtype-width validation, and full Vortex conformance suites. Registers vortex.pivco in UNSTABLE edition and default file encodings, and adds the pivco_compress benchmark with its CodSpeed shard count. Signed-off-by: Will Manning <will@willmanning.io>
lwwmanning
left a comment
There was a problem hiding this comment.
Posted by Claude Opus 5.5 on Will's behalf.
Fresh review of bf5f7388. I found no correctness bug, and no malformed file that can cause a panic or an out-of-bounds read. The read path checks tree depth, symbol ranges against the dtype, header order and bounds, rANS states and stream use, sparse indices, and raw_bits lengths. The 80 seeded byte-flip tests back this up. The compute kernels also traced correct, including negative constants, compares at u64::MAX, slices that start mid-block, and null take indices.
This PR adds the vortex.pivco wire ID to the unstable edition, so its format needs a careful manual review before it leaves draft. Two fixes first:
-
Pin the rANS tables in a test for backward compatibility.
compute_bernoulli_freqsbuilds the 16 Bernoulli tables at run time, so they are part of the format. The only test checks their properties (sum 2048, monotone). A later change to that code would silently break files that were already written. Persist the table values in a test, and pin the serialized bytes of one encoded block with each bitmap marker. -
merge_vec_vec_in_place_left,merge_vec_vec_in_place_right,merge_cst_vec_in_placeandmerge_vec_cst_in_placeinsimd/mod.rsare safe functions, but they do not check thatrightholdspopcount(bm, k)bytes. The scalar tail readsr_base.add(rc)with no bound. For example,merge_vec_vec_in_place_left(&[0xFF; 4], 32, 0, &[], &mut [0; 32])reads 32 bytes from an empty slice. The callers indecode.rsandspine.rsalways computek_rightwith a popcount, so no file can reach this. Mark themunsafe fnwith that precondition, or computek_rightinside them.
Format choices that become permanent once a release can read them:
- Slice state (
offset,tree_base_offset,raw_base_word_offset) goes into the metadata. If serialize rebased the headers, this state would stay off the wire. block_shift == 0is read as 12. Writing 12 avoids a permanent alias.- There is no version byte, so only the unused opcodes and marker values are left to extend the format.
- Padding bytes in sparse indices, rANS words and block tails are not required to be zero.
validateskips the header checks when buffers are not on the host. The CUDA follow-up must validate beforeblock_tree_sliceruns on copied data.
Smaller notes:
scalar_atand the spine walk trustleft_subtree_bytes. On a corrupt file they can return wrong values whereexecutereturns an error, but nothing panics.- The root-only compare path in
spine.rscan leave set bits pastlenin the last byte.BitBufferprobably masks them, but I did not check this. - The NEON code is gated on
target_arch = "aarch64", nottarget_feature = "neon". - No test proves that compare, filter or take used the pushdown and did not fall back. Compare has no test at
block_shift13, with values at or above 2^32, or with the constant on the left.
Proportion: 12.6k lines is large for an experimental encoding, though about 2.9k are tests and benchmarks. These parts could land later: the encoder-only SIMD (partition_ranks_*, pack_flat_codes_*, about 470 lines) and the SSSE3/SSE4.1 tier, which CI never runs on AVX2 runners. estimate_compressed_bits could also move to #12104, its only caller. The NEON 64-byte merge bodies in neon.rs are duplicated. The decode kernels and the core codec look proportionate.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
… and wire/pushdown tests - Mark in-place SIMD merge helpers as unsafe fn with explicit popcount/length preconditions and safety comments at all call sites - Gate NEON merge paths on target_feature = "neon" in addition to target_arch = "aarch64" - Mask trailing padding bits past logical len in the root-only compare fast path - Add wire-format pinning tests for the 16 static Bernoulli rANS tables and all bitmap markers, plus direct CompareKernel/FilterKernel/TakeExecute pushdown and shift-13/u64/const-left edge-case tests Signed-off-by: Will Manning <will@spiraldb.com> Co-Authored-By: Will Manning <will@spiraldb.com>
Merging this PR will degrade performance by 12.82%Warning vortex-data has exceeded the Hobby plan limit of 5 active contributors. Upgrade your plan or apply to the open source program by December 8, 2026 to keep using CodSpeed. 1 warning
Warning Please fix the performance issues or acknowledge them on CodSpeed. Performance Changes
Tip Investigate this regression by commenting Comparing Footnotes
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bf5f738847
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…hecks - Add explicit PivcoMetadata::has_validity flag (tag 7) and ignore trailing extra children on deserialize per wire-contracts.md - Use checked_add in checked_num_blocks_for during deserialization and array validation to reject offset + len overflow - Bound left/right subtree frames and validate left_subtree_bytes bounds in decode_symbol_at and prefix_ebits_sum - Add regression tests for declared validity, ignored trailing children, and offset + len overflow Signed-off-by: Will Manning <will@spiraldb.com> Co-Authored-By: Will Manning <will@spiraldb.com>
|
Addressed the review notes in
|
roborev: Combined Review (
|
robert3005
left a comment
There was a problem hiding this comment.
I read the decode path, the SIMD merge and unpack kernels, the rANS decoder, the plugin and the take/filter/compare kernels at 1878d3b6. I found no new correctness or soundness bug. The in-place merges now are unsafe fn with a stated precondition and length asserts, and the SIMD loads stay inside the checked lengths. Take falls back when indices.len() does not fit in u32, so the u32 cursors cannot wrap. I do not repeat the points that the earlier reviews already raised.
The main problem is size. The PR adds about 13k lines in one change. The repo guidance asks for changes under about 500 lines, and a new wire format needs a careful line-by-line review. At this size, that review is not practical. Please split it. A possible order:
- Scalar codec only:
pow2_bin,tree,bitmap_rans, scalarencode/decode,array,plugin, the edition entry, and the wire-contract tests. This PR fixes the wire format, so it gets the most careful review. - SIMD decode kernels (
simd/neon.rs,simd/x86.rs, and the dispatch insimd/mod.rs), with tests that compare each tier to the scalar path. - Compute pushdown:
codec/spine.rsandcompute.rs(compare, filter, take, ZigZag). - Encoder-only SIMD and the benchmark.
Each step keeps the wire format unchanged, so the later PRs need no format review.
Test volume: tests.rs has 28 test functions with 72 #[case] entries, and conformance_tests.rs adds 7 more with 8 cases. That is far above the 20-case guideline, and no test uses hegeltest. Most of the matrices check the same few properties on different inputs. A small number of hegeltest properties would cover more inputs with less code: round trip equals the input; compare, filter and take equal the canonical result; a slice round trips; and random byte changes in any buffer give an error or a value, never a panic.
|
|
||
| /// Serialized protobuf metadata for a [`PivcoArray`]. | ||
| #[derive(Clone, PartialEq, Eq, prost::Message)] | ||
| pub struct PivcoMetadata { |
There was a problem hiding this comment.
docs/specs/versioning/wire-contracts.md asks for a golden file of the metadata bytes, written with check_metadata, with every field set to a value other than its default. I found no check_metadata call in this crate. The pinned block-bytes test covers the buffers, but not this message. Add a check_metadata("pivco.metadata", ...) test with offset, last_block_len, block_shift, both base offsets, tree_bytes and has_validity all set to non-default values. Without it, a change to a tag or a field type does not fail a test.
There was a problem hiding this comment.
Added test_pivco_metadata_golden with check_metadata("pivco.metadata", ...) and all fields set to non-default values in dae58d112, along with the checked-in encodings/pivco/goldenfiles/pivco.metadata golden file.
| pub use codec::PivcoBlockOffset; | ||
| pub use codec::PivcoOptions; | ||
| pub use codec::block_header_stride; | ||
| pub use codec::estimate_compressed_bits; |
There was a problem hiding this comment.
The crate exports many internals: estimate_compressed_bits, EBITS_TABLE, MAX_SYMS, pow2_sym_and_ebits, PivcoTree (with build, to_bytes, from_bytes), PivcoBlockOffset, block_header_stride, the header-size constants, and the 9-argument PivcoData::try_new. Each export becomes API that later changes must keep. Please keep these pub(crate) unless a caller outside this crate needs them now. Export them in the PR that adds that caller (for example #12104 for estimate_compressed_bits).
There was a problem hiding this comment.
Tightened these exports in dae58d112: PivcoData::try_new is now pub(crate), and estimate_compressed_bits, EBITS_TABLE, MAX_SYMS, pow2_sym_and_ebits, PivcoTree, PivcoBlockOffset, block_header_stride, MAX_BLOCK_VALUES, BLOCK_HEADER_BYTES_NO_EXTRA, and BLOCK_HEADER_BYTES_WITH_EXTRA are no longer re-exported from vortex-pivco here. Only the estimator helpers actually called by vortex-btrblocks are re-exported in #12104 (c1b19b7fb).
Signed-off-by: Will Manning <will@spiraldb.com> Co-Authored-By: Will Manning <will@spiraldb.com>
Signed-off-by: Will Manning <will@spiraldb.com> Co-Authored-By: Will Manning <will@spiraldb.com>
…s-check estimator Signed-off-by: Will Manning <will@spiraldb.com> Co-Authored-By: Will Manning <will@spiraldb.com>
Between fast
BitPacked/FoRand slow archivalPco(VortexCompact), Vortex lacks an integer entropy encoding that keeps fast SIMD scans, sub-microsecond point lookups, selectivefilter/take, directCompareKernelpushdown, and block-parallel GPU decode. Modeled on Marcin Żukowski'spivco-huffman,vortex.pivcosplits non-negative integers intoPow2-Binsymbols (0..150) plus an 8-byte-alignedraw_bitsstream (composing signed integers viaZigZag), and encodes each independent2^block_shift(1,024..=8,192) block as a chunk-level wavelet tree (Huffmanwith collapsed flat subtrees, orOrderPreservingfor range pushdown) whose node bitmaps useRAW,ALL_ZERO/ALL_ONE,SPARSE, or 32-lane static Bernoulli byte-rANS.For reviewers navigating$O(\text{depth})$
encodings/pivco/src/, dependencies flow strictly bottom-up:pow2_bin,simd(neonandx86), andbitmap_ranssit at the base;treebuilds and serializes wavelet trees;codec(encode,decode,spine) handles block compression, L1-resident tail-in-place ping-pong decode, top-downscalar_at, and spine-walking predicates; andarray,compute, andpluginwirevortex.pivcointo theUNSTABLEedition with4B/2B-alignedtree_payloadbuffers and zero-syncSliceReduceready for a follow-up CUDA kernel PR.On 1M-row skewed and power-law integer distributions,
vortex.pivcodecodes at 4.5–51.9 GB/s per core (2.8–3.6×faster than 32-lane symbol rANS), evaluates pushed-down comparisons at 30–940 GB/s, and servesscalar_atin ~250 ns.Authored with AI assistance.