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

Speedup new_with_metadata by removing sort #8855

Merged
merged 1 commit into from
Jan 15, 2024

Conversation

simonvandel
Copy link
Contributor

BTreeMap gives stable iteration order, so we don't need to sort

Speeds up benchmarks in sql_planner.rs by 3-8%

CC @matthewmturner who seems interested in planning performance

Bench results

[~/code/arrow-datafusion/datafusion/core/benches]$ mold -run cargo bench --bench sql_planner --profile release-nonlto
logical_select_one_from_700
time: [3.9136 ms 3.9249 ms 3.9376 ms]
change: [-8.2901% -7.9287% -7.5315%] (p = 0.00 < 0.05)
Performance has improved.
Found 6 outliers among 100 measurements (6.00%)
2 (2.00%) low mild
2 (2.00%) high mild
2 (2.00%) high severe

physical_select_one_from_700
time: [20.597 ms 20.803 ms 21.054 ms]
change: [-8.4809% -6.9620% -5.4361%] (p = 0.00 < 0.05)
Performance has improved.
Found 7 outliers among 100 measurements (7.00%)
3 (3.00%) high mild
4 (4.00%) high severe

Benchmarking logical_trivial_join_low_numbered_columns: Warming up for 3.0000 s
Warning: Unable to complete 100 samples in 5.0s. You may wish to increase target time to 9.7s, enable flat sampling, or reduce sample count to 50.
logical_trivial_join_low_numbered_columns
time: [1.9051 ms 1.9084 ms 1.9119 ms]
change: [-4.0367% -3.6755% -3.2992%] (p = 0.00 < 0.05)
Performance has improved.
Found 12 outliers among 100 measurements (12.00%)
7 (7.00%) high mild
5 (5.00%) high severe

logical_trivial_join_high_numbered_columns
time: [1.9942 ms 2.0077 ms 2.0297 ms]
change: [-5.6552% -4.9685% -3.9991%] (p = 0.00 < 0.05)
Performance has improved.
Found 10 outliers among 100 measurements (10.00%)
1 (1.00%) low mild
2 (2.00%) high mild
7 (7.00%) high severe

logical_aggregate_with_join
time: [2.7620 ms 2.7675 ms 2.7740 ms]
change: [-7.3856% -7.0534% -6.6934%] (p = 0.00 < 0.05)
Performance has improved.
Found 8 outliers among 100 measurements (8.00%)
5 (5.00%) high mild
3 (3.00%) high severe

physical_plan_tpch time: [7.0284 ms 7.0988 ms 7.1760 ms]
change: [-5.1444% -3.0485% -1.1432%] (p = 0.00 < 0.05)
Performance has improved.
Found 12 outliers among 100 measurements (12.00%)
8 (8.00%) high mild
4 (4.00%) high severe

Which issue does this PR close?

Relates to #5637

Rationale for this change

Planning time of Datafusion is slow.

What changes are included in this PR?

Removed a sort by switching to BTreeSet instead of HashSet.

Are these changes tested?

Yes, by existing tests.

Are there any user-facing changes?

Faster planning.

BTreeMap gives stable iteration order, so we don't need to sort

Speeds up benchmarks in sql_planner.rs by 3-8%
Copy link
Contributor

@comphead comphead left a comment

Choose a reason for hiding this comment

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

nice catch. Thanks @simonvandel
I double checked tests without sort and confirm this part covered by tests and this change doesn't break anything

Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Thank you

@Dandandan Dandandan merged commit ff728d6 into apache:main Jan 15, 2024
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants