mightsleep opened a new pull request, #11554:
URL: https://github.com/apache/arrow-rs/pull/11554

   # Which issue does this PR close?
   
   - Part of #7458.
   
   # Rationale for this change
   
   `and_then_dense_masks` from #10968 keeps the not yet consumed bits of 
`other` in a `u128` window and refills it in a `while` loop, and without `pdep` 
each word goes through the bit loops of `bit_util::expand`. Both cost per word 
even where the masks come in whole words, as they do after row group and page 
filters.
   
   # What changes are included in this PR?
   
   - Each mask word reads its 64 bits of `other` from a 16-byte window at the 
running bit position (`BitReader`), so a word's read depends only on the 
position and consecutive words overlap. The main loop ends at the first read 
that would cross the end of `other`; the remaining words read from a 
zero-padded copy of the last 16 bytes. Output words go straight into a zeroed 
buffer.
   - Without `bmi2`, a mask word that is all set takes the next 64 bits as they 
are, and taken bits that are all clear or all set give 0 or the mask word, 
skipping `expand`. With `bmi2` the plain `pdep` stays, the branches cost more 
than it.
   
   # Are these changes tested?
   
   `test_dense_mask_and_then_mask_shapes` compares `and_then_dense_masks` with 
a bit-by-bit reference over lengths from 1 to 8195, random offsets of both 
masks, random bits around the inner slice (so a read past either end shows), 
and random, run-shaped, all-set and sparse outer masks against random, 
run-shaped and constant inner masks. The existing tests pass with and without 
`bmi2`.
   
   `row_selector` benches on GitHub runners, main / this PR, median of three 
interleaved rounds, dense path only (the others are unchanged):
   
   | case | Neoverse-N2 | Apple M1 | EPYC 7763 | EPYC 9V74, x86-64-v3 |
   |---|---|---|---|---|
   | clustered, outer 75 to 99 % | 1.29 to 1.59x | 1.33 to 1.65x | 1.52 to 
1.96x | 1.52 to 1.81x |
   | random, outer 99 % | 1.20 to 1.43x | 1.15 to 1.47x | 1.51 to 1.68x | 1.53 
to 1.72x |
   | random, inner 99 % | 1.69 to 1.74x | 1.68 to 1.95x | 1.77 to 1.81x | 1.45 
to 1.48x |
   | random, outer 75 to 80 %, inner 5 to 10 % | 1.04 to 1.07x | 1.01 to 1.17x 
| 1.10 to 1.14x | 1.43 to 1.49x |
   
   # Are there any significant user-facing changes?
   
   No.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to