neilconway opened a new pull request, #21468:
URL: https://github.com/apache/datafusion/pull/21468

   ## Which issue does this PR close?
   
   - Closes #21467.
   
   ## Rationale for this change
   
   This PR implements three distinct optimizations:
   
   1. `lcm` was computing the result NULL buffer iteratively. This is 
relatively slow. Switching to Arrow's `try_binary` kernel both makes the 
implementation more concise and also improves performance by computing the 
result NULL buffer via the bitwise union of the input NULL buffers.
   2. The `gcd` scalar arg path was doing similarly; switching to Arrow's 
`try_unary` yields a similar speedup.
   3. For the `gcd` scalar path, computing the GCD can only fail in a few edge 
cases (e.g., `gcd(i64::MIN, i64::MIN)`). It is cheap to check for these 
edge-cases; for most `gcd` inputs, we can use Arrow's `unary` kernel instead of 
`try_unary`. The former is more efficient because it allows LLVM to vectorize 
the code more effectively.
   
   Benchmarks (ARM64):
   ```
     - gcd array and scalar: 2.9ms → 2.2ms, -25% faster
     - lcm both array: 2.7ms → 2.0ms, -26% faster
   ```
   
   ## What changes are included in this PR?
   
   * Add benchmark for `lcd`
   * Improve SLT test coverage
   * Move Rust unit test for `lcd` to SLT
   * Optimize `lcd` and `gcm` NULL handling
   * Optimize `gcm` to avoid overhead for edge cases
   
   ## Are these changes tested?
   
   Yes.
   
   ## Are there any 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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to