Repository navigation
Add Affine integer encoding and default-ready AffineScheme - #11907
lwwmanning wants to merge 10 commits into
Conversation
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. |
Local 110-Column Combined
|
| Arm | Edition / Config | All 110 Cols (B) | vs CORE |
Native Int 97 Cols (B) | vs CORE |
TS/Date 13 Cols (B) | vs CORE |
Total Enc (ms) |
|---|---|---|---|---|---|---|---|---|
v1_noD |
CORE (FoR.v1) |
859,967,213 | +0.00% | 539,793,608 | +0.00% | 320,173,605 | +0.00% | 3,935.2 |
v1_D |
PREVIEW (FoR.v1 + Delta) |
792,343,521 | -7.86% | 490,066,759 | -9.21% | 302,276,762 | -5.59% | 3,938.8 |
for_v2_noD |
CORE + UNSTABLE (FoR.v2 only, #11906) |
846,423,838 | -1.57% | 529,651,355 | -1.88% | 316,772,483 | -1.06% | 3,832.9 |
for_v2_D |
PREVIEW + UNSTABLE (FoR.v2 + Delta, #11906) |
793,413,497 | -7.74% | 489,339,503 | -9.35% | 304,073,994 | -5.03% | 3,917.3 |
v2_aff_noD |
CORE + UNSTABLE (FoR.v2 + Affine) |
694,652,889 | -19.22% | 524,931,643 | -2.75% | 169,721,246 | -46.99% | 3,773.7 |
v2_aff_D |
PREVIEW + UNSTABLE (FoR.v2 + Affine + Delta) |
651,554,270 | -24.23% | 487,708,085 | -9.65% | 163,846,185 | -48.83% | 3,796.6 |
Per-Column Size Changes (All 29 Changed Columns; Remaining 81 Columns Byte-Identical)
| Column | Kind | Rows | v1_noD |
for_v2_noD |
v2_aff_noD |
v1_D |
for_v2_D |
v2_aff_D |
v2_aff_noD Encoding |
|---|---|---|---|---|---|---|---|---|---|
taxi.pickup_datetime |
ts | 19,144,903 | 65,967,104 | 65,967,104 | 30,766,890 | 65,967,104 | 65,967,104 | 30,766,890 | affine[SCALE](bp(bw=12,p=318272);refs=vortex.dict) |
taxi.dropoff_datetime |
ts | 19,144,903 | 65,972,480 | 65,972,480 | 31,541,096 | 65,972,480 | 65,972,480 | 31,486,248 | affine[SCALE](bp(bw=13,p=37415);refs=for.v2(...)) |
taxi.request_datetime |
ts | 19,144,903 | 65,950,976 | 65,950,976 | 32,525,458 | 65,950,976 | 65,950,976 | 32,525,458 | affine[SCALE](bp(bw=13,p=155786);refs=for.v2(...)) |
taxi.on_scene_datetime |
ts | 19,144,903 | 68,053,785 | 68,053,785 | 33,924,249 | 68,053,785 | 68,053,785 | 33,924,249 | affine[SCALE](bp(bw=13,p=36170);refs=for.v2(...)) |
euro2016.tweeted_at |
ts | 2,052,497 | 10,778,892 | 9,465,614 | 4,288,180 | 2,497,926 | 2,482,040 | 1,179,358 | affine[SCALE](bp(bw=16,p=20895);refs=for.v1(bp(bw=42))) |
tpch_orders.o_orderkey |
int | 1,500,000 | 4,312,960 | 2,250,240 | 562,566 | 82,456 | 67,736 | 17,697 | affine[ALL](bp(bw=3);refs=vortex.sequence) |
tpch_lineitem.l_orderkey |
int | 6,001,215 | 8,625,920 | 6,563,200 | 5,081,004 | 1,582,251 | 1,567,715 | 1,536,668 | affine[SLOPE](bp(bw=6,p=106030);refs=for.v2(...)) |
airquality.KafkaTimestamp |
ts | 823,743 | 5,255,040 | 4,334,120 | 2,273,326 | 1,016,152 | 1,011,264 | 1,008,814 | affine[SCALE](bp(bw=22);refs=vortex.primitive) |
airquality.timestamp |
ts | 823,743 | 5,255,040 | 4,334,120 | 3,301,417 | 2,161,989 | 2,157,101 | 2,088,010 | affine[SCALE](vortex.primitive;refs=vortex.primitive) |
food.activity_sec |
int | 5,216,593 | 11,344,420 | 11,344,420 | 9,962,128 | 11,344,420 | 11,344,420 | 9,962,128 | affine[SCALE](bp(bw=13,p=182638);refs=bp(bw=4)) |
hashtags.Calculation_6610227171140491 |
ts | 511,511 | 2,688,000 | 2,512,148 | 1,267,014 | 1,230,743 | 2,512,148 | 1,267,014 | affine[SCALE](bp(bw=19,p=5751);refs=vortex.primitive) |
arade.F3 |
ts | 9,888,775 | 994,560 | 924,408 | 575,888 | 167,879 | 709,368 | 342,416 | affine[SCALE](vortex.runend;refs=for.v1(bp(bw=46))) |
airquality.p_0_3 |
int | 823,743 | 1,190,478 | 1,020,810 | 849,260 | 891,659 | 1,020,810 | 849,260 | affine[SCALE](bp(bw=8,p=3652);refs=bp(bw=11,p=1)) |
bimbo.Dev_uni_proxima |
int | 74,180,464 | 10,442,948 | 6,953,650 | 6,953,650 | 8,065,664 | 8,065,664 | 8,065,664 | vortex.sparse (for.v2 child) |
euro2016.id |
int | 2,052,497 | 6,416,000 | 5,195,978 | 5,195,978 | 2,782,234 | 2,750,353 | 2,750,353 | for.v2(bp(bw=20,p=6596);refs=bp(bw=25)) |
hashtags.twitter#in_reply_to_user_id |
int | 511,511 | 701,203 | 487,082 | 487,082 | 701,203 | 487,082 | 487,082 | for.v2(bp(bw=0,p=52367);refs=bp(bw=25,p=1)) |
airquality.p_0_5 |
int | 823,743 | 1,034,848 | 840,282 | 840,282 | 702,925 | 840,282 | 840,282 | for.v2(bp(bw=8,p=2199);refs=bp(bw=9,p=1)) |
airquality.pm_{1,2_5,10} (×2 w/ atm) |
int | 823,743 | 2,703,792 | 1,985,286 | 1,985,286 | 2,703,792 | 1,985,286 | 1,985,286 | for.v2(bp(bw=3);...) |
hashtags.Contains:* (4 cols) |
int | 511,511 | 111,888 | 101,256 | 100,770 | 57,469 | 57,469 | 57,469 | vortex.sparse |
hashtags.twitter#user#utc_offset |
int | 511,511 | 63,367 | 63,367 | 67,321 | 40,739 | 40,739 | 43,717 | affine[SCALE](vortex.runend;refs=vortex.dict) |
tpch_partsupp.ps_partkey |
int | 800,000 | 0 | 0 | 532 | 0 | 0 | 532 | affine[SLOPE](vortex.sparse;refs=vortex.sequence) |
Release Kernel & Encode Timings (Medians in ms; sca in ns/probe over 4,096 probes; _cl = clustered 1% chunks)
| Column | Arm | Bytes | Enc | Dec | sca (ns) |
f1% | f1%_cl | f10% | f50% | t1% | t1%_cl | t10% | t50% | cmp50 | cmp1 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
taxi.pickup_datetime |
v1_noD / for_v2_noD (dict) |
65,967,104 | 332.16 | 25.01 | 160.4 | 4.63 | 2.16 | 8.72 | 16.83 | 3.42 | 1.63 | 6.92 | 18.78 | 12.38 | 12.28 |
v2_aff_noD (affine[SCALE]) |
30,766,890 | 232.13 | 3.52 | 426.1 | 2.43 | 0.35 | 5.09 | 10.00 | 1.88 | 0.95 | 5.86 | 7.23 | 0.77 | 0.71 | |
euro2016.tweeted_at |
v1_noD (for.v1) |
10,778,892 | 12.20 | 0.57 | 111.4 | 0.10 | 0.02 | 0.75 | 0.96 | 0.05 | 0.03 | 0.70 | 1.01 | 0.57 | 0.60 |
for_v2_noD (for.v2) |
9,465,614 | 15.71 | 0.70 | 272.8 | 0.19 | 0.03 | 0.59 | 1.01 | 0.16 | 0.11 | 1.06 | 1.46 | 0.04 | 0.03 | |
v2_aff_noD (affine[SCALE]) |
4,288,180 | 33.15 | 0.36 | 409.4 | 0.14 | 0.03 | 0.51 | 1.01 | 0.12 | 0.10 | 0.56 | 0.65 | 0.05 | 0.05 | |
v2_aff_D (affine[SCALE](delta)) |
1,179,358 | 40.30 | 0.73 | 569.5 | 0.59 | 0.17 | 0.91 | 0.96 | 0.57 | 0.23 | 1.42 | 1.11 | 0.72 | 0.60 | |
airquality.KafkaTimestamp |
v1_noD (for.v1) |
5,255,040 | 8.86 | 0.19 | 62.5 | 0.03 | 0.01 | 0.22 | 0.42 | 0.02 | 0.01 | 0.26 | 0.34 | 0.24 | 0.24 |
v2_aff_noD (affine[SCALE]) |
2,273,326 | 21.31 | 0.14 | 88.8 | 0.04 | 0.01 | 0.18 | 0.37 | 0.03 | 0.01 | 0.15 | 0.25 | 0.01 | 0.00 | |
food.activity_sec |
v1_noD / for_v2_noD (dict) |
11,344,420 | 35.65 | 2.39 | 297.2 | 0.53 | 0.05 | 1.49 | 1.82 | 0.21 | 0.07 | 0.92 | 2.48 | 2.74 | 1.12 |
v2_aff_noD (affine[SCALE]) |
9,962,128 | 54.68 | 0.96 | 327.6 | 0.69 | 0.14 | 1.83 | 2.46 | 0.80 | 0.40 | 1.22 | 1.81 | 0.93 | 1.02 | |
tpch_lineitem.l_orderkey |
v1_noD (runend) |
8,625,920 | 40.67 | 3.41 | 1219.3 | 1.19 | 0.93 | 3.34 | 5.47 | 1.36 | 0.98 | 4.92 | 11.76 | 3.44 | 3.29 |
for_v2_noD (runend) |
6,563,200 | 41.54 | 3.13 | 1204.3 | 1.20 | 0.96 | 3.42 | 5.47 | 1.20 | 0.99 | 4.70 | 12.40 | 3.09 | 2.98 | |
v2_aff_noD (affine[SLOPE]) |
5,081,004 | 70.95 | 1.58 | 363.9 | 0.75 | 0.30 | 1.42 | 3.69 | 0.69 | 0.30 | 2.17 | 2.52 | 0.32 | 0.25 | |
tpch_orders.o_orderkey |
v1_noD (bp) |
4,312,960 | 11.21 | 0.35 | 29.2 | 0.06 | 0.01 | 0.59 | 0.57 | 0.06 | 0.01 | 0.47 | 0.60 | 0.35 | 0.33 |
for_v2_noD (for.v2) |
2,250,240 | 11.46 | 0.21 | 65.7 | 0.07 | 0.01 | 0.36 | 0.66 | 0.05 | 0.02 | 0.22 | 0.55 | 0.01 | 0.01 | |
v2_aff_noD (affine[ALL]) |
562,566 | 29.56 | 0.28 | 93.8 | 0.07 | 0.01 | 0.27 | 0.72 | 0.04 | 0.02 | 0.22 | 0.50 | 0.01 | 0.01 | |
bimbo.Venta_uni_hoy (rejected) |
v1_noD (bp) |
60,482,884 | 209.61 | 5.28 | 211.4 | 8.19 | 1.25 | 16.81 | 12.62 | 11.67 | 9.29 | 62.28 | 15.80 | 5.52 | 5.31 |
v2_aff_noD (bp) |
60,482,884 | 210.33 | 5.16 | 250.9 | 8.27 | 1.21 | 16.90 | 12.51 | 11.92 | 9.33 | 63.28 | 16.02 | 5.19 | 5.20 | |
bimbo.Cliente_ID (RunEnd.ends guard) |
v1_noD (runend) |
72,178,568 | 573.07 | 63.21 | 2103.1 | 13.08 | 8.11 | 31.60 | 46.80 | 12.74 | 6.10 | 56.85 | 125.94 | 37.87 | 31.99 |
v2_aff_noD (runend) |
72,178,568 | 573.73 | 58.84 | 2108.6 | 12.47 | 7.82 | 32.12 | 47.01 | 12.90 | 6.28 | 57.10 | 126.96 | 38.21 | 32.01 | |
euro2016.id (two-tier for.v2) |
v2_aff_noD (for.v2) |
5,195,978 | 30.63 | 0.19 | 241.1 | 0.14 | 0.02 | 0.47 | 0.39 | 0.27 | 0.19 | 1.88 | 0.89 | 0.03 | 0.02 |
airquality.pm_10 (two-tier for.v2) |
v2_aff_noD (for.v2) |
342,078 | 3.43 | 0.04 | 287.3 | 0.04 | 0.01 | 0.11 | 0.09 | 0.05 | 0.05 | 0.35 | 0.28 | 0.05 | 0.03 |
taxi.trip_time (rejected) |
v2_aff_noD (bp) |
31,086,700 | 46.29 | 8.68 | 274.2 | 1.88 | 0.36 | 5.24 | 9.59 | 2.70 | 2.23 | 16.47 | 11.65 | 3.97 | 3.97 |
tpch_lineitem.l_shipdate (rejected) |
v2_aff_noD (for.v1) |
9,002,496 | 7.86 | 0.67 | 66.9 | 0.55 | 0.04 | 1.28 | 1.24 | 0.29 | 0.05 | 0.82 | 1.86 | 0.77 | 0.79 |
Merging this PR will degrade performance by 12.34%Warning vortex-data has exceeded the Hobby plan limit of 5 active contributors. Upgrade your plan or apply to the open source program by December 8, 2026 to keep using CodSpeed. 2 warnings
Warning Please fix the performance issues or acknowledge them on CodSpeed. Performance Changes
Tip Investigate this regression by commenting Comparing Footnotes
|
lwwmanning
left a comment
There was a problem hiding this comment.
Posted by Claude Opus 5.5 on Will's behalf.
The decode, slice, filter, take and compare math looks right. The encoder and every decoder apply the same wrapping model, the compare rewrites hold for all six operators and both scale signs, and the edition gating and CUDA exclusion work as described.
One bug needs a fix: validation accepts an unsigned residual child as wide as a signed dtype, and decode then panics (inline).
The rest repeats what came up on #11906, at about twice the size:
- The per-chunk decoders and the galloping patch fixup copy FoR v2's kernels. Affine with scale 1 and slope 0 is FoR v2, so the two encodings should share one set of kernels.
- About 2,200 lines of filter, take and compare kernels are optimizations. The encoding decodes correctly through the generic paths without them. Landing them later, with benches, would leave this PR as the encoding, the scheme and the edition wiring, which is where the risk is.
- The tuned thresholds in take, filter and the scheme have no bench behind them, and the 16x compare claim has no bench in the tree.
compressreruns the estimate's sample cascades through a second copy of the mode decision.
| /// | ||
| /// Flat chunks (`scale == 1 && slope == 0`) unpack straight into `dst` with FastLanes' fused | ||
| /// `FoR::unchecked_unfor_pack`. | ||
| pub(super) struct AffineSameWidthBitPackedChunks<'a, T: PhysicalPType> { |
There was a problem hiding this comment.
These two chunk decoders are close copies of FoR v2's same-width and narrow decoders from #11906, and visit_surviving_patches in filter.rs re-implements FoR's galloping patch fixup. Could FoR's decoders take a per-chunk decode function, so both encodings call one copy?
|
|
||
| /// Apply surviving [`BitPacked`] patches to `values` after `filter_chunked`, decoding each | ||
| /// surviving patch residual with the model of its original `(chunk, j)` position. | ||
| fn apply_filtered_patches<T>( |
There was a problem hiding this comment.
This picks among four patch strategies, and visit_surviving_patches then picks between galloping and a bitmap scan with a 16x ratio. That is about 230 lines and two magic ratios with no benchmark. BitPacked's filter calls patches.filter(mask) and applies the result. Patches are rare by construction, so the simple path should be enough unless a bench shows otherwise.
|
|
||
| /// Above this fraction of the array, fused full-array decode plus primitive gather beats sparse | ||
| /// chunked take. | ||
| const FULL_ARRAY_DECODE_RATIO: usize = 8; |
There was a problem hiding this comment.
These ratios, and the 4096 switch in take_search, MAX_FUSED_DICT_VALUES, unpack_chunk_threshold, filter's ratios and the scheme's SAMPLE_CHUNKS, have no data in the repo, and no bench here covers take or filter. Please remove the ones no bench supports, or add the bench that chose them.
| /// Select the [`AffineOptions`] to encode with during [`AffineScheme::compress`], matching | ||
| /// [`choose_mode`] while avoiding redundant sample cascades whenever Delta arbitration is not | ||
| /// needed. | ||
| fn choose_mode_for_compress( |
There was a problem hiding this comment.
choose_mode_for_compress runs pre_estimate again and, when SCALE and a sloped mode are both viable, reruns measure_affine_bits and measure_delta_bits on the sample. The estimate already did those cascades. It also copies choose_mode's decision tree, and a comment is what keeps the two in sync. One function that returns the chosen AffineOptions for both callers would remove the drift risk.
| pub slope: bool, | ||
| /// Fit only the least-squares slope, always, as LeCo-fix does, instead of choosing the | ||
| /// narrowest of several slopes and a zero slope. Requires `slope`. | ||
| pub least_squares: bool, |
There was a problem hiding this comment.
Only tests use least_squares and AffineOptions::LECO, and the scheme never picks LECO. choose_slope_shift and choose_slope_shift_sampled share a body except for the chunk iteration, and so do evaluate and evaluate_pair. Removing LECO and merging each pair would shrink this file.
ad6b2bb to
ffc862d
Compare
236cf8d to
0ec7d3e
Compare
|
To use Codex here, create a Codex account and connect to github. |
|
Claude finished @lwwmanning's task in 54s —— View job Review of #11907 at
|
5f3bde1 to
3bf1fa5
Compare
roborev: Combined Review (
|
2527984 to
b877f94
Compare
9d45762 to
2b2269b
Compare
20ab065 to
a5d567a
Compare
Adds the per-chunk FastLanes Affine encoding (fastlanes.affine) with fused BitPacked/Dict decompression, chunk-pruned filter/take/compare compute kernels, and a default-ready BtrBlocks AffineScheme gated behind the unstable edition and excluded in CUDA mode. Replaces multi-mode trial cascades with a direct residual bit-width and outlier-patch pre-estimator so rejected columns incur negligible encode overhead while preserving the two-tier boundary with FoR.v2 and excluding RunEnd/BoolRunEnd ends and dictionary codes. Co-authored-by: Joe Isaacs <joe.isaacs@live.co.uk> Signed-off-by: Will Manning <will@willmanning.io>
…dings Signed-off-by: Will Manning <will@spiraldb.com> Co-Authored-By: Will Manning <will@spiraldb.com>
…inks Signed-off-by: Will Manning <will@spiraldb.com> Co-Authored-By: Will Manning <will@spiraldb.com>
Signed-off-by: Will Manning <will@spiraldb.com> Co-Authored-By: Will Manning <will@spiraldb.com>
Signed-off-by: Will Manning <will@spiraldb.com> Co-Authored-By: Will Manning <will@spiraldb.com>
Signed-off-by: Will Manning <will@spiraldb.com> Co-Authored-By: Will Manning <will@spiraldb.com>
Signed-off-by: Will Manning <will@spiraldb.com> Co-Authored-By: Will Manning <will@spiraldb.com>
Signed-off-by: Will Manning <will@spiraldb.com> Co-Authored-By: Will Manning <will@spiraldb.com>
a5d567a to
13ae19a
Compare
Signed-off-by: Will Manning <will@spiraldb.com> Co-Authored-By: Will Manning <will@spiraldb.com>
Signed-off-by: Will Manning <will@spiraldb.com> Co-Authored-By: Will Manning <will@spiraldb.com>
|
Closing after portfolio ablations: once FoR.v2, Delta, and an entropy leaf (vortex.rans / PIVCO) are present, Affine adds -0.32% net file-size savings (-7.6 MB across 10.39 GB raw) at a 12-15% encode throughput cost, and ~88% of its tabular delta comes from slopes == 0 cases where FoR.v2 cascading into the entropy leaf achieves the same result without a new wire format. |
This lands
Affine(fastlanes.affine), building on #11489.Affineis a per-chunk FastLanes integer encoding with a scale and an optional slope. It is in theunstableedition, andAffineSchemenow runs in the defaultBtrBlocksCompressornext toFoR.v2. CUDA mode, dictionary codes, andRunEndends do not use it.Affinehas chunk-prunedfilter,take, and constantcomparekernels, so selective scans and predicates do not decode the whole array. Before,AffineScheme::choose_moderan a trial compression cascade for each mode. After, it estimates each mode's residual bit width and outlier patches directly, so a column thatAffinedoes not suit costs almost nothing to encode.On all 110 integer and temporal columns with
Deltaoff,FoR.v2andAffinetogether cut the compressed size by 19.22%. It goes from 859.97 MB to 694.65 MB, 17.93% less than with #11906 alone. WithDeltaon, the cut is 24.23% (651.55 MB). Total corpus encode is 4% faster, and every column round-trips bit-exactly through the wire format. Ontaxi.pickup_datetime, the size drops 53.4% (65.97 MB to 30.77 MB) and full decode is 7.1× faster. A 1%filteris 1.9–6.2× faster, and a constant<compare is 16.1× faster.Stacked on #11906
Authored with AI assistance.