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: Use List's TotalEqKernel #18984

Merged
merged 1 commit into from
Sep 27, 2024

Conversation

coastalwhite
Copy link
Collaborator

This utilizes List's variant of TotalEqKernel and implements broadcasting for that kernel. This gives a nice speed-up, reduces code-bloat and reduces chance of bugs.

For a measure on how much faster this is, I did a microbenchmark:

import polars as pl
import numpy as np
from timeit import timeit

lists = [None] + [list(range(i)) for i in range(11)]
a = [lists[length] for length in np.random.randint(0, 11, 1_000_000)]
b = [lists[length] for length in np.random.randint(0, 11, 1_000_000)]

a = pl.Series('a', a)
b = pl.Series('b', b)

t = timeit(lambda: a == b, number=100)
print(f"Time: {t:.2}s")
  • Before: Time: 16s
  • After: Time: 1.9s

I feel like there is more that can be done to make this a lot faster, but I feel like this is good enough for now.

This utilizes `List`'s variant of `TotalEqKernel` and implements broadcasting
for that kernel. This gives a nice speed-up, reduces code-bloat and reduces
chance of bugs.

For a measure on how much faster this is I did a microbenchmark:

```python
import polars as pl
import numpy as np
from timeit import timeit

lists = [None] + [list(range(i)) for i in range(11)]
a = [lists[length] for length in np.random.randint(0, 11, 1_000_000)]
b = [lists[length] for length in np.random.randint(0, 11, 1_000_000)]

a = pl.Series('a', a)
b = pl.Series('b', b)

t = timeit(lambda: a == b, number=100)
print(f"Time: {t:.2}s")
```

- Before: `Time: 16s`
- After: `Time: 1.9s`

I feel like there is more that can be done to make this a lot faster, but I
feel like this is good enough for now.
@github-actions github-actions bot added performance Performance issues or improvements python Related to Python Polars rust Related to Rust Polars labels Sep 27, 2024
Copy link

codecov bot commented Sep 27, 2024

Codecov Report

Attention: Patch coverage is 89.72973% with 19 lines in your changes missing coverage. Please review.

Project coverage is 79.86%. Comparing base (3904774) to head (bfa1d64).
Report is 14 commits behind head on main.

Files with missing lines Patch % Lines
...es/polars-core/src/chunked_array/comparison/mod.rs 83.18% 19 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##             main   #18984    +/-   ##
========================================
  Coverage   79.86%   79.86%            
========================================
  Files        1523     1523            
  Lines      207504   207618   +114     
  Branches     2904     2904            
========================================
+ Hits       165720   165821   +101     
- Misses      41237    41250    +13     
  Partials      547      547            

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

@ritchie46 ritchie46 merged commit 901b243 into pola-rs:main Sep 27, 2024
26 checks passed
@coastalwhite coastalwhite deleted the perf/list-eq-kernel branch September 27, 2024 18:25
@c-peters c-peters added the accepted Ready for implementation label Sep 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted Ready for implementation performance Performance issues or improvements python Related to Python Polars rust Related to Rust Polars
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants