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: Fix pathological perf issue in window-order-by #17650

Merged
merged 1 commit into from
Jul 16, 2024
Merged

Conversation

ritchie46
Copy link
Member

@ritchie46 ritchie46 commented Jul 16, 2024

fixes #17637

@github-actions github-actions bot added performance Performance issues or improvements python Related to Python Polars rust Related to Rust Polars labels Jul 16, 2024
.collect::<PolarsResult<_>>()?;
// Will trigger a gather for every group, so rechunk before.
let sort_by_s = sort_by_s.rechunk();
let groups = POOL.install(|| {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We forgot to launch on our thread pool, so for every group our thread pool was contending with rayon's default. This improved the single chunk query 7 times on a debug build for me.

.par_iter()
.map(|indicator| sort_by_groups_single_by(indicator, sort_by_s, options))
.collect::<PolarsResult<_>>()?;
// Will trigger a gather for every group, so rechunk before.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was the culprit.

@ritchie46 ritchie46 merged commit 4ff51a3 into main Jul 16, 2024
22 checks passed
@ritchie46 ritchie46 deleted the sort_by branch July 16, 2024 07:27
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: Calculation 200x+ slower without rechunking or sorting first
1 participant