Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: add new when-then-otherwise kernels #15089

Merged
merged 17 commits into from
Mar 18, 2024

Conversation

orlp
Copy link
Collaborator

@orlp orlp commented Mar 15, 2024

Fixes #15068.

This PR does not include the SIMD implementation. I'll do that in a follow-up PR, but we won't use the SIMD implementation for ARM anyway due to bad codegen for SimdMask::select on ARM, so I can already include benchmarks for ARM.

On Apple M1 I got the following speedups (mask% is the fraction of elements in then vs otherwise):

mask%     old          new                speedup        
polars timings u8        
0.00000   0.02525929   0.02219738         1.1x  
0.00100   0.02910158   0.02012929         1.4x  
0.01000   0.05439158   0.02014079         2.7x  
0.10000   0.27665242   0.02082679         13.3x 
0.50000   0.65478233   0.02012488         32.5x 
0.90000   0.26645138   0.01983608         13.4x 
0.99000   0.05240671   0.02002283         2.6x  
0.99900   0.02816983   0.01986192         1.4x  
1.00000   0.02423300   0.01985971         1.2x  
polars timings u8 (broadcast otherwise)         
0.00000   0.46525446   0.01984646         23.4x 
0.00100   0.46273529   0.01936929         23.9x 
0.01000   0.46829967   0.01936913         24.2x 
0.10000   0.51979821   0.01947946         26.7x 
0.50000   0.76355354   0.01926450         39.6x 
0.90000   0.51624604   0.01933525         26.7x 
0.99000   0.46921817   0.01895537         24.8x 
0.99900   0.46344254   0.01907154         24.3x 
1.00000   0.46381225   0.01925962         24.1x 
polars timings f64                              
0.00000   0.09006762   0.09574792         0.9x  
0.00100   0.10305983   0.09796342         1.1x  
0.01000   0.14941062   0.09693425         1.5x  
0.10000   0.34394075   0.09820421         3.5x  
0.50000   0.76637354   0.09134887         8.4x  
0.90000   0.31638142   0.09411667         3.4x  
0.99000   0.14092225   0.09765837         1.4x  
0.99900   0.09814958   0.09806475         1.0x  
1.00000   0.08417254   0.09562071         0.9x  
polars timings f64 (broadcast otherwise)         
0.00000   0.52636163   0.09149808         5.8x  
0.00100   0.53964625   0.08892567         6.1x  
0.01000   0.53506392   0.08688375         6.2x  
0.10000   0.59140608   0.08942167         6.6x  
0.50000   0.84946300   0.08939233         9.5x  
0.90000   0.58273454   0.08750654         6.7x  
0.99000   0.52966904   0.08492963         6.2x  
0.99900   0.52321504   0.08970133         5.8x  
1.00000   0.53637021   0.08843629         6.1x  
polars timings str                              
0.00000   0.47731292   0.23280058         2.1x  
0.00100   0.49604742   0.23696479         2.1x  
0.01000   0.62790583   0.30284708         2.1x  
0.10000   0.71476996   0.24317346         2.9x  
0.50000   1.05374433   0.22551333         4.7x  
0.90000   0.72261725   0.23241883         3.1x  
0.99000   0.62651550   0.30388683         2.1x  
0.99900   0.48815529   0.23109054         2.1x  
1.00000   0.45677750   0.21798329         2.1x  
polars timings str (broadcast otherwise)         
0.00000   1.24380221   0.19173546         6.5x  
0.00100   1.24489379   0.19009825         6.5x  
0.01000   1.33005296   0.22736504         5.8x  
0.10000   1.30071879   0.19487300         6.7x  
0.50000   1.46655796   0.19071213         7.7x  
0.90000   1.55811000   0.19063617         8.2x  
0.99000   1.58550654   0.19164250         8.3x  
0.99900   1.57938763   0.18342154         8.6x  
1.00000   1.57809433   0.18277375         8.6x

@github-actions github-actions bot added performance Performance issues or improvements python Related to Python Polars rust Related to Rust Polars labels Mar 15, 2024
Copy link

codecov bot commented Mar 15, 2024

Codecov Report

Attention: Patch coverage is 93.71482% with 67 lines in your changes are missing coverage. Please review.

Project coverage is 81.17%. Comparing base (066c262) to head (010f1d3).
Report is 2 commits behind head on main.

❗ Current head 010f1d3 differs from pull request most recent head 20f48e4. Consider uploading reports for the commit 20f48e4 to get more accurate results

Files Patch % Lines
...tes/polars-arrow/src/array/static_array_collect.rs 25.00% 18 Missing ⚠️
crates/polars-arrow/src/array/static_array.rs 15.00% 17 Missing ⚠️
crates/polars-arrow/src/array/growable/utils.rs 60.00% 8 Missing ⚠️
crates/polars-core/src/chunked_array/collect.rs 25.00% 6 Missing ⚠️
crates/polars-core/src/chunked_array/object/mod.rs 75.00% 6 Missing ⚠️
crates/polars-arrow/src/compute/utils.rs 80.00% 2 Missing ⚠️
crates/polars-arrow/src/datatypes/mod.rs 0.00% 2 Missing ⚠️
crates/polars-arrow/src/io/ipc/write/schema.rs 0.00% 2 Missing ⚠️
.../polars-core/src/datatypes/static_array_collect.rs 71.42% 2 Missing ⚠️
crates/polars-arrow/src/array/growable/binview.rs 92.85% 1 Missing ⚠️
... and 3 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #15089      +/-   ##
==========================================
+ Coverage   81.08%   81.17%   +0.09%     
==========================================
  Files        1342     1346       +4     
  Lines      174150   174777     +627     
  Branches     2459     2459              
==========================================
+ Hits       141210   141877     +667     
+ Misses      32473    32434      -39     
+ Partials      467      466       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@orlp orlp marked this pull request as ready for review March 18, 2024 11:50
@ritchie46 ritchie46 merged commit 9f7ec49 into pola-rs:main Mar 18, 2024
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Performance issues or improvements python Related to Python Polars rust Related to Rust Polars
Projects
None yet
Development

Successfully merging this pull request may close these issues.

when/then/otherwise for arrays does not work
2 participants