Skip to content

Improve numeric dictionary schemes with bounded probes - #12434

Open
lwwmanning wants to merge 11 commits into
developfrom
wm/numeric-dict-probe
Open

lwwmanning wants to merge 11 commits into
developfrom
wm/numeric-dict-probe

Conversation

@lwwmanning

@lwwmanning lwwmanning commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Replaces #12217. IntDictScheme and DecimalDictScheme previously priced codes with an unpenalized full-chunk formula that ignored frequency skew and selected marginal dictionaries over flat SIMD encodings (FoR, BitPacking, ALP, Pco), while FloatDictScheme and SparseScheme forced eager full-chunk distinct-value hashing in stats even on unique columns, and 1% samples under-rated medium-cardinality dictionaries (1K–30K distinct values in 100K–1M rows) as well as long-run and jump-patched integer columns.

This change unifies numeric dictionary selection behind bounded stratified probes, an aligned pre-trial, tightly gated runner-up verification, improved Delta/RunEnd estimators, and zero eager distinct-value hashing:

  • Pass-2 bounded probes, aligned pre-trial, and trial margin (vortex-compressor): IntDictScheme, FloatDictScheme, and DecimalDictScheme run as a DeferredEstimate::Callback after sampled rivals establish best_so_far. Stratified 2,048- and 8,192-row probes screen inputs via a collision cardinality bound and a histogram lower bound across per-block bit-packing, run-encoding, and integer Pco entropy; multi-chunk inputs (>= 32,768 rows) run an 8,192-row FastLanes-aligned pre-trial that projects exact unsubtracted sample_codes, per-chunk vortex.pco metadata amortization, and unseen singleton values. Surviving candidates build a single frequency-ordered DictArray (<= valid_rows / 2), cascade-compress codes and values, apply a quadratic code-patch penalty (256 bits), peer run-encoding deferral, and a 7% + 64 B savings margin.
  • Gated runner-up verification with per-scheme trial caching (vortex-compressor): When a numeric Dict trial wins, selection verifies the best non-entropy, non-ALP/ALPRD, non-default (AlwaysUse) runner-up within a 4.0x ratio gap (MAX_RUNNER_UP_VERIFY_RATIO_GAP) on the full chunk, suppressing nested verification via CompressorContext::without_runner_up_verification() and storing per-scheme TrialOutputs ranked by override_above_nbytes.
  • Restored Delta/RunEnd estimators, zero eager distinct hashing, and bijective exclusions (vortex-compressor, vortex-btrblocks): Built-in schemes no longer set count_distinct_values: true (SparseScheme screens via the O(1) run_count bound plus majority_candidate). DeltaScheme adds patched and majority_candidate estimation guarded by 4-chunk blocked bit-packing, RunEndScheme uses an aligned-chunk >= 1,024-run callback with full-encode TrialOutput caching (both ordered ahead of IntDictScheme), and single-part DecimalScheme, patchless ALPScheme (when FloatDictScheme is a peer), and OnPairScheme exclude redundant nested IntDictScheme trials.

Across 77 datasets (15 compress-bench + 62 spiraldb/raincloud; full breakdown in #12434 (comment)), vortex-file-compressed shrinks by 3.04% geomean (-1.61% / -63.70 MB total), vortex-compact shrinks by 1.57% geomean (-1.35% / -39.86 MB total), decompression is 19.74% faster total (+0.87% geomean, with statpopgen -34.59%), and compression is +1.03% geomean (+1.40% total; raincloud -3.57% total / -0.59% geomean; local write_compression medians: drifting 17.94 ms, urls 20.41 ms, table 24.37 ms).

Authored with AI assistance.

- Tracking Issue: #11890

Replaces #12217. `IntDictScheme` and `DecimalDictScheme` previously priced codes with an unpenalized full-chunk formula that over-charged power-of-two dictionaries by one bit, ignored frequency skew, and picked marginal dictionaries over fast flat encodings, while `FloatDictScheme` requested full-chunk distinct hashing in `FloatStats` only to evaluate on a 1,024-row sample that under-rated medium-cardinality dictionaries.

This change unifies `IntDictScheme`, `FloatDictScheme`, and `DecimalDictScheme` behind a Pass-2 `DeferredEstimate::Callback` (`numeric_candidate`) modeled on `StringDictScheme` and `BinaryDictScheme`, leaving `vortex-compressor/src/stats` untouched:

- None of the three numeric dictionary schemes request `count_distinct_values: true` (`IntDictScheme` still reuses `IntegerStats` when a sibling scheme such as `SparseScheme` already computed it).
- Multi-stage lower-bound gates (`O(1)` cardinality/run bounds, stratified 2,048- and 8,192-row probes on un-statted floats and decimals, an `O(K)` exact code-histogram gate covering `Sparse`, `BitPacking` v1/v2, `RunEnd`, and entropy coders, plus an aligned 8,192-row `codes` pre-trial above 64K rows) screen out unique and flat-dominated columns before full-chunk materialization.
- Admitted candidates build a frequency-ordered `DictArray` (`<= valid_rows / 2`) in a single hash pass, cascade-compress its children, and cache a measured `TrialOutput` with an override threshold (`TrialOutput::with_override_threshold`) so winners are never encoded twice and marginal trials cannot bypass the indirection margin on sample noise (`Dict(RunEnd/RLE)` is also skipped when `dict_len * 2 > runs`).
- Replacing a compressed rival requires at least 7% relative byte savings (`MIN_RELATIVE_SAVINGS = 0.07`, plus a 64 B metadata floor above 512 B) after a quadratic code patch-density penalty (`PATCH_DENSITY_COST_BITS = 256`).
- `DecimalScheme` excludes `IntDictScheme` on its most-significant part so low-cardinality decimals stay root `Dict` rather than `DecimalByteParts(Dict)`, and low-cardinality floats in default mode now emit root `Dict` (`6,208 B`) instead of `ALP(Dict)`.

On `compress-bench` (7-round interleaved release medians vs `develop`), `vortex-compact` shrinks by 5.8% (`-16.4 MB`) on `CMSprovider`, 4.3% on `TPC-H SF1 partsupp`, 3.3% on `sparse-wide-flat-runs`, 2.3% (`-2.7 MB`) on `HashTags`, 2.1% (`-5.7 MB`) on `Bimbo`, 1.9% on `TPC-H SF1 orders`, and 0.7% on `statpopgen` and `taxi`, while `vortex-file-compressed` shrinks by 3.0% (`-12.2 MB`) on `CMSprovider`, 1.6% (`-3.3 MB`) on `statpopgen`, 1.0% on `Food`, and 0.5% (`-2.2 MB`) on `taxi` (`+1.5%` on `Bimbo` where marginal `<7%` dictionaries are declined) with decompression flat-to-faster across `Bimbo` (`-0.5%`), `statpopgen` (`-1.6%`), `taxi` (`-2.3%`), `orders` (`+0.4%`), and `partsupp` (`-7.2%`).

Authored with AI assistance.

Signed-off-by: Will Manning <will@willmanning.io>
@lwwmanning lwwmanning added the changelog/performance A performance improvement label Nov 30, 2026
@lwwmanning

lwwmanning commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor Author

Updated 5-round release medians across the 15 compress-bench datasets plus 62 spiraldb/raincloud datasets (77 datasets total, commit 227148873d vs develop 8bf02d845c):

Aggregate Summary (77 datasets)

Suite Datasets vortex-file-compressed (develop -> PR) Default Δ (Geomean) vortex-compact (develop -> PR) Compact Δ (Geomean) Compress Time (develop -> PR) Comp Δ (Geomean) Decompress Time (develop -> PR) Decomp Δ (Geomean)
compress-bench 15 1,748,581,260 -> 1,731,667,108 B -0.97% (-16.91 MB, gm -0.61%) 1,258,123,908 -> 1,235,333,380 B -1.81% (-22.79 MB, gm -0.87%) 5470.06 -> 5857.66 ms +7.09% (gm +7.98%) 654.93 -> 486.45 ms -25.72% (gm -3.74%)
spiraldb/raincloud 62 2,216,753,784 -> 2,169,963,144 B -2.11% (-46.79 MB, gm -3.61%) 1,698,741,268 -> 1,681,673,668 B -1.00% (-17.07 MB, gm -1.73%) 6259.32 -> 6035.62 ms -3.57% (gm -0.59%) 267.27 -> 253.74 ms -5.06% (gm +2.01%)
Grand Total 77 3,965,335,044 -> 3,901,630,252 B -1.61% (-63.70 MB, gm -3.04%) 2,956,865,176 -> 2,917,007,048 B -1.35% (-39.86 MB, gm -1.57%) 11729.38 -> 11893.29 ms +1.40% (gm +1.03%) 922.19 -> 740.20 ms -19.74% (gm +0.87%)
  • write_compression (local Divan medians, 227148873d): write_default[drifting] 17.94 ms (fastest 17.90 ms), write_default[urls] 20.41 ms (fastest 20.26 ms), write_default[table] 24.37 ms (fastest 23.88 ms).
  • Design highlights in 227148873d:
    • Unified Pass-2 DeferredEstimate::Callback (numeric_candidate.rs) with 2,048- and 8,192-row stratified collision/histogram probes, an 8,192-row FastLanes-aligned pre-trial on >= 32,768-row chunks (with .with_sampling(), exact unsubtracted sample_codes scaling, per-chunk vortex.pco metadata amortization, and unseen singleton values scaling), single-pass frequency-ordered DictArray construction (<= valid_rows / 2), quadratic code-patch penalty (256 bits), peer run-encoding deferral, unconditionally penalized reported ratio, and 7% + 64 B trial margin.
    • Tightly gated verify_runner_up (MAX_RUNNER_UP_VERIFY_RATIO_GAP = 4.0, skipping entropy, ALP/ALPRD, and AlwaysUse rivals, with nested verification suppressed via CompressorContext::without_runner_up_verification()) backed by per-scheme TrialOutputs ranked by (override_above_nbytes, nbytes).
    • Restored DeltaScheme (patched + majority_candidate estimation guarded by 4-chunk blocked bit-packing) and RunEndScheme (aligned-chunk >= 1,024-run callback via compress_encoded with full-encode TrialOutput caching), ordered ahead of IntDictScheme in session.rs.
    • Zero eager count_distinct_values scans across built-in schemes (SparseScheme uses the O(1) run_count bound + majority_candidate), plus bijective IntDictScheme exclusions on single-part DecimalScheme, patchless ALPScheme (when FloatDictScheme is a peer), and OnPairScheme offsets/tokens.

compress-bench (15 datasets)

Dataset develop size PR size Size Δ develop compact PR compact Compact Δ develop comp PR comp Comp Δ develop decomp PR decomp Decomp Δ
Bimbo 402,551,600 404,799,456 +0.56% 276,854,528 271,083,680 -2.08% 2268.34 ms 2265.60 ms -0.12% 59.40 ms 56.13 ms -5.50%
statpopgen 209,386,284 208,653,540 -0.35% 115,116,324 114,608,508 -0.44% 313.74 ms 539.11 ms +71.83% 477.27 ms 312.18 ms -34.59%
CMSprovider 412,847,664 400,377,696 -3.02% 284,508,584 268,738,496 -5.54% 901.46 ms 957.18 ms +6.18% 30.25 ms 31.50 ms +4.15%
taxi 47,163,380 46,139,204 -2.17% 33,838,692 33,352,092 -1.44% 178.62 ms 220.24 ms +23.30% 6.13 ms 5.92 ms -3.42%
Euro2016 132,322,008 130,261,456 -1.56% 99,772,864 99,767,680 -0.01% 235.25 ms 237.61 ms +1.01% 9.91 ms 8.42 ms -15.01%
Food 37,247,260 36,564,900 -1.83% 23,315,636 23,344,012 +0.12% 137.27 ms 141.10 ms +2.79% 2.46 ms 2.58 ms +4.84%
HashTags 154,110,284 151,836,388 -1.48% 115,722,472 115,664,952 -0.05% 327.29 ms 371.81 ms +13.60% 25.54 ms 24.54 ms -3.92%
Arade 140,919,236 141,001,388 +0.06% 117,623,648 117,473,560 -0.13% 333.39 ms 331.76 ms -0.49% 7.55 ms 7.59 ms +0.51%
sparse-wide-flat-runs 1,176,964 1,176,964 +0.00% 1,114,484 1,078,196 -3.26% 65.92 ms 63.93 ms -3.02% 5.09 ms 4.95 ms -2.87%
sparse-wide-nested-runs 981,748 981,748 +0.00% 948,664 948,664 +0.00% 208.63 ms 196.51 ms -5.81% 6.19 ms 6.03 ms -2.67%
TPC-H SF1 lineitem 136,674,600 136,464,776 -0.15% 122,085,844 122,051,372 -0.03% 309.16 ms 328.19 ms +6.16% 9.13 ms 10.39 ms +13.80%
TPC-H SF1 orders 31,506,412 31,506,396 -0.00% 29,089,152 29,089,152 +0.00% 69.01 ms 76.31 ms +10.57% 2.60 ms 2.54 ms -2.45%
TPC-H SF1 partsupp 24,410,188 24,619,564 +0.86% 20,849,384 20,849,384 +0.00% 51.83 ms 58.45 ms +12.77% 2.34 ms 2.18 ms -6.88%
wide table cols=1000 chunks=1 rows=1000 8,641,816 8,641,816 +0.00% 8,641,816 8,641,816 +0.00% 35.20 ms 34.98 ms -0.62% 5.49 ms 5.96 ms +8.54%
wide table cols=1000 chunks=50 rows=1000 8,641,816 8,641,816 +0.00% 8,641,816 8,641,816 +0.00% 34.93 ms 34.87 ms -0.18% 5.58 ms 5.55 ms -0.56%
Subtotal (15 compress-bench) 1,748,581,260 1,731,667,108 -0.97% 1,258,123,908 1,235,333,380 -1.81% 5470.06 ms 5857.66 ms +7.09% 654.93 ms 486.45 ms -25.72%

spiraldb/raincloud (62 datasets)

Top byte movers in raincloud (>= 500 KB delta in default or compact):

Dataset develop size PR size Size Δ develop compact PR compact Compact Δ Comp Δ Decomp Δ
bi-redfin4 488,896,668 472,889,668 -3.27% (-16.01 MB) 363,727,292 356,311,044 -2.04% (-7.42 MB) +8.57% -7.75%
duckdb-tpcds-sf1-inventory 27,361,220 19,084,484 -30.25% (-8.28 MB) 16,779,868 16,698,076 -0.49% (-0.08 MB) -1.98% -12.92%
uci-individual-household-electric-power-consumption 15,381,944 12,733,112 -17.22% (-2.65 MB) 9,106,936 9,106,552 -0.00% (-0.00 MB) -1.77% +6.13%
openpowerlifting 144,347,000 141,804,168 -1.76% (-2.54 MB) 100,709,928 97,200,008 -3.49% (-3.51 MB) -13.60% -18.33%
duckdb-tpcds-sf1-catalog_sales 70,008,516 67,523,212 -3.55% (-2.49 MB) 59,468,068 59,282,252 -0.31% (-0.19 MB) -9.68% -13.22%
duckdb-tpcds-sf1-store_sales 102,751,100 100,308,484 -2.38% (-2.44 MB) 82,274,508 81,644,708 -0.77% (-0.63 MB) +3.92% +20.25%
bi-romance 362,305,724 360,045,868 -0.62% (-2.26 MB) 300,716,564 300,087,516 -0.21% (-0.63 MB) -19.70% -16.55%
covid-world-vaccination-progress 7,245,076 5,740,756 -20.76% (-1.50 MB) 1,746,852 1,746,852 +0.00% (+0.00 MB) +19.12% +61.85%
bi-citymaxcapita 110,418,740 109,197,012 -1.11% (-1.22 MB) 83,481,240 83,128,160 -0.42% (-0.35 MB) +7.32% -11.66%
imdb-job-title 94,130,796 93,023,564 -1.18% (-1.11 MB) 84,760,600 84,728,168 -0.04% (-0.03 MB) -12.82% +0.72%
bi-hatred 106,513,640 105,491,384 -0.96% (-1.02 MB) 82,729,752 82,605,256 -0.15% (-0.12 MB) +4.41% -16.29%
uber-pickups-in-new-york-city 3,033,100 2,327,292 -23.27% (-0.71 MB) 1,843,736 1,855,352 +0.63% (+0.01 MB) +18.45% +52.57%
imdb-job-movie-companies 12,635,312 11,940,336 -5.50% (-0.69 MB) 7,930,432 7,844,464 -1.08% (-0.09 MB) -3.92% +1.61%
stackoverflow-postlinks 103,158,112 102,553,360 -0.59% (-0.60 MB) 89,122,704 88,954,840 -0.19% (-0.17 MB) +11.35% -0.24%
bi-yalelanguages 115,446,464 115,116,648 -0.29% (-0.33 MB) 75,243,728 73,734,120 -2.01% (-1.51 MB) -5.87% -7.10%
goodbooks-10k 23,852,056 23,840,344 -0.05% (-0.01 MB) 16,261,992 15,442,120 -5.04% (-0.82 MB) +0.79% +6.45%
airquality 8,841,288 9,566,192 +8.20% (+0.72 MB) 4,334,772 4,333,004 -0.04% (-0.00 MB) +2.64% +14.40%
Full 62-dataset spiraldb/raincloud table (sorted by default byte Δ)
Dataset develop size PR size Size Δ develop compact PR compact Compact Δ develop comp PR comp Comp Δ develop decomp PR decomp Decomp Δ
bi-redfin4 488,896,668 472,889,668 -3.27% 363,727,292 356,311,044 -2.04% 594.64 ms 645.61 ms +8.57% 44.67 ms 41.21 ms -7.75%
duckdb-tpcds-sf1-inventory 27,361,220 19,084,484 -30.25% 16,779,868 16,698,076 -0.49% 185.81 ms 182.13 ms -1.98% 4.48 ms 3.90 ms -12.92%
uci-individual-household-electric-power-consumption 15,381,944 12,733,112 -17.22% 9,106,936 9,106,552 -0.00% 169.12 ms 166.13 ms -1.77% 2.28 ms 2.42 ms +6.13%
openpowerlifting 144,347,000 141,804,168 -1.76% 100,709,928 97,200,008 -3.49% 705.23 ms 609.29 ms -13.60% 24.54 ms 20.04 ms -18.33%
duckdb-tpcds-sf1-catalog_sales 70,008,516 67,523,212 -3.55% 59,468,068 59,282,252 -0.31% 187.55 ms 169.40 ms -9.68% 7.96 ms 6.90 ms -13.22%
duckdb-tpcds-sf1-store_sales 102,751,100 100,308,484 -2.38% 82,274,508 81,644,708 -0.77% 198.29 ms 206.07 ms +3.92% 7.48 ms 9.00 ms +20.25%
bi-romance 362,305,724 360,045,868 -0.62% 300,716,564 300,087,516 -0.21% 931.23 ms 747.77 ms -19.70% 30.77 ms 25.68 ms -16.55%
covid-world-vaccination-progress 7,245,076 5,740,756 -20.76% 1,746,852 1,746,852 +0.00% 14.04 ms 16.73 ms +19.12% 1.08 ms 1.74 ms +61.85%
bi-citymaxcapita 110,418,740 109,197,012 -1.11% 83,481,240 83,128,160 -0.42% 232.13 ms 249.12 ms +7.32% 10.20 ms 9.01 ms -11.66%
imdb-job-title 94,130,796 93,023,564 -1.18% 84,760,600 84,728,168 -0.04% 207.00 ms 180.46 ms -12.82% 8.58 ms 8.64 ms +0.72%
bi-hatred 106,513,640 105,491,384 -0.96% 82,729,752 82,605,256 -0.15% 218.96 ms 228.62 ms +4.41% 11.33 ms 9.48 ms -16.29%
uber-pickups-in-new-york-city 3,033,100 2,327,292 -23.27% 1,843,736 1,855,352 +0.63% 18.25 ms 21.61 ms +18.45% 0.68 ms 1.03 ms +52.57%
imdb-job-movie-companies 12,635,312 11,940,336 -5.50% 7,930,432 7,844,464 -1.08% 79.12 ms 76.02 ms -3.92% 1.42 ms 1.45 ms +1.61%
stackoverflow-postlinks 103,158,112 102,553,360 -0.59% 89,122,704 88,954,840 -0.19% 120.03 ms 133.65 ms +11.35% 3.31 ms 3.30 ms -0.24%
world-energy-consumption 6,479,276 6,034,292 -6.87% 1,910,276 1,918,300 +0.42% 21.66 ms 24.43 ms +12.77% 3.61 ms 5.45 ms +50.68%
imdb-job-movie-keyword 11,059,044 10,671,876 -3.50% 8,672,388 8,327,556 -3.98% 63.42 ms 59.71 ms -5.85% 1.35 ms 1.16 ms -14.30%
uci-beijing-multi-site-air-quality 5,214,476 4,856,188 -6.87% 3,478,284 3,426,028 -1.50% 25.98 ms 34.34 ms +32.18% 1.91 ms 2.05 ms +7.14%
duckdb-tpcds-sf1-web_sales 33,476,852 33,138,932 -1.01% 29,365,204 29,346,596 -0.06% 74.97 ms 80.96 ms +8.00% 3.35 ms 3.51 ms +4.67%
bi-yalelanguages 115,446,464 115,116,648 -0.29% 75,243,728 73,734,120 -2.01% 770.83 ms 725.61 ms -5.87% 20.21 ms 18.77 ms -7.10%
appian-credit-card 50,973,812 50,664,004 -0.61% 32,649,964 32,441,180 -0.64% 82.60 ms 104.85 ms +26.95% 3.83 ms 3.87 ms +0.97%
ampds-whe 10,457,664 10,167,712 -2.77% 5,867,720 5,867,720 +0.00% 39.56 ms 40.76 ms +3.05% 1.18 ms 1.34 ms +14.15%
bi-corporations 58,476,868 58,204,868 -0.47% 46,595,116 46,553,172 -0.09% 210.43 ms 196.24 ms -6.75% 14.27 ms 12.29 ms -13.86%
appian-address 27,831,424 27,568,176 -0.95% 25,094,272 24,916,296 -0.71% 47.15 ms 52.18 ms +10.67% 2.19 ms 3.29 ms +50.19%
green_tripdata_2025 10,096,012 9,902,132 -1.92% 6,948,396 6,694,492 -3.65% 45.54 ms 44.43 ms -2.43% 2.25 ms 2.17 ms -3.36%
tpcgen-rs-tpch-sf1-part 4,001,096 3,811,160 -4.75% 3,085,612 3,085,612 +0.00% 15.75 ms 15.87 ms +0.80% 1.44 ms 1.39 ms -2.92%
anthropic-economic-index 5,003,392 4,856,488 -2.94% 2,639,120 2,635,080 -0.15% 33.49 ms 34.11 ms +1.84% 1.05 ms 1.14 ms +8.57%
appian-customer 13,648,600 13,509,888 -1.02% 10,661,128 10,579,360 -0.77% 33.55 ms 40.07 ms +19.44% 1.68 ms 2.04 ms +21.45%
oasst1 35,344,740 35,216,548 -0.36% 24,054,428 24,044,540 -0.04% 107.44 ms 108.86 ms +1.32% 4.78 ms 4.60 ms -3.71%
kepler-exoplanet-search-results 3,019,856 2,916,592 -3.42% 2,058,264 2,015,256 -2.09% 22.52 ms 25.32 ms +12.42% 2.36 ms 2.80 ms +18.50%
bi-iglocations1 2,104,488 2,010,040 -4.49% 1,515,160 1,512,872 -0.15% 18.02 ms 14.96 ms -16.99% 1.08 ms 1.26 ms +16.99%
appian-order 45,290,968 45,198,024 -0.21% 32,413,716 32,413,716 +0.00% 194.41 ms 221.56 ms +13.97% 4.56 ms 4.64 ms +1.71%
duckdb-tpcds-sf1-date_dim 440,952 371,656 -15.72% 123,184 114,192 -7.30% 11.20 ms 11.60 ms +3.62% 1.72 ms 1.59 ms -7.20%
uci-cdc-diabetes-health-indicators 1,321,984 1,260,352 -4.66% 1,288,992 1,063,264 -17.51% 15.98 ms 16.05 ms +0.48% 0.54 ms 0.74 ms +36.90%
duckdb-tpcds-sf1-time_dim 308,272 251,888 -18.29% 85,784 83,864 -2.24% 7.02 ms 6.93 ms -1.32% 0.71 ms 0.77 ms +8.24%
uci-human-activity-recognition-using-smartphones 24,313,844 24,276,812 -0.15% 18,931,740 18,931,172 -0.00% 69.09 ms 66.23 ms -4.13% 8.14 ms 9.39 ms +15.32%
duckdb-tpcds-sf1-item 1,180,924 1,147,932 -2.79% 1,002,436 1,002,708 +0.03% 19.94 ms 19.53 ms -2.08% 0.96 ms 1.05 ms +9.14%
uci-default-of-credit-card-clients 984,080 970,104 -1.42% 745,168 715,096 -4.04% 3.51 ms 4.32 ms +23.16% 0.39 ms 0.47 ms +19.51%
goodbooks-10k 23,852,056 23,840,344 -0.05% 16,261,992 15,442,120 -5.04% 76.45 ms 77.05 ms +0.79% 0.93 ms 0.99 ms +6.45%
uci-diabetes-130-us-hospitals 2,045,360 2,034,408 -0.54% 1,564,504 1,529,264 -2.25% 20.25 ms 22.52 ms +11.20% 1.97 ms 2.12 ms +7.31%
duckdb-tpcds-sf1-catalog_page 470,956 461,588 -1.99% 356,608 357,064 +0.13% 13.93 ms 12.10 ms -13.12% 0.62 ms 0.56 ms -10.18%
duckdb-tpcds-sf1-household_demographics 12,804 9,812 -23.37% 8,388 5,900 -29.66% 1.34 ms 1.38 ms +2.89% 0.17 ms 0.16 ms -5.01%
appian-tax-record 19,752,272 19,752,272 +0.00% 18,136,888 18,136,888 +0.00% 34.10 ms 31.43 ms -7.82% 0.89 ms 0.95 ms +6.87%
duckdb-tpcds-sf1-call_center 29,584 29,584 +0.00% 24,400 24,400 +0.00% 2.45 ms 2.12 ms -13.78% 0.51 ms 0.46 ms -9.84%
duckdb-tpcds-sf1-income_band 3,708 3,708 +0.00% 3,516 3,516 +0.00% 0.22 ms 0.19 ms -13.85% 0.07 ms 0.07 ms -8.28%
duckdb-tpcds-sf1-promotion 36,784 36,784 +0.00% 26,640 26,640 +0.00% 3.57 ms 3.55 ms -0.73% 0.30 ms 0.31 ms +4.32%
duckdb-tpcds-sf1-reason 5,544 5,544 +0.00% 4,312 4,312 +0.00% 0.57 ms 0.55 ms -4.09% 0.07 ms 0.06 ms -2.72%
duckdb-tpcds-sf1-ship_mode 8,660 8,660 +0.00% 6,980 6,812 -2.41% 0.79 ms 0.73 ms -7.69% 0.12 ms 0.10 ms -12.83%
duckdb-tpcds-sf1-store 25,228 25,228 +0.00% 19,972 19,972 +0.00% 1.75 ms 1.59 ms -9.15% 0.32 ms 0.32 ms +0.32%
duckdb-tpcds-sf1-warehouse 11,436 11,436 +0.00% 10,396 10,396 +0.00% 0.98 ms 0.85 ms -12.39% 0.17 ms 0.16 ms -3.92%
duckdb-tpcds-sf1-web_page 17,716 17,716 +0.00% 12,996 12,788 -1.60% 1.19 ms 1.16 ms -2.39% 0.19 ms 0.20 ms +3.10%
tpcgen-rs-tpch-sf1-supplier 541,564 541,564 +0.00% 471,540 471,540 +0.00% 8.40 ms 7.94 ms -5.42% 0.49 ms 0.47 ms -3.13%
duckdb-tpcds-sf1-web_site 31,324 31,340 +0.05% 22,084 21,900 -0.83% 3.51 ms 2.00 ms -42.86% 0.39 ms 0.36 ms -6.91%
tpcgen-rs-tpch-sf1-customer 7,970,752 7,972,704 +0.02% 7,166,484 7,166,484 +0.00% 20.31 ms 21.68 ms +6.75% 2.30 ms 2.46 ms +7.04%
duckdb-tpcds-sf1-customer_address 718,544 727,824 +1.29% 534,484 537,116 +0.49% 11.08 ms 9.84 ms -11.21% 1.12 ms 1.11 ms -1.27%
duckdb-tpcds-sf1-customer_demographics 1,213,508 1,230,204 +1.38% 411,556 394,468 -4.15% 57.44 ms 55.61 ms -3.19% 1.39 ms 1.40 ms +0.59%
duckdb-tpcds-sf1-web_returns 3,512,344 3,533,320 +0.60% 3,110,416 3,116,896 +0.21% 7.41 ms 7.25 ms -2.20% 1.50 ms 1.30 ms -13.23%
duckdb-tpcds-sf1-customer 4,084,304 4,108,040 +0.58% 3,406,004 3,409,020 +0.09% 18.39 ms 14.73 ms -19.87% 2.11 ms 1.71 ms -18.63%
duckdb-tpcds-sf1-catalog_returns 7,071,460 7,100,556 +0.41% 5,970,084 5,970,084 +0.00% 15.35 ms 18.20 ms +18.57% 2.31 ms 2.08 ms -9.99%
duckdb-tpcds-sf1-store_returns 11,144,768 11,200,944 +0.50% 9,734,288 9,762,664 +0.29% 20.31 ms 25.48 ms +25.44% 1.54 ms 1.48 ms -3.72%
120-years-of-olympic-history-athletes-and-results 4,418,472 4,474,728 +1.27% 3,466,852 3,462,604 -0.12% 35.08 ms 32.59 ms -7.10% 1.61 ms 1.77 ms +10.00%
uci-online-retail-ii 6,271,312 6,453,632 +2.91% 4,846,552 4,832,376 -0.29% 70.94 ms 64.48 ms -9.11% 2.42 ms 1.89 ms -21.80%
airquality 8,841,288 9,566,192 +8.20% 4,334,772 4,333,004 -0.04% 38.07 ms 39.07 ms +2.64% 1.45 ms 1.66 ms +14.40%
Subtotal (62 raincloud) 2,216,753,784 2,169,963,144 -2.11% 1,698,741,268 1,681,673,668 -1.00% 6259.32 ms 6035.62 ms -3.57% 267.27 ms 253.74 ms -5.06%

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-02T06:06:54.462378Z 2271488 New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@lwwmanning lwwmanning changed the title Select numeric dictionaries with bounded probes and trial margins Select numeric dictionaries with bounded probes Nov 30, 2026
@vortex-roborev-bot

vortex-roborev-bot Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

roborev: Combined Review (2271488)

Verdict: Changes require fixes for 1 finding.

Low

  • vortex-compressor/src/builtins/dict/numeric_candidate.rs:737-749: The probe's cardinality bound rejects Dict for columns where repeats are far apart. With zero collisions, the bound for a 2,048-row probe is rows^2 / 8, about 524K. That is above max_entries for any chunk under roughly 1M rows, and the 16-row stratified slices miss distant repeats. For example, an ids ++ ids column (about 600K rows, 300K distinct) skips IntDict/FloatDict even though Dict would be about 20% smaller. It also blocks the ALP(IntDict) fallback. Output stays correct.

    Fix: Apply the collision-based rejection only above a minimum collision count and let the aligned pre-trial and histogram gates decide otherwise, keeping head_probe_rejects_unique_column_without_distinct_stats passing and adding an ids ++ ids regression case.


Reviewers: claude-code | Synthesis: claude-code, 8s, ~$0.04 | Total: 4m25s, ~$2.37

@vortex-roborev-bot vortex-roborev-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line comments for the roborev review of 991542d. The roborev PR comment has the full review.

Comment on lines +184 to +200
let mut ctx = SESSION.create_execution_ctx();
// 32,768 rows with 2,048 distinct values (2% hot pair + 98% skewed vs tail): 1,024-row
// sampling alone would see >50% distinct, while the bounded probe + trial selects `Dict`.
let skewed_floats = PrimitiveArray::from_iter((0..32_768usize).map(|i| {
if i % 64 == 0 {
1_000.25 + (i % 2_046) as f64 * 0.5
} else if i % 2 == 0 {
12.5
} else {
25.0
}
}))
.into_array();
let compressed_float =
CascadingCompressor::new(vec![&FloatDictScheme, &ALPScheme, &BITPACKING])
.compress(&skewed_floats, &mut ctx)?;
assert!(compressed_float.is::<Dict>());

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Low: skewed_medium_cardinality_selects_dict_while_dense_uniform_stays_flat does not cover the medium-cardinality case it describes. Tail values appear only on rows where i % 64 == 0 (512 rows), which gives about 514 distinct values instead of the 2,048 the comment claims. The column is about 98.5% the two hot values. A 1,024-row sample would see few distinct values, so the old Sample path would probably also pick Dict.

Fix: Build a float column whose 1,024-row sample is more than 50% distinct but the full chunk is not (for example, thousands of distinct values each repeated many times). Assert that FloatDictScheme beats ALPScheme, and correct the comment's distinct count.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 991542d1b1

ℹ️ 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".

Comment on lines +128 to +129
excluded: IntDictScheme.id(),
children: ChildSelection::One(DecimalBytePartsSlots::MSP),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve MSP dictionaries inside decimal dictionaries

When DecimalDictScheme wins, its decimal values child can itself be encoded by DecimalScheme; this unconditional descendant rule then excludes IntDictScheme from that nested values array's MSP. That contradicts DecimalDictScheme's existing policy of excluding integer dictionaries only from codes so that distinct decimal values sharing a small set of MSPs can still compress well. On such columns this can enlarge the measured/final root dictionary or cause it to lose selection, so scope this exclusion to a top-level DecimalScheme that is actually competing with a sibling DecimalDictScheme, rather than applying it beneath an already-selected decimal dictionary.

Useful? React with 👍 / 👎.

Comment on lines +426 to +429
let by_net = if penalized_nbytes >= 512 {
penalized_nbytes.saturating_add(MIN_NET_BYTES_SAVED)
} else {
penalized_nbytes

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Apply the byte floor based on the winner size

When the penalized trial is below 512 bytes but the actual winner is at least 512 bytes, this condition drops the 64-byte floor even though clears_margin applies it based on the rival's size. For example, a 480-byte trial against a 520-byte winner is rejected by clears_margin because it saves only 40 bytes, but the trial was already cached and this function sets its override threshold to 516, so the cascade replaces the 520-byte winner anyway. Evaluate the non-tiny condition against the actual winner at override time, rather than against the trial size, so cached trials cannot bypass the required metadata margin.

Useful? React with 👍 / 👎.

Comment thread vortex-compressor/src/compressor/mod.rs Outdated
Comment on lines +89 to +91
let has_entropy_scheme = schemes
.iter()
.any(|s| s.scheme_name().ends_with(".pco") || s.scheme_name().ends_with(".zstd"));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Ignore variable-width Zstd for numeric entropy gates

In a compressor configured with the BtrBlocks zstd feature but without pco, the registered vortex.string.zstd and vortex.binary.zstd schemes make this flag true even though their matches implementations accept only UTF-8 and binary arrays and therefore cannot compress numeric dictionary codes. The numeric admission gates consequently price an unavailable entropy-coded alternative and can let high-cardinality integer, float, or decimal columns proceed through a full hash pass and cascade trial that the bounded gates would otherwise reject. Determine entropy availability for numeric codes specifically, rather than matching any scheme name ending in .zstd.

Useful? React with 👍 / 👎.

@robert3005

Copy link
Copy Markdown
Contributor

Interestingly I have similar thing in #11307

@lwwmanning lwwmanning left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Posted by Claude Opus 5.5 on Will's behalf.

I reviewed 991542d with fresh eyes. I found no path that gives a wrong array or a panic, and the wire format is unchanged. It is not ready to merge yet.

  1. The CI failure is a real regression. DecimalScheme now excludes IntDictScheme on the MSP for every decimal, not only for the low-cardinality ones that DecimalDictScheme takes. In rejected_decimal_keeps_nested_int_dict, the decimal is unique, so root Dict is not an option. Its MSP has 4 distinct values, and it now gets FoR with 5-bit BitPacking (10.24 kB) instead of a nested Dict. Please apply the exclusion only when the root dictionary is a real candidate, or drop it.

  2. numeric_candidate.rs has about 1,060 production lines, against 444 for bytes_candidate.rs. Much of it can shrink:

    • Three lower-bound functions model the same encodings: sparse, BitPacking, RLE, entropy and v2. One function over a histogram and a scale factor would cover all three.
    • integer_stats_histogram has 8 identical match arms.
    • encode_slice_bounded repeats encode_sorted_codes in dict/mod.rs. The callback still calls integer::dictionary_encode too, so two integer encoders remain.
    • KEEP_NUMERATOR and KEEP_DENOMINATOR repeat MIN_RELATIVE_SAVINGS.
  3. The compressor now matches encoding internals by name. has_entropy_scheme matches any name that ends in .zstd, so vortex.string.zstd loosens the integer gates. The gates also compare against "fastlanes.rle" and walk slots named patch_indices and child. A renamed slot would turn a gate off with no error.

  4. The gates and constants have no tests. These include the 0.6 factor, the 3/4 slack, the 25% run gate and the 64 B and 512 B floors. Hegel tests that compare the chosen size with a forced flat encoding would cover them. The comment on skewed_medium_cardinality_selects_dict_while_dense_uniform_stays_flat claims 2,048 distinct values. The fixture has 514, and a 1,024-row sample sees about 18, so the test does not exercise sample under-rating.

  5. The description reports sizes but not compression time. Each admitted column now runs a full-chunk cascade trial during estimation. Please add the compress-time column from the same run.

…lusions

Drop count_distinct_values from SparseScheme in favor of an O(1) run-transition bound plus PrimitiveArray::majority_candidate, and exclude IntDictScheme on patchless ALP and single-part Decimal child slots while keeping patched ALP and multi-part Decimal MSP eligible.

Co-Authored-By: Antigravity <noreply@google.com>
Signed-off-by: Will Manning <will@willmanning.io>
@codspeed

codspeed Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Merging this PR will improve performance by 15.01%

2 warnings

⚠️ Walltime results may be unreliable

Some benchmarks used the Walltime instrument outside CodSpeed Macro Runners, which can make the results inconsistent.

Learn more about Macro Runners

See affected benchmarks

⚠️ 1 benchmark is dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

⚡ 5 improved benchmarks
✅ 2184 untouched benchmarks
⏩ 136 skipped benchmarks1

Performance Changes

Mode Benchmark BASE HEAD Efficiency
⚡ Walltime infallible_bool_neon[i32, PerRowPerRow] 4.1 µs 3.3 µs +21.55%
⚡ Walltime infallible_bool_constant_neon[ConstantPerRow] 4.8 µs 4.1 µs +16.6%
⚡ Walltime infallible_bool_constant_neon[PerRowConstant] 4.6 µs 4 µs +14.31%
⚡ Walltime deferred_bool_constant_neon[ConstantPerRow] 4.5 µs 4 µs +11.78%
⚡ CPU Simulation write_default[drifting] 529.4 ms 476.4 ms +11.13%

Tip

Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.


Comparing wm/numeric-dict-probe (2271488) with develop (ad754a9)

Open in CodSpeed

Footnotes

  1. 136 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 75351f7720

ℹ️ 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".

Comment on lines +258 to +260
if span == 0 {
return Ok(EstimateVerdict::Skip);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Let dictionaries handle constants when constant encoding is disabled

When with_allow_constant(false) is used, or when a nullable one-value column is compressed with with_allow_masked(false), the compressor's constant fast path intentionally declines the column, but this unconditional span == 0 return also prevents IntDictScheme from trying it. A repeated i64 value can otherwise become a one-entry dictionary with byte-sized codes (and the existing validity), so this leaves a substantially larger canonical array even though the configuration only prohibited Constant/Masked encodings, not Dict.

Useful? React with 👍 / 👎.

Comment on lines +270 to +272
&& let Some(head) = probe_array(data, &mask, HEAD_PROBE_RANGE_SIZE)
&& (head.is_unique()
|| head.exceeds_cardinality_bound(max_entries)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Do not treat a unique probe as proof the column is unique

For a large column whose values repeat only in distant regions, the deterministic 2,048-row probe can contain no duplicate even though the full distinct count is within the dictionary limit—for example, two large halves containing the same random i64 values in different orders. This branch then skips before the bounded full hash/trial, so a dictionary whose codes would bit-pack and beat the flat representation is never considered; sample uniqueness is not a safe hard rejection criterion.

Useful? React with 👍 / 👎.

Comment on lines +76 to +78
vec![DescendantExclusion {
excluded: IntDictScheme.id(),
children: ChildSelection::One(PATCHLESS_ENCODED_SLOT),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep IntDict available when FloatDict is not configured

In compressors that register ALPScheme and IntDictScheme without FloatDictScheme—a supported pattern with BtrBlocksCompressorBuilder::empty()—this exclusion removes the only dictionary path for patchless floats. Low-cardinality floats whose ALP integers span a wide range can therefore remain wide or only bit-pack poorly, whereas the previous ALP(IntDict) cascade used compact codes; only apply this exclusion when a parent-level float dictionary is actually available to replace it.

Useful? React with 👍 / 👎.

@lwwmanning lwwmanning left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Posted by Claude Opus 5.5 on Will's behalf.

Follow-up on 75351f7. Point 1 from my last review is fixed. The multi-part DecimalByteParts MSP now has its own slot, so IntDict can compress it again, and the new nesting test covers that case. The Rust test failures are gone. The two CodSpeed failures are infrastructure: the CodSpeed installer returned an expired token error.

I checked the new SparseScheme logic and found no bug. The run-count bound is sound because runs count only valid values, and nulls do not break a run. The strict-majority check before the fill also looks right.

Points 2, 3 and 4 are still open. This commit also adds about 270 lines, so the size concern from point 2 has grown. The SparseScheme change is a separate speedup. If it is needed here, please say why in the description. The name matching in has_entropy_scheme, the untested constants and the 2,048 comment are unchanged.

Skip IntDictScheme when integer codes compress as RunEnd/RLE before caching TrialOutput so direct RunEnd/RLE (which cascades values to IntDict/FoR/Pco) is never overridden, gate MIN_NET_BYTES_SAVED on uncompressed input size rather than rival size, and skip IntDict on multi-byte integers with tiny spans (< 16) where code bit-width matches FoR.

Co-Authored-By: Antigravity <noreply@google.com>
Signed-off-by: Will Manning <will@willmanning.io>

@lwwmanning lwwmanning left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Posted by Claude Opus 5.5 on Will's behalf.

Follow-up on 2d3296f. I found no bug. Moving the run-encoded skip before the TrialOutput cache is right, because a rejected Dict(RunEnd) trial can no longer override a direct RunEnd winner. The new test covers both new gates.

One question on the narrow-span gate. It skips IntDict when the code bit width is at least the bit width of max - min. That comparison already shows FoR packs at least as tightly, for any span and any integer width. Why also require span < 16 and a multi-byte type? If there is no reason, dropping both removes two more constants to tune and test.

The CodSpeed failure is the same installer problem as before. My earlier points on size, name matching and untested constants still apply.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2d3296f518

ℹ️ 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".

Comment on lines +128 to +131
fn descendant_exclusions(&self) -> Vec<DescendantExclusion> {
vec![DescendantExclusion {
excluded: IntDictScheme.id(),
children: ChildSelection::One(DecimalBytePartsSlots::MSP),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Retain MSP dictionaries when DecimalDict is unavailable

When DecimalDictScheme is excluded—as supported by the existing low_cardinality_decimal_without_dict_scheme_keeps_byte_parts configuration—this unconditional rule still removes IntDictScheme from a single-part decimal's MSP child, even though no root dictionary can replace it. Repeated i64-backed decimals therefore remain as wide byte-part values instead of the previous compact DecimalByteParts(IntDict) representation; apply this exclusion only when a parent-level decimal dictionary is actually available.

Useful? React with 👍 / 👎.

Comment on lines +312 to +315
if let Some(span) = int_span
&& span < 16
&& array.dtype().element_size().unwrap_or(1) > 1
&& min_code_bit_width(dict_len) >= (u64::BITS - span.leading_zeros())

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Retain IntDict when FoR packing is unavailable

When a custom compressor includes IntDictScheme but omits either FoR or BitPacking, this unconditional tiny-span rejection assumes a direct encoding that the compressor cannot produce. For example, a repeated i64 column cycling through four adjacent values has span == 3 and equal code/span bit widths, so it now stays as an 8-byte primitive even though a four-entry dictionary with byte codes would be much smaller; gate this shortcut on the required direct schemes being available.

Useful? React with 👍 / 👎.

Comment on lines +341 to +343
if let Some(runs) = run_encoded_runs
&& (scheme.id() == IntDictScheme.id() || dict_len.saturating_mul(2) > runs)
{

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep run-coded dictionaries when no direct rival is registered

When a custom compressor registers FloatDictScheme and IntRLEScheme but omits FloatRLEScheme, run-heavy floats can produce a measured Dict(RLE) that is far smaller than the input, yet this branch discards it solely because dict_len * 2 > runs. The integer RLE scheme that compressed the dictionary codes cannot operate directly on the float input, so there is no direct RLE winner to prefer; only apply this rejection when a corresponding root-level run encoding is actually eligible (the same issue applies to decimals without a direct decimal alternative).

Useful? React with 👍 / 👎.

@vortex-roborev-bot vortex-roborev-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line comments for the roborev review of 2d3296f. The roborev PR comment has the full review.

Comment on lines +202 to +216
// 32,768 rows with 2,048 distinct values (2% hot pair + 98% skewed vs tail): 1,024-row
// sampling alone would see >50% distinct, while the bounded probe + trial selects `Dict`.
let skewed_floats = PrimitiveArray::from_iter((0..32_768usize).map(|i| {
if i % 64 == 0 {
1_000.25 + (i % 2_046) as f64 * 0.5
} else if i % 2 == 0 {
12.5
} else {
25.0
}
}))
.into_array();
let compressed_float =
CascadingCompressor::new(vec![&FloatDictScheme, &ALPScheme, &BITPACKING])
.compress(&skewed_floats, &mut ctx)?;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Low: skewed_medium_cardinality_selects_dict_while_dense_uniform_stays_flat doesn't test the medium-cardinality case its comment describes. Tail values only appear when i % 64 == 0, so the column has about 514 distinct values (not 2,048) and is about 98.5% the two hot values. The old DeferredEstimate::Sample path would likely pick Dict here too, so the test doesn't show that the bounded probe and trial fix the sampling under-rating.

Fix: Build a float column whose 1,024-row sample is over 50% distinct while the full chunk is well under 50%, assert that FloatDictScheme beats ALPScheme on it, and correct the distinct count in the comment.

Comment on lines +102 to +104
/// Minimum byte savings required on non-tiny rivals (`>= 512` B) to amortize serialized
/// `vortex.dict` FlatBuffer metadata.
const MIN_NET_BYTES_SAVED: u64 = 64;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Low: The MIN_NET_BYTES_SAVED doc says the 64 B floor applies to rivals of at least 512 B, but that's no longer the condition. clears_margin and override_threshold_bytes now check uncompressed_nbytes >= 512, not the rival's size.

Fix: Change the doc to say the floor applies when the uncompressed input is at least 512 B and a compressed rival exists.

Copy link
Copy Markdown
Contributor Author

Posted by Claude Mythos 5.2 on Will's behalf. This is an AI review of 2d3296f. It is not Will's own text.

Verdict

The change is correct as far as I can find. No path returns wrong data or panics, and all 1,010 tests pass locally (vortex-compressor and vortex-btrblocks, all features). It is not proportional yet. About 450 of the 1,310 production lines in numeric_candidate.rs change no output and almost no timing in my runs. One gate rejects a dictionary that is 2.8× smaller. Most new tests do not pin the code that they name.

Method: I put local environment-variable switches around each gate (not pushed). Then I ran both test suites and a release-mode timing harness. The harness covers 8 synthetic column shapes at 1M and 50,000 rows, in the default and compact presets. Timings are the minimum of 7 runs on a 2-core VM, with about 15% run-to-run noise.

1. The narrow-span gate rejects a 2.8× smaller dictionary

Input: 1M i32, values 14 and 15 at 49.5% each, 1% spread over 0..=13, default preset.

Output Bytes
PR fastlanes.bitpacked.v2, 4 bits 500,224
PR, gate off vortex.dict, 1-bit codes, 10,122 patches 177,684

develop also writes 500,224 B, so this is a lost win and not a regression. The gate assumes that FoR matches the dictionary when the code width equals the span width. Frequency-ordered codes with patches break that assumption. int_dict_defers_to_runend_and_narrow_for still passes with the gate deleted, because the 7% margin already keeps its fixture flat. Delete the gate.

2. Most of the screening code has no measurable effect

Screening pays as a group. Two parts carry it: the head-probe cardinality bound and the aligned pre-trial.

1M rows, default preset, ms develop PR no probes no pre-trial no admit_*
i64 unique 45.9 3.0 39.7 3.2 3.2
i64 drifting walk 39.0 8.7 7.4 58.5 9.4
i32 dense 0..1000 2.9 2.3 2.3 10.4 2.3
f64 unique 42.2 3.1 20.5 3.1 3.2

The three admit_* functions (about 300 lines) move one timing of 32 beyond noise: compact preset, drifting i64, 50,000 rows, 0.82 ms to 1.55 ms. Output bytes are identical in all 32 runs with every screen off.

Specific cuts:

  • In admit_cardinality_only and admit_exact_histogram, the per-block term is never larger than the plain, Sparse, and global bit-packing terms. Each row costs bw bits in the per-block term and at least bw bits in the others. I ran 4,000 random histograms and found 0 exceptions. Those three terms never change the min. admit_probe has the same structure.
  • No built-in scheme sets count_distinct_values now. The precomputed_int_dict branch, integer_stats_histogram (8 identical arms), and integer::dictionary_encode are unreachable from built-in schemes. No test reaches that branch (I put a panic! in it and nothing failed).
  • is_unique() equals the collisions == 0 branch of exceeds_cardinality_bound.
  • encode_slice_bounded writes its insert loop twice and its remap loop three times.
  • KEEP_NUMERATOR and KEEP_DENOMINATOR restate MIN_RELATIVE_SAVINGS. The exact gates charge max_bw + 16 bits per run and the probe gate charges max_bw + 8, with no stated reason.

One function that returns min(per_block, rle, entropy) over a histogram and a scale factor replaces all three gates.

  • [open] Does any benchmark dataset need the admit_* gates below 65,536 rows?
  • [open] No test fails with PATCH_DENSITY_COST_BITS at 0. Which measurement set 256?

3. Tests

I disabled eight mechanisms together. The set is both probes, the pre-trial, the admit_* gates, the cardinality bound, the span == 1 shortcut, the narrow-span gate, the patch penalty, and the ALP exclusion. All 1,010 tests pass, golden snapshots included. Of the 13 switches that I tried, only the run deferral, the margin, and the decimal exclusion fail a test.

High value:

  • binary_non_boolean_integers_select_one_bit_dict fails on develop and passes here.
  • trial_output_reused_on_win_and_respects_override_threshold pins the margin, the override threshold, and the single encode.
  • The first half of int_dict_defers_to_runend_and_narrow_for pins the run deferral.
  • bounded_encoder_matches_stats_encoder_on_nulls_and_special_floats is a good oracle test. Its oracle is the encoder that this PR leaves without an in-repo caller.

Low value:

  • bijective_vs_decompositional_dict_nesting_for_alp_and_decimals (about 75 lines) passes on develop and passes with the ALP exclusion deleted.
  • skewed_medium_cardinality_selects_dict_while_dense_uniform_stays_flat passes on develop. Its comment claims 2,048 distinct values and the fixture has 514.
  • head_probe_rejects_unique_column_without_distinct_stats passes with both probes disabled.
  • sparse_scheme_uses_majority_vote_without_distinct_stats differs from develop only in its stats_options flag assertion.
  • patch_density_cost_scales_quadratically restates the formula.

The screens have one contract: they change time and never output. Add one Hegel property test that compares compress with the screens on and with the screens bypassed. That test covers every screen at once.

4. Compression time

The description says latency is "flat-to-faster". The benchmark table in this PR shows +3.47% compression time across compress-bench, with partsupp at +22.8% and HashTags at +13.8%. CodSpeed fails on write_default[drifting] (-18.3%) and write_default[urls] (-12.4%). The cost is a full-chunk trial that then loses or ties:

ms develop PR Bytes
compact, i32, 4,000 distinct, skewed, 1M rows 25.8 49.4 same (Pco)
compact, f64, 20,000 distinct prices, 1M rows 46.9 76.2 same (Pco)
default, f64, 300 distinct, 1M rows 15.1 25.5 same, ALP root to Dict root
default, i32 dense 0..1000, 50,000 rows 0.16 0.62 same

The large wins come from the removal of full-chunk distinct counting (first table, about 15× on unique i64). State both sides in the description and resolve the CodSpeed failure. The Python CodSpeed job fails on an installer hash and is not related.

5. Coupling

  • has_entropy_scheme matches names that end in .zstd. vortex.string.zstd and vortex.binary.zstd match, and they cannot compress integer codes. The CUDA preset and the Variant storage compressor of the default preset therefore run the entropy gates with no numeric entropy coder. The effect is extra trials, not wrong output.
  • vortex-compressor now holds "fastlanes.rle", the slot names "patch_indices" and "child", and a copy of MIN_BITS_SAVED. A rename turns a gate off with no error. PCO_HEADER_FLOOR_BYTES cites a PCO_FIXED_NBYTES constant that does not exist.
  • ALPScheme and DecimalScheme use the child index as a state flag (PATCHED_ENCODED_SLOT, MSP + 1). The index is public through ChildKind::Cascade, and both encode doc comments still give the old numbers. Both exclusions are unconditional. A builder that excludes FloatDictScheme or DecimalDictScheme gets no dictionary path for those columns.
  • [open] Which dataset needs the ALP exclusion? No test does, and the golden snapshot is the same without it.

6. Scope

Split this PR into three.

  1. The Sparse Boyer-Moore change is correct and independent. Runs count valid values only, so run_count - 1 <= 2E holds and the skip is safe. Propagate the error that .ok().flatten() hides.
  2. The TrialOutput override threshold is small and clean.
  3. The dictionary selection, at about 500 lines after the cuts above.

#11307 builds a similar head probe and bounded counting pass for DictStrategy. One shared helper can serve both.


Generated by Claude Code

@lwwmanning lwwmanning changed the title Select numeric dictionaries with bounded probes Improve numeric dictionary schemes with bounded probes Dec 1, 2026
- Remove the narrow-span integer gate that rejected skewed patched dictionaries.
- Unify histogram lower-bound admission into one function, remove dead precomputed-stats paths, and deduplicate bounded dict encoding.
- Add conservative Chao1 cardinality bound to stratified probes and charge unscaled values in the aligned pre-trial to speed up bimodal/drifting columns.
- Narrow integer entropy detection to vortex.int.pco, gate run-coded dict deferral on registered direct run schemes, and gate DecimalScheme's IntDict exclusion on DecimalDictScheme being an eligible peer.
- Revert unnecessary ALPScheme child-slot split, propagate SparseScheme majority_candidate errors via ArrayAndStats::get_or_try_insert_with, and fix/expand tests including screen invariance.

Signed-off-by: Will Manning <will@spiraldb.com>
Co-Authored-By: Will Manning <will@spiraldb.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor

Addressed the review findings in fa12a36c3:

  • Narrow-span gate: Removed the tiny-span integer gate so skewed narrow-span columns (e.g. 99% in {14, 15}, 1% in 0..14) can select 1-bit patched IntDict, while dense narrow-span inputs still stay flat via the 7% margin.
  • Admission simplification: Unified admit_cardinality_only, admit_exact_histogram, and admit_probe into a single admit_histogram lower bound, removed unreachable precomputed-stats paths and integer_stats_histogram, deduplicated encode_slice_bounded (intern + generic remap_codes), and derived override_threshold_bytes from MIN_RELATIVE_SAVINGS_PCT.
  • Performance / CodSpeed: Added a conservative Chao1 cardinality bound to NumericProbe::exceeds_cardinality_bound to reject bimodal run-plus-unique columns (such as drifting) during the probe, and included unscaled compressed values in passes_aligned_codes_pretrial. Note: the Benchmark with Codspeed (Python) failure on the prior commit was an expired CodSpeed CLI installer JWT (618 jwt:expired).
  • Custom compressors & scheme coupling: Narrowed integer entropy detection to vortex.int.pco, gated run-coded dictionary deferral on CascadingCompressor::has_run_scheme_for, gated DecimalScheme's IntDict exclusion on DecimalDictScheme being an eligible peer (CompressorContext::has_peer_scheme), and reverted the unnecessary ALPScheme child-slot split.
  • Error propagation & tests: Propagated majority_candidate errors in SparseScheme via ArrayAndStats::get_or_try_insert_with, fixed the skewed_medium_cardinality_selects_dict_while_dense_uniform_stays_flat fixture to have ~2,050 distinct values (>50% in a 1,024-row sample), and added tests for skewed narrow-span, custom-compressor exclusions, and screen invariance.

@vortex-roborev-bot vortex-roborev-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line comments for the roborev review of fa12a36. The roborev PR comment has the full review.

Comment on lines +553 to +587
return true;
}
if self.rows < MIN_HEAD_PROBE_ROWS {
return false;
}
let collisions = self.rows.saturating_sub(self.distinct);
if collisions == 0 {
return true;
}
let safety_factor = if self.rows < 4096 { 8u128 } else { 4u128 };
let num = (self.rows as u128) * (self.rows as u128);
let den = safety_factor * (collisions as u128 + 1);
if (num / den) > (max_entries as u128) {
return true;
}
// Conservative Chao1 lower bound (divided by `safety_factor`) catches bimodal
// run-plus-unique columns where repeated values hide a unique tail from the global
// collision count.
let s = self.singletons as u128;
let unseen = if self.doubletons > 0 {
(s * s) / (2 * self.doubletons as u128)
} else {
s.saturating_mul(s.saturating_sub(1)) / 2
};
(self.distinct as u128).saturating_add(unseen / safety_factor) > (max_entries as u128)
}
}

/// Collects a [`NumericProbe`] of `PROBE_RANGE_COUNT * range_size` elements from `data`.
fn probe_array(data: &ArrayAndStats, mask: &Mask, range_size: u32) -> Option<NumericProbe> {
match data.array().dtype() {
DType::Primitive(ptype, _) => {
let prim = data.array_as_primitive();
match_each_native_ptype!(*ptype, |T| {
probe_typed_slice(prim.as_slice::<T>(), mask, range_size, NativeValue)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Medium: exceeds_cardinality_bound adds an unseen-species estimate that isn't capped by the number of rows the probe skipped, yet its doc calls it a conservative lower bound. A unique tail gives many singletons and no doubletons, so the s*(s-1)/2 term can exceed the chunk size. Example (reviewer's estimate): 10,000 i64 rows with 2 hot values and 300 unique tail values gives a probe with s≈246 and an estimate of about 7,781, which is more than 5,000. The column is rejected, although the old exact path picked Dict for its 302 distinct values.

Fix: Cap unseen at valid_rows - probe.rows before dividing by safety_factor, keep unique-column rejection through the collision and distinct checks, and add a hot-values-plus-unique-tail case (about 10k and 65k rows) to screens_preserve_unscreened_verdict_across_distributions.

- Cap the Chao1 unseen-species estimate in NumericProbe::exceeds_cardinality_bound at valid_rows - probe.rows so small unique tails on hot-value columns are not overestimated, and add 10k/65k hot-pair+unique-tail cases to screens_preserve_unscreened_verdict_across_distributions.
- Exclude IntDictScheme on OnPairScheme's codes child (child 1), matching StringDictScheme/BinaryDictScheme and avoiding redundant full-chunk dictionary trials over OnPair's token IDs (fixing the CodSpeed write_default[urls] and write_default[table] regressions).

Signed-off-by: Will Manning <will@spiraldb.com>
Co-Authored-By: Will Manning <will@spiraldb.com>
Dividing the capped unseen count by safety_factor (4 or 8) bounded it below valid_rows / 4 < max_entries (valid_rows / 2), disabling the bimodal run-plus-unique rejection on write_default[drifting]. Dividing by safety_factor first and then capping at valid_rows - probe.rows preserves the small-tail guard while keeping bimodal rejection active.

Signed-off-by: Will Manning <will@spiraldb.com>
Co-Authored-By: Will Manning <will@spiraldb.com>

@vortex-roborev-bot vortex-roborev-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line comments for the roborev review of a54a91d. The roborev PR comment has the full review.

Comment on lines +244 to +256
// 4 exact ALP floats (`<= 50%` distinct, patchless ALP): bijective slot excludes
// `ALP(IntDict)` so root `Dict` wins instead of decoding ALP per row.
let low_card_alp =
PrimitiveArray::from_iter((0..16_384usize).map(|i| [1.25f64, 2.50, 3.75, 5.00][i % 4]))
.into_array();
let comp_low = float_compressor.compress(&low_card_alp, &mut ctx)?;
assert!(comp_low.is::<Dict>(), "{}", comp_low.display_tree());
assert_arrays_eq!(comp_low, low_card_alp, &mut ctx);

// `> 50%` distinct floats (55% unique non-ALP `PI` multiples + 45% 4 exact ALP floats):
// root `FloatDict` skips (`> 50%` distinct), while patched `ALP` collapses exceptions to a
// fill value so `ALP(IntDict)` still compresses `encoded`.
let patched_alp = PrimitiveArray::from_iter((0..8_192usize).map(|i| {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Low: The comments in bijective_vs_decompositional_dict_nesting_for_alp_and_decimals still describe the ALP child-slot split, which commit fa12a36 reverted. ALPScheme now has one child and no descendant_exclusions, so IntDict is never excluded under ALP. In the first case, root Dict wins because FloatDict's measured trial beats the ALP(IntDict) estimate, not because of an exclusion.

Fix: Rewrite both comments with the real reasons (first case: FloatDict wins on trial and margin; second case: FloatDict skips at >50% distinct and ALP(IntDict) compresses encoded) and drop the slot-exclusion wording.

Signed-off-by: Will Manning <will@spiraldb.com>
Co-Authored-By: Will Manning <will@spiraldb.com>

@lwwmanning lwwmanning left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Posted by Claude Opus 5.5 on Will's behalf.

Follow-up on 47ad197. I found no bug that returns a wrong array or panics. The Chao1 cap is in the right units, cannot divide by zero, and now applies the safety factor before the cap. The narrow-span gate is gone, and numeric_candidate.rs has about 940 production lines, down from about 1,310. There is no wire-format change.

I need to correct my last review. I said the run-encoded skip before the TrialOutput cache was right. For integers, it skips every Dict(RunEnd) trial whenever a run scheme is registered (numeric_candidate.rs:260). The old comment said that this trial rescued chunks where direct RunEnd lost its 1,024-row sample to FastLanes padding. That rescue is now gone for integers, and no test covers it. Is that intended?

Name matching is still open, and this push adds more. has_run_scheme_for matches "vortex.int.runend", "vortex.int.rle" and "vortex.float.rle", and has_int_entropy_scheme matches "vortex.int.pco" (compressor/mod.rs:89 and 107). These checks test registration, not eligibility at the call site. The new has_peer_scheme uses SchemeId, and these checks could use it too. "fastlanes.rle", "child" and "patch_indices" remain in numeric_candidate.rs.

Four new constants have no test that fails when they change. They are the Chao1 safety factor (8 below 4,096 rows, else 4) and the run cost of 8 bits per run. The others are the Pco gate max_bw > 8 and the OnPair IntDict exclusion.

…nd add Hegel tests

Signed-off-by: Will Manning <will@willmanning.io>

@lwwmanning lwwmanning left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Posted by Claude Opus 5.5 on Will's behalf.

Follow-up on e669d13. I found no bug that returns a wrong array or panics, and there is no wire-format change.

The peer gates now check what an eligible scheme at the current site produces, not the registered set. They match RunEnd.id(), "fastlanes.rle" and "vortex.pco", and these strings match the CachedId values in vortex-fastlanes and vortex-pco. When constant or masked encoding is off, IntDictScheme now compresses one-value columns, and two tests cover this. The patch-density penalty and the 64-byte net-savings floor now have tests, and the new Hegel property checks round trips and that the output never grows.

One question from my last review is still open. Integers still skip every Dict(RunEnd) trial when a run scheme is an eligible peer (numeric_candidate.rs:261). This removes the rescue for chunks where direct RunEnd loses its 1,024-row sample to FastLanes padding. Is that loss intended?

Two smaller points remain. Four constants still have no test that fails when they change. They are the Chao1 safety factor, the run cost of 8 bits per run, the Pco gate max_bw > 8 and the OnPair IntDict exclusion. "child" and "patch_indices" slot names remain at lines 418, 434 and 437.

The collisions == 0 early return is also gone. With max_entries = valid_rows / 2, a 1,024-row probe with no repeats now passes the collision bound in chunks of 262,144 or more valid rows. The Chao1 check and the admission screens then decide. Is that intended?

Copy link
Copy Markdown
Contributor Author

Posted by Claude Mythos 5.2 on Will's behalf. This is an AI re-review of e669d13. It is not Will's own text.

Verdict

Most findings from my review of 2d3296f are resolved. The narrow-span gate is gone (my case now writes 176,774 B, down from 500,224 B). The three admission gates are one function, the unreachable statistics path is gone, and numeric_candidate.rs has 938 production lines, down from 1,310. I found no path that returns wrong data, and all 1,014 tests pass locally.

It is not ready. Two selection defects write some columns up to 57× larger than develop, and the CodSpeed gate is green on incomplete data.

Method: local environment-variable switches around each gate (not pushed), and release builds of e669d13 and of the merge base. Timings are the minimum of 3 to 9 runs on a 2-core VM. The sweep below is 51 synthetic column shapes at 4 sizes (3,000 to 500,000 rows) in 2 presets, 408 cases.

1. The Chao1 bound rejects dictionaries that develop selects

Input: i64, 8 hot values plus a share of one-off values at random positions, all about 50 bits wide, default preset.

Rows One-off share develop PR Ratio
16,384 5% 15,756 B 102,400 B 6.5×
131,072 10% 197,103 B 819,200 B 4.2×
131,072 30% 455,274 B 819,200 B 1.8×
1,000,000 30% 3,722,730 B 6,252,800 B 1.7×

11 of 18 cases regress. With the Chao1 term off, all 18 equal develop.

The term is not a lower bound. At 131,072 rows with 10% one-off values, the column has about 13,100 distinct values and max_entries is 65,536. The bound still reports more than 65,536. With no doubletons, the term rejects when the 8,192-row probe holds about 2 * sqrt(valid_rows) singletons. That is 3% of rows at 16,384, 9% at 131,072, and 24% at 1M. The fixtures in screens_preserve_unscreened_verdict_across_distributions stop at 3% and 0.8%.

The term exists for the drifting benchmark, and there it works. That column takes 0.5 ms here, 1.0 to 1.3 ms on develop, and 3 to 7 ms with the term off. Cardinality cannot separate the two columns. Both are below max_entries. The difference is value width against code width.

[open] I tried one replacement: Chao1 off, and admit_histogram charges half of ceil(log2(distinct)) bits per dictionary value. All 18 cases equal develop again, and 2 of 408 sweep outputs change. drifting costs 2.6 to 4.8 ms, so this is half a fix.

2. A measured dictionary beats a sampled rival that is much smaller

Column (i64, default preset) Rows develop PR Ratio
Sorted keys, each 2 times 8,192 200 B (delta) 11,410 B (dict) 57×
Sorted keys, each 2 times 20,000 3,123 B (delta) 31,914 B (dict) 10×
Sorted keys, each 3 times 40,000 8,619 B (delta) 64,378 B (dict) 7.5×
4 wide values, runs of 8 131,072 13,610 B (runend) 32,800 B (dict) 2.4×

The sorted cases regress in 7 of 8 runs below 65,536 rows. The run case regresses at every size from 20,000 to 131,072 rows.

The dictionary size is measured. The rival size is a sample estimate. In the 20,000-row case that estimate is at least 10× too high, or the 7% margin fails. The override threshold corrects only one direction: a rival that wins and then disappoints. develop hid this because its dictionary estimate was also too high (3 bits for 4 values). When the dictionary wins the callback, encode the runner-up and keep the smaller output.

3. Tests

Over-rejection is now pinned. Three switches that make a screen too strict fail 16, 6, and 2 tests. That is a real improvement.

  • heavily_patched_dict_rejected_by_patch_density_penalty does not reach the penalty. Its codes pack at 3 bits with 0 patches, so the dictionary is 3,088 B against 3,072 B flat. The test passes with the penalty at 0.
  • [open] The penalty changes 3 of 408 sweep outputs. In one (f64, 131,072 rows, two hot values at 90%, 3,000-value tail) it writes 159,694 B where the dictionary is 109,316 B. Which measurement set 256?
  • The Hegel property caps len at 10,000, so it never reaches the pre-trial (65,536 rows). It asserts round trip and no expansion, which sections 1 and 2 both satisfy.
  • Add a regret property: full-compressor output is at most 1.1× the best output of each root scheme alone. It fails on sections 1 and 2.
  • [open] No test pins the OnPairScheme exclusion, and "redundant" is not always true. On 131,072 unique URLs in the compact preset it writes 1,676,879 B. Without it the PR writes 1,487,215 B. In the default preset the bytes are equal and the exclusion saves 28% to 42% of the time.

4. CodSpeed

The gate is green on e669d13, but it compared 378 of 2,322 benchmarks. A shard failure cancelled the other four shards on each of the last three commits (installer error 618 on e669d13). The last complete run is 242b9d6, and it failed with write_default[drifting] at -11.7%. My harness puts the two integer drifting columns at 2× faster than develop on this head, so the fix probably holds. Re-run the shards before merge.

5. Aggregate

Across the 408 cases the PR writes 8.4% fewer bytes than develop (default -13.0%, compact -2.1%). 70 cases shrink by more than 2% and 14 grow. The sweep leans toward dictionaries, so compression time is up 20% to 23% at 500,000 rows and 79% to 93% at 3,000 rows.

The remaining screens each carry weight. The cardinality bound saves 21% of default-preset time. The pre-trial is worth 3× to 5× on dense narrow integers. admit_histogram is worth up to 2.8× on 6 compact cases. The collision term has no effect while Chao1 is on.

On the open question about integer Dict(RunEnd): with the run deferral off, 57 of 408 outputs change and 42 of them grow. The deferral is a net win. Its largest loss in bytes is 17,349 B against 10,996 B (compact, 20,000 rows).

The "fastlanes.rle", "vortex.pco", "child", and "patch_indices" strings remain in vortex-compressor.


Generated by Claude Code

Replace the infinite-population Chao1 probe bound with singleton-scaled
pretrial sizing (with Pco chunk_meta amortization), fix Delta outlier
patch and dominant-stride estimation, use aligned-chunk RunEnd sampling,
and exclude IntDict under patchless ALP when FloatDict is a peer.

Signed-off-by: Will Manning <will@willmanning.io>

Copy link
Copy Markdown
Contributor Author

Posted by Claude Mythos 5.2 on Will's behalf. This is an AI re-review of a843288. It is not Will's own text.

This comment is a static review. I read the diff and the benchmark tables and ran nothing. Items that need a measurement carry [unmeasured]. A follow-up comment will give the measurements.

Resolved

  • CodSpeed ran in full and is green: 2,188 untouched, 136 skipped, and write_default[drifting] is 11.08% faster.
  • The Chao1 term is gone from exceeds_cardinality_bound. The pre-trial now estimates dictionary entries and scales the values bytes, which is the right question (value width against code width). My hand calculation says the 131,072-row 10% case and the 1M-row 30% case both pass. [unmeasured]
  • heavily_patched_dict_rejected_by_patch_density_penalty now asserts 550 patches and a forced dictionary that beats flat by more than 7%.
  • test_numeric_dict_screens_do_not_reject_winning_dicts pins a hot-plus-one-off fixture in both presets.

1. The measured-against-estimated gap is narrowed, not closed

This commit makes the DeltaScheme and RunEndScheme estimates more accurate. It does not compare a winning dictionary with the real output of the runner-up. Every other sampled rival (IntRLEScheme, SequenceScheme, PcoScheme, the float schemes) keeps the old exposure.

The new Hegel property accepts a dictionary up to 2.0× the size of the non-dictionary output. Its comment says the bound tolerates "benign 1.2x–1.5x" cases. Those cases are the same defect at a smaller scale. [unmeasured]

The fix also depends on scheme order. session.rs now registers Delta and RunEnd before IntDictScheme, and only a comment states that contract. A caller that builds a CascadingCompressor with another order gets different margins. Two new tests in this PR list IntDictScheme before RunEndScheme.

2. The new RunEnd estimate does full work and discards it

target_chunks is the average run length, clamped to 16. sample_aligned_chunks returns None when the array has no more full chunks than that. The callback then run-end encodes the whole array and cascade-compresses both children with a non-sampling context. It ignores best_so_far, and it caches nothing, so encode repeats the work when RunEnd wins.

statpopgen compression time is 313.74 ms on develop and 473.64 ms here (+50.96%). I suspect this callback. [unmeasured]

3. The description overstates decompression

"Decompression is 22.67% faster" is 209.03 ms saved across 77 datasets. statpopgen alone is 166.91 ms of that (80%). The geomean in your table, -4.34%, is the fair headline. The description also omits statpopgen at +50.96% and taxi at +11.86% on compression.

4. Scope

The PR is now 3,024 added lines in 25 files. numeric_candidate.rs has 1,167 production lines, up from 938 at e669d13. The pre-trial alone gained five helper functions.

  • The Delta and RunEnd estimator changes affect every integer column, with or without a dictionary. Move them to their own PR with their own benchmark. That split also attributes the statpopgen cost.
  • vortex-compressor now holds more Pco internals: the "vortex.pco" ID, the chunk_meta_ buffer-name prefix, and a copy of the 262,144-value chunk size. A rename in vortex-pco changes the estimate with no error.
  • ALPScheme uses the child index as a state flag again (slot 0 or 1 for the same child). It is now conditional on a FloatDictScheme peer, which fixes the builder case. [unmeasured] I do not know if a test fails without it.
  • test_delta_wins_full_compressor_on_zero_span_constant_lanes has a new fixture and a looser bound (/ 50 to / 25). The reason is that RunEnd now beats Delta on the old fixture by 8 B. State that behavior change in the description.

Generated by Claude Code

Copy link
Copy Markdown
Contributor Author

Posted by Claude Mythos 5.2 on Will's behalf. This is the measured follow-up to my static review of a843288. It is not Will's own text.

Method: local environment-variable switches around each gate and around the two new estimators (not pushed), and release builds of a843288 and of the merge base. Timings are the minimum of 7 to 9 runs on a 2-core VM. The sweep is 63 synthetic column shapes at 4 sizes (3,000 to 500,000 rows) in 2 presets, 504 cases. All 1,017 tests pass on the pristine head.

Corrections to my static review

  • My suspicion about the new RunEnd estimate was wrong. It is faster than the old sampled estimate: 521 ms against 567 ms over the 500,000-row default cases. At 3,000 and 20,000 rows the two cost the same within 2%.
  • The ALPScheme exclusion is pinned. bijective_vs_decompositional_dict_nesting_for_alp_and_decimals fails without it.

Confirmed fixed

  • Hot values plus one-off values: all 18 default-preset cases are now equal to develop or smaller. Three are 4% to 9% smaller.
  • A test now fails when I remove the patch penalty, the margin, or the net-bytes floor. The same holds for the ALP, decimal, and OnPair exclusions and for the new RunEnd estimate.

1. The measured-against-estimated gap is still open

Column (i64, default preset) Rows develop PR Ratio Rival with the high estimate
Sorted keys, each 2 times 8,192 200 B 11,410 B 57× delta
Sorted keys, each 2 times 20,000 3,123 B 31,914 B 10× delta
Sorted keys, each 3 times 40,000 8,619 B 64,378 B 7.5× delta
4 wide values, runs of 8 65,536 6,806 B 16,416 B 2.4× runend
4 wide values, runs of 8 500,000 50,846 B 125,216 B 2.5× runend
Runs, then 30% random 131,072 164,868 B 188,189 B 1.14× bitpacked.v2

The sorted rows are byte-identical to e669d13. They are also identical with the old Delta estimate switched back in, so the Delta change does not reach them. The run case is fixed at 20,000 and 131,072 rows. At 500,000 rows the old RunEnd estimate selects runend (50,846 B) and the new one does not. The last row is new: a third rival whose estimate (one global bit width) is far above its real per-block output.

Three rivals now show the same defect. Estimator repairs fix one size of one shape at a time. When the dictionary wins the callback, encode the runner-up and keep the smaller output. The Hegel property passes while these rows exist. It runs a custom scheme list and not the default preset, its tier-2 bound is 2.0×, and its lengths stop at 70,000.

2. New: binary and ternary columns pay a full trial that cannot win

i8, values 0 to 2, random order develop PR PR with the change below
131,072 rows 0.69 ms 2.17 ms 0.42 ms
500,000 rows 2.59 ms 8.00 ms 1.19 ms

Output bytes are equal in all three columns. estimate_scaled_child_bytes subtracts 128 B from the sampled codes. One-bit codes on 8,192 rows are 1,024 B, so the pre-trial projects a 12.5% saving that does not exist (6.25% for two-bit codes). The threshold is 4.2%, so the full hash pass and trial run. Four-bit codes project 3.1% and stop.

I removed that subtraction for codes only. No output changes in 610 cases (the sweep, the 36 hot-value cases, and the 70 sorted and run cases), and all 1,017 tests pass. statpopgen is genotype data, so this is my new candidate for its +50.96% compression time. [unmeasured on the real dataset]

3. The drifting integer column is slow again

Without Chao1, the column that the term was built for costs 3.0 to 8.5 ms in 5 of 6 variants (30%, 50%, and 60% random, both orders). develop takes 0.9 to 1.2 ms, and e669d13 took 0.5 ms. CodSpeed still reports write_default[drifting] 11% faster, because that benchmark times the whole file write. The trade is correct, because the hot-value fix is worth more. State the cost in the description.

4. Two additions that no test pins

  • The new Delta estimate (estimate_delta_bits, patched_bit_width): all tests pass with the old span-only estimate. It changes 12 of 504 outputs. 10 shrink and 2 grow, one of them by 44% (runs, then 20% random, 20,000 rows: 23,718 B against 16,421 B).
  • The run deferral: no test fails without it now. It changes 21 of 504 outputs, and 13 shrink.

Aggregate

Across the 504 cases the PR writes 8.3% fewer bytes than develop (default -12.8%, compact -2.0%). 79 cases shrink by more than 2% and 23 grow. The new RunEnd estimate changes 45 outputs (28 shrink, 17 grow) and the new Delta estimate changes 12. Compression time in this dictionary-leaning sweep is up 8% to 10% at 500,000 rows and 43% to 62% at 3,000 and 20,000 rows.


Generated by Claude Code

Stop subtracting 128 B from unamortized sample codes in the numeric Dict pre-trial, unconditionally apply the 7% gather penalty to NumericDict's reported ratio, revert DeltaScheme/RunEndScheme/session.rs ordering changes back to origin/develop, and add bounded non-entropy, non-default runner-up verification without nested recursion.

Signed-off-by: Will Manning <will@willmanning.io>

@vortex-roborev-bot vortex-roborev-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line comments for the roborev review of b1ec053. The roborev PR comment has the full review.

Comment on lines +739 to +751
fn exceeds_cardinality_bound(&self, max_entries: usize) -> bool {
if self.distinct > max_entries {
return true;
}
if self.rows < MIN_HEAD_PROBE_ROWS {
return false;
}
let collisions = self.rows.saturating_sub(self.distinct);
let safety_factor = if self.rows < 4096 { 8u128 } else { 4u128 };
let num = (self.rows as u128) * (self.rows as u128);
let den = safety_factor * (collisions as u128 + 1);
(num / den) > (max_entries as u128)
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Low: exceeds_cardinality_bound rejects a dictionary whenever a probe of at least 1,024 rows finds zero or few collisions. A 2,048-row probe with no collisions gives a bound of about 524K, which is above max_entries for chunks under about 1M rows. The probe reads 16-row slices, so it misses repeats that are far apart. This also blocks the ALP(IntDict) fallback. Output stays correct, but compression is lost.

ids ++ ids  // ~600K wide i64 rows, 300K distinct: Dict is skipped although it would be ~20% smaller

Fix: When the probe finds zero or very few collisions, let the aligned pre-trial and histogram gates decide instead of rejecting, while still rejecting truly unique columns cheaply so head_probe_rejects_unique_column_without_distinct_stats keeps passing; add an ids ++ ids regression test that expects a Dict result.

Restore DeltaScheme, RunEndScheme, and session ordering from a843288 on top of b1ec053, guard DeltaScheme against beating direct per-block BitPacking on the same sampled chunks, cache full-array RunEnd trial outputs via per-scheme TrialOutputs (through compress_encoded so ChildPolicy is respected), and gate verify_runner_up to skip sampled float-transform cascades (ALP/ALPRD) and >4x landslide wins.

Signed-off-by: Will Manning <will@willmanning.io>

@vortex-roborev-bot vortex-roborev-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line comments for the roborev review of 2271488. The roborev PR comment has the full review.

Comment on lines +737 to +749
fn exceeds_cardinality_bound(&self, max_entries: usize) -> bool {
if self.distinct > max_entries {
return true;
}
if self.rows < MIN_HEAD_PROBE_ROWS {
return false;
}
let collisions = self.rows.saturating_sub(self.distinct);
let safety_factor = if self.rows < 4096 { 8u128 } else { 4u128 };
let num = (self.rows as u128) * (self.rows as u128);
let den = safety_factor * (collisions as u128 + 1);
(num / den) > (max_entries as u128)
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Low: The probe's cardinality bound rejects Dict for columns where repeats are far apart. With zero collisions, the bound for a 2,048-row probe is rows^2 / 8, about 524K. That is above max_entries for any chunk under roughly 1M rows, and the 16-row stratified slices miss distant repeats. For example, an ids ++ ids column (about 600K rows, 300K distinct) skips IntDict/FloatDict even though Dict would be about 20% smaller. It also blocks the ALP(IntDict) fallback. Output stays correct.

Fix: Apply the collision-based rejection only above a minimum collision count and let the aligned pre-trial and histogram gates decide otherwise, keeping head_probe_rejects_unique_column_without_distinct_stats passing and adding an ids ++ ids regression case.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 227148873d

ℹ️ 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".

Comment on lines +186 to +188
if ctx.has_peer_scheme(SparseScheme.id())
&& u64::from(stats.run_count().saturating_sub(1)) * 5 <= u64::from(stats.value_count()) + 1
&& let Some((_, majority_count)) = deltas.majority_candidate(exec_ctx)?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Price Sparse residual values at the remaining cascade depth

When Delta is evaluated with only one cascade level remaining, its residual child reaches allowed_cascading == 0: SparseScheme can still wrap that child, but Sparse's patch values cannot be cascaded and remain at their native width. This estimate nevertheless charges each non-fill value only span_bits, which can substantially overstate Delta's ratio on sparse 64-bit residuals and make it beat a genuinely smaller rival. Require another cascade level here, as the ZigZag estimate above does, or charge the uncompressed value width when Sparse's children cannot be compressed.

Useful? React with 👍 / 👎.

Comment on lines +154 to +156
let target_chunks = u32::try_from(full_len.div_ceil(full_runs))
.unwrap_or(MAX_SAMPLE_CHUNKS)
.clamp(1, MAX_SAMPLE_CHUNKS);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Measure the full array when fewer than 1,024 runs exist

When a large array has fewer than 1,024 long runs, clamping target_chunks to 16 still takes an aligned sample instead of the full array promised by the comment. That sample contains only a handful of run values but pays the same 1,024-element FastLanes padding as the complete RunEnd children, so its ratio can be far below the full-array ratio and RunEnd can lose to a larger rival. Bypass sample_aligned_chunks when full_runs < FL_CHUNK_SIZE, or otherwise project the fixed padding over the full input.

Useful? React with 👍 / 👎.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog/performance A performance improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants