You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "simonvandel (via GitHub)" <gi...@apache.org> on 2024/10/12 08:08:12 UTC

[PR] Optimize `signum` function (3-25x faster) [datafusion]

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

   ## Which issue does this PR close?
   
   <!--
   We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
   -->
   Didn't create an issue beforehand.
   
   ## Rationale for this change
   
   <!--
    Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
    Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.  
   -->
   
   Same idea as https://github.com/apache/datafusion/pull/12881. Using the `unary` functions allow faster processing (most likely auto-vectorized code) by avoiding branching on nulls.
   
   ## What changes are included in this PR?
   
   <!--
   There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
   -->
   
   - Add bench
   - Apply `unary`
   
   ## Are these changes tested?
   
   <!--
   We typically require tests for all PRs in order to:
   1. Prevent the code from being accidentally broken by subsequent changes
   2. Serve as another way to document the expected behavior of the code
   
   If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
   -->
   
   Yes, with existing tests.
   
   ## Are there any user-facing changes?
   
   Yes, faster `signum`:
   
   ```
   signum f32 array: 1024  time:   [419.68 ns 420.68 ns 421.84 ns]
                           change: [-93.679% -93.655% -93.628%] (p = 0.00 < 0.05)
                           Performance has improved.
   Found 7 outliers among 100 measurements (7.00%)
     3 (3.00%) high mild
     4 (4.00%) high severe
   
   signum f64 array: 1024  time:   [1.1809 µs 1.1822 µs 1.1835 µs]
                           change: [-81.672% -81.630% -81.593%] (p = 0.00 < 0.05)
                           Performance has improved.
   Found 5 outliers among 100 measurements (5.00%)
     4 (4.00%) high mild
     1 (1.00%) high severe
   
   signum f32 array: 4096  time:   [1.1124 µs 1.1137 µs 1.1153 µs]
                           change: [-96.060% -96.049% -96.039%] (p = 0.00 < 0.05)
                           Performance has improved.
   Found 8 outliers among 100 measurements (8.00%)
     6 (6.00%) high mild
     2 (2.00%) high severe
   
   signum f64 array: 4096  time:   [5.4527 µs 5.4624 µs 5.4725 µs]
                           change: [-80.223% -80.176% -80.125%] (p = 0.00 < 0.05)
                           Performance has improved.
   Found 4 outliers among 100 measurements (4.00%)
     4 (4.00%) high mild
   
   signum f32 array: 8192  time:   [2.2937 µs 2.2959 µs 2.2983 µs]
                           change: [-96.218% -96.199% -96.181%] (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
   
   signum f64 array: 8192  time:   [15.455 µs 15.534 µs 15.630 µs]
                           change: [-75.051% -74.722% -74.440%] (p = 0.00 < 0.05)
                           Performance has improved.
   Found 5 outliers among 100 measurements (5.00%)
     4 (4.00%) high mild
     1 (1.00%) high severe
   ```
   
   <!--
   If there are user-facing changes then we may require documentation to be updated before approving the PR.
   -->
   
   <!--
   If there are any breaking changes to public APIs, please add the `api change` label.
   -->
   


-- 
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@datafusion.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] Optimize `signum` function (3-25x faster) [datafusion]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #12890:
URL: https://github.com/apache/datafusion/pull/12890#issuecomment-2410974792

   > Are we going to remove all usages of make_function_scalar_inputs_return_type?
   
   Perhaps it could be a nice ticket to file / project ti organize


-- 
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@datafusion.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] Optimize `signum` function (3-25x faster) [datafusion]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #12890:
URL: https://github.com/apache/datafusion/pull/12890#issuecomment-2410973150

   🚀 looking very nice 👌 


-- 
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@datafusion.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] Optimize `signum` function (3-25x faster) [datafusion]

Posted by "simonvandel (via GitHub)" <gi...@apache.org>.
simonvandel commented on PR #12890:
URL: https://github.com/apache/datafusion/pull/12890#issuecomment-2408857121

   I don't mind adding the benchmarks, since they
   - are easy to add
   - will benefit the next contributor wanting to try some optimizations
   - motivate me by quantifying performance of the changes I make


-- 
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@datafusion.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] Optimize `signum` function (3-25x faster) [datafusion]

Posted by "findepi (via GitHub)" <gi...@apache.org>.
findepi commented on PR #12890:
URL: https://github.com/apache/datafusion/pull/12890#issuecomment-2408688447

   Makes sense to me!
   If this is an already established knowledge that replacing `make_function_scalar_inputs_return_type` with `unary` is an improvement, I don't see a need to benchmark this every time separately. IMO we could just do this change everywhere where the code pattern is same.


-- 
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@datafusion.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] Optimize `signum` function (3-25x faster) [datafusion]

Posted by "simonvandel (via GitHub)" <gi...@apache.org>.
simonvandel commented on PR #12890:
URL: https://github.com/apache/datafusion/pull/12890#issuecomment-2408681451

   > Are we going to remove all usages of `make_function_scalar_inputs_return_type`?
   
   If the replacement always has same or better performance, I don't see why not
   


-- 
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@datafusion.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] Optimize `signum` function (3-25x faster) [datafusion]

Posted by "findepi (via GitHub)" <gi...@apache.org>.
findepi commented on PR #12890:
URL: https://github.com/apache/datafusion/pull/12890#issuecomment-2408680388

   Are we going to remove all usages of `make_function_scalar_inputs_return_type`?


-- 
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@datafusion.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] Optimize `signum` function (3-25x faster) [datafusion]

Posted by "findepi (via GitHub)" <gi...@apache.org>.
findepi commented on PR #12890:
URL: https://github.com/apache/datafusion/pull/12890#issuecomment-2411958109

   
   > > Are we going to remove all usages of make_function_scalar_inputs_return_type?
   > 
   > Perhaps it could be a nice ticket to file / project ti organize
   
   filed https://github.com/apache/datafusion/issues/12923


-- 
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@datafusion.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] Optimize `signum` function (3-25x faster) [datafusion]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb merged PR #12890:
URL: https://github.com/apache/datafusion/pull/12890


-- 
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@datafusion.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org