valkum opened a new issue, #9152: URL: https://github.com/apache/arrow-rs/issues/9152
**Is your feature request related to a problem or challenge? Please describe what you are trying to do.** <!-- A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] (This section helps Arrow developers understand the context and *why* for this feature, in addition to the *what*) --> This is based on: https://discord.com/channels/885562378132000778/1450910501369286746 Currently, the comparison kernels for `FixedSizeBinary`, `Eq` and `Lt` (and thus also the other basic comparison operators) rely on the `ArrayOrd` impl for `FixedSizeBinary`. This is currently implemented as a `&[u8] == &[u8]` (`T::Item` is `&[u8]`) comparison, which will result in a libc `bcmp@GOTPCREL` call. Furthermore, canonical extensions like UUID are built upon `FixedSizeBinary`. UUIDs are 128-bit and thus are a perfect fit for AVX 128-bit registers. **Describe the solution you'd like** <!-- A clear and concise description of what you want to happen. --> I would like arrow-rs to use better cmp instructions in these cases. For this, we need to forward the fixed size of our binary elements to the comparison function. This will lead to more code, but we can limit this to sizes where we actually see a difference. I have one example implementation [here](https://github.com/apache/arrow-rs/compare/main...valkum:arrow-rs:improved-bin) that allowed me to collect some benchmarks (run on a noisy macbook pro m1 max). See the first commit in my branch for the benchmark code. ``` FixedSizeBinary: comparison benchmarks/eq FixedSizeBinary<16> time: [79.100 µs 79.590 µs 80.465 µs] change: [-39.566% -38.918% -38.196%] (p = 0.00 < 0.05) Performance has improved. Found 2 outliers among 100 measurements (2.00%) 1 (1.00%) high mild 1 (1.00%) high severe FixedSizeBinary: comparison benchmarks/eq scalar FixedSizeBinary time: [74.613 µs 75.119 µs 76.120 µs] change: [-42.516% -42.100% -41.551%] (p = 0.00 < 0.05) Performance has improved. Found 17 outliers among 100 measurements (17.00%) 4 (4.00%) high mild 13 (13.00%) high severe ``` My impl (second commit) was just quick and dirty to prove a point. There might be different ways to solve this issue. **Describe alternatives you've considered** <!-- A clear and concise description of any alternative solutions or features you've considered. --> Other options include the ability to provide specialized kernels you can opt in to (for example in datafusion) to avoid bloating the size of arrow-rs. In this case, I think there should be a collection of said specialized kernels, at least for canonical extensions. I haven't done any comparison on emitted code size. So I guess it comes down to the fixed sizes we pick and how much size this adds to arrow-rs. **Additional context** <!-- Add any other context or screenshots about the feature request here. --> This was inspired by looking into the call stack for operations on UUIDs. So I would like to at least include 128 as a size. -- 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]
