You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "RTEnzyme (via GitHub)" <gi...@apache.org> on 2024/01/12 02:18:43 UTC

[I] Add support for more fused boolean operations [arrow-rs]

RTEnzyme opened a new issue, #5297:
URL: https://github.com/apache/arrow-rs/issues/5297

   **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*)
   -->
   From issue in arrow-datafusion: https://github.com/apache/arrow-datafusion/issues/8816#issue-2074225073
   
   For the below code: https://github.com/apache/arrow-datafusion/blob/e5ba6de074affd40cb0984d503694e543d816a6c/datafusion/physical-expr/src/expressions/case.rs#L164C1-L165C1
   ```Rust
   remainder = and(&remainder, &not(&when_match)?)?;
   ```
   
   By implementing the and_not boolean function, we can fuse these two operations into one single operation, instead of performing them separately (first applying not to when_match and then applying and to remainder). This optimization has the potential to enhance the efficiency of the code for the following reasons:
   - The and_not function is natively implemented in x86 as ANDN, which merges the two operations into a single instruction.
   - By performing these operations in a single iteration instead of two, we can avoid materializing an extra intermediate array.
   
   **Describe the solution you'd like**
   <!--
   A clear and concise description of what you want to happen.
   -->
   We can implement `and_not` in [boolean](https://github.com/apache/arrow-rs/blob/master/arrow-arith/src/boolean.rs) and [bitwise](https://github.com/apache/arrow-rs/blob/master/arrow-arith/src/bitwise.rs).
   
   
   **Describe alternatives you've considered**
   <!--
   A clear and concise description of any alternative solutions or features you've considered.
   -->
   
   **Additional context**
   <!--
   Add any other context or screenshots about the feature request here.
   -->
   I conduct a [benchmark](https://github.com/apache/arrow-datafusion/issues/8816#issuecomment-1886252573) to show the improvement:
   
   | array_length | and(lhs, not(rhs)) | and_not(lhs, rhs) | Improvement Ratio|
   |--------------|-------------------|------------------|------------------|
   | 100 | 149.17 ns | 102.88 ns | 31.11% |
   | 1000 | 167.16 ns | 78.770 ns | 52.89% |
   | 10000 | 270.81 ns | 90.285 ns | 66.67% |
   | 100000 | 666.20 ns | 336.37 ns | 49.51% |
   
   
   


-- 
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: github-unsubscribe@arrow.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Add support for more fused boolean operations [arrow-rs]

Posted by "tustvold (via GitHub)" <gi...@apache.org>.
tustvold closed issue #5297: Add support for more fused boolean operations
URL: https://github.com/apache/arrow-rs/issues/5297


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Add support for more fused boolean operations [arrow-rs]

Posted by "tustvold (via GitHub)" <gi...@apache.org>.
tustvold commented on issue #5297:
URL: https://github.com/apache/arrow-rs/issues/5297#issuecomment-1972588663

   `label_issue.py` automatically added labels {'arrow'} from #5298


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org