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: improve partial_lookahead #11278

Closed
wants to merge 1 commit into from
Closed

perf: improve partial_lookahead #11278

wants to merge 1 commit into from

Conversation

ritchie46
Copy link
Member

Use the previous partition point as educated guess for the first partition in binary search. I assume this fixes #11243

Still have to benchmark.

@github-actions github-actions bot added performance Performance issues or improvements python Related to Python Polars rust Related to Rust Polars labels Sep 24, 2023
@ritchie46 ritchie46 changed the title perf: improve parital_lookahead perf: improve partial_lookahead Sep 24, 2023
@ritchie46
Copy link
Member Author

@MarcoGorelli can you take a look if this improves your cases? I don't see much of a difference. 🤔

@MarcoGorelli
Copy link
Collaborator

From having tried this out on a kaggle notebook it looks like it's got slightly slower https://www.kaggle.com/code/marcogorelli/polars-timing?scriptVersionId=144087899

But the difference between the two function calls doesn't seem very large there to begin with, perhaps because they only have 2 cores there, will check later

@orlp
Copy link
Collaborator

orlp commented Sep 25, 2023

I don't think this really helps, and we should be doing this in a single linear scan anyway. In pseudo-code:

let mut i = start_offset;
let mut j = start_offset;

let mut results = Vec::with_capacity(upper_bound - lower_bound);
while i < upper_bound {
    if j < upper_bound && time[j] < time[i] + period {
        j += 1;
    } else {
        results.push((i, j-i));
        i += 1;
    }
}

@orlp orlp closed this Sep 25, 2023
@stinodego stinodego deleted the lookahead branch November 4, 2023 13:04
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.

Performance of group_by_values_iter_lookbehind could be improved?
3 participants