Speedup new_with_metadata by removing sort #8855
Merged
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.
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.