Repository navigation
Improve numeric dictionary schemes with bounded probes - #12434
lwwmanning wants to merge 11 commits into
Conversation
- 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>
|
Updated 5-round release medians across the 15 Aggregate Summary (
|
| 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) with2,048- and8,192-row stratified collision/histogram probes, an8,192-row FastLanes-aligned pre-trial on>= 32,768-row chunks (with.with_sampling(), exact unsubtractedsample_codesscaling, per-chunkvortex.pcometadata amortization, and unseen singletonvaluesscaling), single-pass frequency-orderedDictArrayconstruction (<= valid_rows / 2), quadratic code-patch penalty (256bits), peer run-encoding deferral, unconditionally penalized reported ratio, and7%+64 Btrial margin. - Tightly gated
verify_runner_up(MAX_RUNNER_UP_VERIFY_RATIO_GAP = 4.0, skipping entropy,ALP/ALPRD, andAlwaysUserivals, with nested verification suppressed viaCompressorContext::without_runner_up_verification()) backed by per-schemeTrialOutputsranked by(override_above_nbytes, nbytes). - Restored
DeltaScheme(patched +majority_candidateestimation guarded by 4-chunk blocked bit-packing) andRunEndScheme(aligned-chunk>= 1,024-run callback viacompress_encodedwith full-encodeTrialOutputcaching), ordered ahead ofIntDictSchemeinsession.rs. - Zero eager
count_distinct_valuesscans across built-in schemes (SparseSchemeuses theO(1)run_countbound +majority_candidate), plus bijectiveIntDictSchemeexclusions on single-partDecimalScheme, patchlessALPScheme(whenFloatDictSchemeis a peer), andOnPairSchemeoffsets/tokens.
- Unified Pass-2
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% |
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. |
roborev: Combined Review (
|
| 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>()); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
💡 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".
| excluded: IntDictScheme.id(), | ||
| children: ChildSelection::One(DecimalBytePartsSlots::MSP), |
There was a problem hiding this comment.
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 👍 / 👎.
| let by_net = if penalized_nbytes >= 512 { | ||
| penalized_nbytes.saturating_add(MIN_NET_BYTES_SAVED) | ||
| } else { | ||
| penalized_nbytes |
There was a problem hiding this comment.
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 👍 / 👎.
| let has_entropy_scheme = schemes | ||
| .iter() | ||
| .any(|s| s.scheme_name().ends_with(".pco") || s.scheme_name().ends_with(".zstd")); |
There was a problem hiding this comment.
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 👍 / 👎.
|
Interestingly I have similar thing in #11307 |
lwwmanning
left a comment
There was a problem hiding this comment.
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.
-
The CI failure is a real regression.
DecimalSchemenow excludesIntDictSchemeon the MSP for every decimal, not only for the low-cardinality ones thatDecimalDictSchemetakes. Inrejected_decimal_keeps_nested_int_dict, the decimal is unique, so rootDictis not an option. Its MSP has 4 distinct values, and it now gets FoR with 5-bit BitPacking (10.24 kB) instead of a nestedDict. Please apply the exclusion only when the root dictionary is a real candidate, or drop it. -
numeric_candidate.rshas about 1,060 production lines, against 444 forbytes_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_histogramhas 8 identical match arms.encode_slice_boundedrepeatsencode_sorted_codesindict/mod.rs. The callback still callsinteger::dictionary_encodetoo, so two integer encoders remain.KEEP_NUMERATORandKEEP_DENOMINATORrepeatMIN_RELATIVE_SAVINGS.
-
The compressor now matches encoding internals by name.
has_entropy_schemematches any name that ends in.zstd, sovortex.string.zstdloosens the integer gates. The gates also compare against"fastlanes.rle"and walk slots namedpatch_indicesandchild. A renamed slot would turn a gate off with no error. -
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_flatclaims 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. -
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>
Merging this PR will improve performance by 15.01%2 warnings
Performance Changes
Tip Curious why performance improved? Comment Comparing Footnotes
|
There was a problem hiding this comment.
💡 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".
| if span == 0 { | ||
| return Ok(EstimateVerdict::Skip); | ||
| } |
There was a problem hiding this comment.
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 👍 / 👎.
| && let Some(head) = probe_array(data, &mask, HEAD_PROBE_RANGE_SIZE) | ||
| && (head.is_unique() | ||
| || head.exceeds_cardinality_bound(max_entries) |
There was a problem hiding this comment.
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 👍 / 👎.
| vec![DescendantExclusion { | ||
| excluded: IntDictScheme.id(), | ||
| children: ChildSelection::One(PATCHLESS_ENCODED_SLOT), |
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
💡 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".
| fn descendant_exclusions(&self) -> Vec<DescendantExclusion> { | ||
| vec![DescendantExclusion { | ||
| excluded: IntDictScheme.id(), | ||
| children: ChildSelection::One(DecimalBytePartsSlots::MSP), |
There was a problem hiding this comment.
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 👍 / 👎.
| 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()) |
There was a problem hiding this comment.
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 👍 / 👎.
| if let Some(runs) = run_encoded_runs | ||
| && (scheme.id() == IntDictScheme.id() || dict_len.saturating_mul(2) > runs) | ||
| { |
There was a problem hiding this comment.
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 👍 / 👎.
| // 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)?; |
There was a problem hiding this comment.
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.
| /// Minimum byte savings required on non-tiny rivals (`>= 512` B) to amortize serialized | ||
| /// `vortex.dict` FlatBuffer metadata. | ||
| const MIN_NET_BYTES_SAVED: u64 = 64; |
There was a problem hiding this comment.
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.
|
Posted by Claude Mythos 5.2 on Will's behalf. This is an AI review of 2d3296f. It is not Will's own text. VerdictThe change is correct as far as I can find. No path returns wrong data or panics, and all 1,010 tests pass locally ( 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 dictionaryInput: 1M
2. Most of the screening code has no measurable effectScreening pays as a group. Two parts carry it: the head-probe cardinality bound and the aligned pre-trial.
The three Specific cuts:
One function that returns
3. TestsI disabled eight mechanisms together. The set is both probes, the pre-trial, the High value:
Low value:
The screens have one contract: they change time and never output. Add one Hegel property test that compares 4. Compression timeThe description says latency is "flat-to-faster". The benchmark table in this PR shows +3.47% compression time across
The large wins come from the removal of full-chunk distinct counting (first table, about 15× on unique 5. Coupling
6. ScopeSplit this PR into three.
#11307 builds a similar head probe and bounded counting pass for Generated by Claude Code |
- 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>
|
Addressed the review findings in
|
| 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) |
There was a problem hiding this comment.
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>
| // 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| { |
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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?
|
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. VerdictMost 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 It is not ready. Two selection defects write some columns up to 57× larger than 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
|
| 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_penaltydoes 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
lenat 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
OnPairSchemeexclusion, 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>
|
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
1. The measured-against-estimated gap is narrowed, not closedThis commit makes the 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. 2. The new RunEnd estimate does full work and discards it
3. The description overstates decompression"Decompression is 22.67% faster" is 209.03 ms saved across 77 datasets. 4. ScopeThe PR is now 3,024 added lines in 25 files.
Generated by Claude Code |
|
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
Confirmed fixed
1. The measured-against-estimated gap is still open
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 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
Output bytes are equal in all three columns. I removed that subtraction for 3. The
|
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>
| 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) | ||
| } |
There was a problem hiding this comment.
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>
| 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) | ||
| } |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
💡 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".
| 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)? |
There was a problem hiding this comment.
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 👍 / 👎.
| let target_chunks = u32::try_from(full_len.div_ceil(full_runs)) | ||
| .unwrap_or(MAX_SAMPLE_CHUNKS) | ||
| .clamp(1, MAX_SAMPLE_CHUNKS); |
There was a problem hiding this comment.
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 👍 / 👎.
Replaces #12217.
IntDictSchemeandDecimalDictSchemepreviously priced codes with an unpenalized full-chunk formula that ignored frequency skew and selected marginal dictionaries over flat SIMD encodings (FoR,BitPacking,ALP,Pco), whileFloatDictSchemeandSparseSchemeforced eager full-chunk distinct-value hashing in stats even on unique columns, and 1% samples under-rated medium-cardinality dictionaries (1K–30Kdistinct values in100K–1Mrows) 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/RunEndestimators, and zero eager distinct-value hashing:vortex-compressor):IntDictScheme,FloatDictScheme, andDecimalDictSchemerun as aDeferredEstimate::Callbackafter sampled rivals establishbest_so_far. Stratified2,048- and8,192-row probes screen inputs via a collision cardinality bound and a histogram lower bound across per-block bit-packing, run-encoding, and integerPcoentropy; multi-chunk inputs (>= 32,768rows) run an8,192-row FastLanes-aligned pre-trial that projects exact unsubtractedsample_codes, per-chunkvortex.pcometadata amortization, and unseen singletonvalues. Surviving candidates build a single frequency-orderedDictArray(<= valid_rows / 2), cascade-compresscodesandvalues, apply a quadratic code-patch penalty (256bits), peer run-encoding deferral, and a7%+64 Bsavings margin.vortex-compressor): When a numericDicttrial wins, selection verifies the best non-entropy, non-ALP/ALPRD, non-default (AlwaysUse) runner-up within a4.0xratio gap (MAX_RUNNER_UP_VERIFY_RATIO_GAP) on the full chunk, suppressing nested verification viaCompressorContext::without_runner_up_verification()and storing per-schemeTrialOutputsranked byoverride_above_nbytes.Delta/RunEndestimators, zero eager distinct hashing, and bijective exclusions (vortex-compressor,vortex-btrblocks): Built-in schemes no longer setcount_distinct_values: true(SparseSchemescreens via theO(1)run_countbound plusmajority_candidate).DeltaSchemeadds patched andmajority_candidateestimation guarded by 4-chunk blocked bit-packing,RunEndSchemeuses an aligned-chunk>= 1,024-run callback with full-encodeTrialOutputcaching (both ordered ahead ofIntDictScheme), and single-partDecimalScheme, patchlessALPScheme(whenFloatDictSchemeis a peer), andOnPairSchemeexclude redundant nestedIntDictSchemetrials.Across 77 datasets (
15compress-bench+62spiraldb/raincloud; full breakdown in #12434 (comment)),vortex-file-compressedshrinks by3.04%geomean (-1.61%/-63.70 MBtotal),vortex-compactshrinks by1.57%geomean (-1.35%/-39.86 MBtotal), decompression is19.74%faster total (+0.87%geomean, withstatpopgen-34.59%), and compression is+1.03%geomean (+1.40%total;raincloud-3.57%total /-0.59%geomean; localwrite_compressionmedians:drifting17.94 ms,urls20.41 ms,table24.37 ms).Authored with AI assistance.