Window function perf: Speed up rank window materialization#23021
Draft
Dandandan wants to merge 1 commit into
Draft
Window function perf: Speed up rank window materialization#23021Dandandan wants to merge 1 commit into
Dandandan wants to merge 1 commit into
Conversation
d73be11 to
a5fb331
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
Rationale for this change
rank,dense_rank,percent_rank, andcume_distcurrently materialize rank output arrays through nested iterator pipelines usingscan,repeat_n, andflatten. These paths run for every partition for rank-like window functions, so avoiding iterator layering helps both all-distinct and repeated peer-group partitions.What changes are included in this PR?
rank,dense_rank,percent_rank, andcume_dist.evaluate_all_with_rankmaterialization.Short local Criterion run on 8192 rows after the latest update:
rank10.466 us -> 1.090 us,dense_rank10.491 us -> 1.058 us,percent_rank13.093 us -> 1.877 us,cume_dist12.699 us -> 1.796 usrank7.971 us -> 3.975 us,dense_rank7.208 us -> 3.890 us,percent_rank8.910 us -> 4.176 us,cume_dist6.157 us -> 4.108 usrank7.974 us -> 1.283 us,dense_rank5.518 us -> 1.201 us,percent_rank8.134 us -> 1.190 us,cume_dist4.747 us -> 1.211 usBenchmark command:
Are these changes tested?
Yes.
cargo fmt --all cargo test -p datafusion-functions-window cargo clippy --all-targets --all-features -- -D warnings cargo bench -p datafusion-functions-window --bench rank -- --sample-size 10 --warm-up-time 1 --measurement-time 2Are there any user-facing changes?
No API or behavior changes. This only changes internal array materialization for rank-like window functions.