Commit 3062ebb
committed
Skip per-split zone-mask expansion when covering zones are uniform
`ZonedReader::pruning_evaluation` expanded the cached zone-level pruning
mask into a row-aligned bit buffer for every split, then intersected it
with the incoming mask. That cost a `Vec` of zone lengths (built eagerly,
before the future was polled), a `BitBufferMut` of the full split length,
a popcount over it, and a bitand, on every split of every scan.
For most splits the zones covering that split are uniform: either none
are pruned or all of them are. Both collapse to a constant stats mask, so
counting the covered zone bits first - a handful of bit reads via
`BitBuffer::count_range` - lets us skip the expansion entirely:
- no covered zone pruned: the stats mask is all-true, so forward the
incoming mask unchanged,
- every covered zone pruned: return `Mask::new_false` directly,
- otherwise: fall through to the existing expansion.
The zone-length computation now lives on the non-uniform path, so uniform
splits allocate nothing. Results and masks are unchanged.
The equivalence is exact, not just bit-equal. `Mask::from_buffer`
canonicalises an all-ones buffer to `AllTrue` and an all-zeros buffer to
`AllFalse`, and owned-left `bitand` short circuits on both
(`(_, AllOr::All) => self` and `(_, AllOr::None) => new_false`). So the
old code already returned the incoming mask unchanged in the no-prune
case, after an allocation and two O(n) passes to rediscover that. The new
fast paths return the same `Mask` variant, not merely the same bits. No
path in this change does more work than before; the only addition is a
`count_range` over the covering zones on the non-uniform path.
This is a simplification, not a demonstrated speedup. Two full benchmark
sweeps were run over the same commit. Every suite returned "No clear
signal", and four of the six suites common to both sweeps flipped sign:
statpopgen -6.0% then +1.8%, clickbench-sorted -2.8% then +1.4%, tpcds
-1.4% then +0.7%, polarsignals +1.7% then -2.0%. The apparent statpopgen
win came from an anomalously slow baseline: q10 measured 4.26s base /
2.94s HEAD in the first sweep and 2.88s base / 3.12s HEAD in the second,
so HEAD was stable and the base was not. A tight Parquet control does not
rule this out - it bounds host drift, not per-path measurement variance.
What holds up is the absence of a regression. The lowest-noise suites all
read zero: random-access -0.1% (controls 0.98-1.04), appian +0.2% (all
rows 0.98-1.02), string encoding +0.1% (sizes byte-identical), tpch sf=10
-0.3% (controls 0.96-1.03). CodSpeed reports no change across 1934
benchmarks. No suite in either sweep showed a credible regression.
Signed-off-by: Joe Isaacs <joe.isaacs@live.co.uk>1 parent c1ae775 commit 3062ebb
1 file changed
Lines changed: 85 additions & 35 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
10 | 9 | | |
11 | 10 | | |
12 | 11 | | |
13 | 12 | | |
14 | 13 | | |
15 | 14 | | |
16 | 15 | | |
17 | | - | |
18 | 16 | | |
| 17 | + | |
19 | 18 | | |
20 | 19 | | |
21 | 20 | | |
| |||
97 | 96 | | |
98 | 97 | | |
99 | 98 | | |
| 99 | + | |
100 | 100 | | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
107 | 106 | | |
108 | 107 | | |
109 | 108 | | |
| |||
149 | 148 | | |
150 | 149 | | |
151 | 150 | | |
152 | | - | |
| 151 | + | |
| 152 | + | |
153 | 153 | | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
170 | 159 | | |
171 | 160 | | |
172 | 161 | | |
| 162 | + | |
173 | 163 | | |
174 | | - | |
| 164 | + | |
175 | 165 | | |
176 | 166 | | |
177 | 167 | | |
178 | 168 | | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
183 | 178 | | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | 179 | | |
189 | | - | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
190 | 209 | | |
191 | 210 | | |
192 | 211 | | |
| |||
231 | 250 | | |
232 | 251 | | |
233 | 252 | | |
| 253 | + | |
234 | 254 | | |
235 | 255 | | |
236 | 256 | | |
| |||
375 | 395 | | |
376 | 396 | | |
377 | 397 | | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
378 | 428 | | |
379 | 429 | | |
380 | 430 | | |
| |||
0 commit comments