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

   Thanks for the reruns. The `99pct NULLs` regression on Neoverse-V2 holds 
with alignment pinned (+9 to 10%, against +14 to 15% without), so it comes from 
the code, not layout.
   
   My best explanation: on mostly-null input the old `if` is never taken and 
predicts perfectly, so base skips the count for free. The new form always 
counts, which costs a few more µops per level, plus a store of `cur_offset` and 
a reload from register pressure. `llvm-mca` puts it at 8.0 against 7.0 cycles 
per list start on V2. The spanning `ldp` reload I mentioned turned out not to 
matter: it isn't on the chain carried from one level to the next.
   
   I tried three small reorderings to take out the extra loads and stores. Each 
moved the spill somewhere else, depending on the architecture or the 
codegen-units setting. One removed it under the bot's 16 CGUs but brought it 
back at `codegen-units = 1`. So I don't think source tweaks can fix it reliably.
   
   Where `289cd186` stands against `aa3e63d8`, across your runs (negative is 
faster):
   
   | | Neoverse-V2 | x86 |
   |---|---:|---:|
   | `99pct NULLs` | +9 to +15% | -2 to +3% |
   | `90pct` / `half NULLs` | +2 to +6% | -4 to +1% |
   | `Int32ListList` | -3 to -6% | -6 to -13% |
   | `Int32LongList/128 items` | -41 to -43% | -18 to -22% |
   | `Int32LongList/1024 items` | -6 to -40% | -4 to +2% |
   
   Options I see:
   
   1. Keep `289cd186` and state the trade-off in the description: mostly-null 
lists are slower on Neoverse-V2 in exchange for the long-list and nested gains, 
and x86 stays within ±3% or gets faster.
   2. Close the PR, if a regression on V2 for null-heavy lists isn't acceptable.
   3. Make the loop call-free. The `Vec::push` and 
`BooleanBufferBuilder::append` grow paths are what keep values spilling. The 
original rewrite had no calls in the loop and was 15 to 29% faster than base on 
V2 for the null and short-list cases, but it lost on long lists because it 
wrote an offset on every level. A version that fixes that would need room for 
every offset up front (about 4 bytes per level for `i32`), a counting pass 
first, or unchecked writes. It's a bigger change, so I'd do it as a follow-up 
PR rather than grow this one.
   
   What would you prefer?
   


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