Commit adeda19
committed
OnPair decoder: drop redundant dict_offsets widen + tighter hot path
Local-only follow-up to the combined-table decoder (15569bb). Four
correctness-preserving micro-optimisations and some test/bench hygiene.
Not pushed; user requested local-only review.
1. Drop `OwnedDecodeInputs::dict_offsets` — the decoder only needs the
combined `(offset << 16) | length` `dict_table`, so `collect` no
longer materialises a `Buffer<u32>` for the offsets at all. The
table is built directly from whatever ptype the cascading compressor
handed back via `match_each_integer_ptype!`. Saves one
`dict_size`-element allocation per decode.
2. Single-allocation widen. `widen_to_{u16,u32}` now go through
`BufferMut::with_capacity` + `push_unchecked` + `freeze` rather than
`Vec → Buffer::copy_from`, halving allocator traffic.
3. Zero-copy widen fast path. When the cascading compressor did *not*
narrow (the common case for small dicts / wide value ranges), the
widen function refcount-bumps the underlying Arc via
`PrimitiveArray::into_buffer::<u_N>()` instead of copying.
4. `for_each_dict_slice` + `decoded_len_rows` use `dict_table`. One
`u64` load per token instead of two adjacent `u32` loads.
5. Tighter predicate kernels. `row_equals` / `row_starts_with` use raw
slice pointer math on the needle/prefix after a single length
check, instead of re-running bounds-checked subslicing on every
iteration.
Tests + bench
* New `rstest`-parameterised `test_onpair_unroll_tail_boundaries` for
`n ∈ {1, 2, 3, 4, 5, 7, 8, 9}` to stress the 4×-unrolled decode
loop's scalar tail. Plus `test_onpair_empty`.
* Bench sweeps four corpus shapes (URL/log, short, long, high-card)
across two row counts, so a regression on any shape surfaces clearly.
Benchmark (release, 30 samples, vs prior tip 15569bb)
canonicalize UrlLog 100 K 1.85 ms → 1.42 ms (-23 %)
canonicalize UrlLog 1 M 29.7 ms → 15.1 ms (-49 %)
decode_rows UrlLog 1 M 9.6 ms → 4.6 ms (-52 %)
Verified
* `cargo test -p vortex-onpair` — 16/16 (was 7/7).
* `cargo test -p vortex-btrblocks` — 35/35.
* `cargo test -p vortex-file --features onpair,tokio
--test test_onpair_string_roundtrip` — 5/5.
* `cargo clippy -p vortex-onpair -p vortex-onpair-sys
-p vortex-btrblocks --all-targets` — clean.
Signed-off-by: Claude <noreply@anthropic.com>1 parent 15569bb commit adeda19
5 files changed
Lines changed: 302 additions & 146 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
15 | | - | |
| 14 | + | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
57 | 59 | | |
58 | | - | |
| 60 | + | |
59 | 61 | | |
60 | 62 | | |
61 | 63 | | |
62 | | - | |
63 | | - | |
64 | | - | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
65 | 111 | | |
66 | 112 | | |
67 | 113 | | |
68 | 114 | | |
69 | | - | |
70 | | - | |
| 115 | + | |
| 116 | + | |
71 | 117 | | |
72 | 118 | | |
73 | 119 | | |
| |||
81 | 127 | | |
82 | 128 | | |
83 | 129 | | |
84 | | - | |
85 | 130 | | |
86 | 131 | | |
87 | 132 | | |
88 | 133 | | |
89 | | - | |
| 134 | + | |
90 | 135 | | |
91 | 136 | | |
92 | 137 | | |
93 | 138 | | |
94 | | - | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
95 | 146 | | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
101 | 153 | | |
102 | 154 | | |
103 | 155 | | |
| |||
112 | 164 | | |
113 | 165 | | |
114 | 166 | | |
115 | | - | |
116 | | - | |
117 | | - | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
118 | 171 | | |
119 | 172 | | |
120 | 173 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
| 74 | + | |
| 75 | + | |
74 | 76 | | |
75 | 77 | | |
76 | | - | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
77 | 91 | | |
78 | 92 | | |
79 | 93 | | |
80 | 94 | | |
81 | 95 | | |
82 | | - | |
| 96 | + | |
83 | 97 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
106 | 106 | | |
107 | 107 | | |
108 | 108 | | |
| 109 | + | |
| 110 | + | |
109 | 111 | | |
110 | 112 | | |
111 | | - | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
112 | 119 | | |
113 | 120 | | |
114 | 121 | | |
115 | 122 | | |
116 | 123 | | |
117 | | - | |
| 124 | + | |
118 | 125 | | |
119 | 126 | | |
120 | 127 | | |
| |||
123 | 130 | | |
124 | 131 | | |
125 | 132 | | |
| 133 | + | |
| 134 | + | |
126 | 135 | | |
127 | | - | |
| 136 | + | |
128 | 137 | | |
129 | | - | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
130 | 147 | | |
131 | 148 | | |
132 | 149 | | |
133 | | - | |
| 150 | + | |
134 | 151 | | |
135 | 152 | | |
136 | 153 | | |
| |||
0 commit comments