dwsmith1983 commented on PR #12018:
URL: https://github.com/apache/arrow-rs/pull/12018#issuecomment-6967721838

   I tried the per-batch choice, but it doesn't survive codegen. With the loops 
in a helper generic over `const BRANCHLESS: bool`, LLVM turns the `if` into a 
select as well, so the two instantiations come out identical, get merged, and 
the cutoff check disappears. That holds on x86-64 and aarch64 at 16 and 1 
codegen units.
   
   The asm also showed where main's branch comes from: inside `consume_batch` 
the count lives on the stack (`str x24, [sp, #160]` on aarch64, `16(%rsp)` on 
x86-64). In a separate function the count and the level thresholds stay in 
registers on both, at 16 and 1 codegen units and with thin or fat LTO. Without 
`#[inline(never)]`, LLVM inlined the `i64` instantiation back into 
`consume_batch` under the default, thin LTO and fat LTO settings and reloaded 
the thresholds from the stack on every level, hence the attribute.
   
   The branch now has three new commits: a revert to main's loop, the new 
benches (`79e6cc01`), and the outlined branchless loop. The benches add 63, 83, 
91 and 95 pct NULLs, at fractions of about 0.71, 0.48, 0.31 and 0.19. I used 91 
rather than 93, because at 93 the per-batch fraction straddles 0.25.
   
   Could you rerun the four configs with `79e6cc01` as the baseline? If `99pct 
NULLs` on V2 is still slower, I'll try a real branchy variant next. 
`std::hint::cold_path` keeps the two loops apart but is newer than the MSRV, so 
it would have to be a `#[cold]` function.
   


-- 
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