mbutrovich commented on PR #12018: URL: https://github.com/apache/arrow-rs/pull/12018#issuecomment-6961064636
> What would you prefer? Could you try choosing the loop per batch? `child_array.len()` is known before the loop, and it must equal the final `cur_offset` ([check](https://github.com/apache/arrow-rs/blob/a6c684842b8b224790f8bba8f31c12c05482fb91/parquet/src/arrow/array_reader/list_array.rs#L211)). So `child_array.len() / levels_len` gives the fraction of levels that add a child, at no extra cost. When that fraction is low, the old `if` predicts well, so the branchy loop could run there and the branchless one everywhere else. arrow-rs already switches loops on null density in [array equality](https://github.com/apache/arrow-rs/blob/a6c684842b8b224790f8bba8f31c12c05482fb91/arrow-data/src/equal/primitive.rs#L38-L44) and [`divisor_op`](https://github.com/apache/arrow-rs/blob/a6c684842b8b224790f8bba8f31c12c05482fb91/arrow-arith/src/numeric.rs#L357). In the current benches that fraction is about 0.04 for `99pct NULLs`, 0.33 for `90pct`, 0.80 for `half NULLs`, and 0.98 for `no NULLs`. Nothing falls between 0.33 and 0.80, so the benches can't place a cutoff yet. Could you add list cases at null densities of about 0.3, 0.6, and 0.75 (fractions near 0.71, 0.48, and 0.18) to the bench commit? Then start with `child_array.len() * 4 < levels_len` and adjust from the bot results on both architectures. A helper that is generic over a `const BRANCHLESS: bool` would avoid writing eight loops by hand. The tests would also need batches on both sides of the cutoff, so that every loop runs. I don't expect this to fix the 2 to 6% on V2 for `half NULLs`, since the branchless loop would still handle it. If that remains, a sentence on the trade-off in the description is fine. -- 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]
