forked from facebookincubator/velox
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support prefix sort in spilling (facebookincubator#11384)
Summary: Spill uses timsort which is introduced in facebookincubator#6745. Use the query config `spill_enable_prefix_sort` default false to control if use prefix sort in spill, prefix sort requires extra memory such as prefix data which timsort not. Prefix sort fallbacks to stdsort when the condition is not satisfied such as sort type contains string type. So if enable prefix sort, OOM may occur and string type performance may deteriorate depending on data pattern but sort performance is much better. The sort performance accelerates 2 times vs before from 561.38ms to 323.14ms in `velox_spiller_aggregate_benchmark`, total time accelerates 18% from 139.75ms to 114.38ms. ``` /mnt/DP_disk1/code/velox/build/velox/exec/tests# ./velox_spiller_aggregate_benchmark WARNING: Logging before InitGoogleLogging() is written to STDERR I1029 16:12:05.584403 1758176 AggregateSpillBenchmarkBase.cpp:81] ======Aggregate AGGREGATE_INPUT spilling statistics====== I1029 16:12:05.584498 1758176 AggregateSpillBenchmarkBase.cpp:83] total execution time: 139.75ms I1029 16:12:05.584528 1758176 AggregateSpillBenchmarkBase.cpp:84] 10000 vectors each with 100 rows have been processed I1029 16:12:05.584535 1758176 AggregateSpillBenchmarkBase.cpp:87] peak memory usage[0B] cumulative memory usage[0B] I1029 16:12:05.584542 1758176 AggregateSpillBenchmarkBase.cpp:90] spillRuns[1] spilledInputBytes[1.49GB] spilledBytes[122.09MB] spilledRows[1000000] spilledPartitions[8] spilledFiles[8] spillFillTimeNanos[20.78ms] spillSortTimeNanos[561.38ms] spillExtractVectorTime[170.30ms] spillSerializationTimeNanos[41.86ms] spillWrites[128] spillFlushTimeNanos[13.78ms] spillWriteTimeNanos[85.34ms] maxSpillExceededLimitCount[0] spillReadBytes[0B] spillReads[0] spillReadTimeNanos[0ns] spillReadDeserializationTimeNanos[0ns] I1029 16:12:05.584635 1758176 AggregateSpillBenchmarkBase.cpp:97] spilled file /tmp/velox_test_FMUXBc/SpillerBenchmarkTest-spill-7-0-7 size 15.12MB I1029 16:12:05.584645 1758176 AggregateSpillBenchmarkBase.cpp:97] spilled file /tmp/velox_test_FMUXBc/SpillerBenchmarkTest-spill-4-0-3 size 15.37MB I1029 16:12:05.584656 1758176 AggregateSpillBenchmarkBase.cpp:97] spilled file /tmp/velox_test_FMUXBc/SpillerBenchmarkTest-spill-0-0-0 size 15.30MB I1029 16:12:05.584664 1758176 AggregateSpillBenchmarkBase.cpp:97] spilled file /tmp/velox_test_FMUXBc/SpillerBenchmarkTest-spill-5-0-4 size 15.22MB I1029 16:12:05.584672 1758176 AggregateSpillBenchmarkBase.cpp:97] spilled file /tmp/velox_test_FMUXBc/SpillerBenchmarkTest-spill-2-0-2 size 15.28MB I1029 16:12:05.584681 1758176 AggregateSpillBenchmarkBase.cpp:97] spilled file /tmp/velox_test_FMUXBc/SpillerBenchmarkTest-spill-3-0-6 size 15.23MB I1029 16:12:05.584689 1758176 AggregateSpillBenchmarkBase.cpp:97] spilled file /tmp/velox_test_FMUXBc/SpillerBenchmarkTest-spill-1-0-1 size 15.35MB I1029 16:12:05.584697 1758176 AggregateSpillBenchmarkBase.cpp:97] spilled file /tmp/velox_test_FMUXBc/SpillerBenchmarkTest-spill-6-0-5 size 15.22MB I1029 16:12:05.584717 1758176 SpillerBenchmarkBase.cpp:143] Remove spill dir: /tmp/velox_test_FMUXBc I1029 16:12:05.602726 1758176 TempDirectoryPath.cpp:29] TempDirectoryPath:: removing all files from /tmp/velox_test_FMUXBc /mnt/DP_disk1/code/velox/build/velox/exec/tests# ./velox_spiller_aggregate_benchmark WARNING: Logging before InitGoogleLogging() is written to STDERR I1029 16:12:53.025599 1758616 AggregateSpillBenchmarkBase.cpp:81] ======Aggregate AGGREGATE_INPUT spilling statistics====== I1029 16:12:53.025705 1758616 AggregateSpillBenchmarkBase.cpp:83] total execution time: 114.38ms I1029 16:12:53.025740 1758616 AggregateSpillBenchmarkBase.cpp:84] 10000 vectors each with 100 rows have been processed I1029 16:12:53.025746 1758616 AggregateSpillBenchmarkBase.cpp:87] peak memory usage[0B] cumulative memory usage[0B] I1029 16:12:53.025755 1758616 AggregateSpillBenchmarkBase.cpp:90] spillRuns[1] spilledInputBytes[1.49GB] spilledBytes[122.09MB] spilledRows[1000000] spilledPartitions[8] spilledFiles[8] spillFillTimeNanos[21.92ms] spillSortTimeNanos[323.14ms] spillExtractVectorTime[176.32ms] spillSerializationTimeNanos[46.42ms] spillWrites[128] spillFlushTimeNanos[12.87ms] spillWriteTimeNanos[92.95ms] maxSpillExceededLimitCount[0] spillReadBytes[0B] spillReads[0] spillReadTimeNanos[0ns] spillReadDeserializationTimeNanos[0ns] I1029 16:12:53.025866 1758616 AggregateSpillBenchmarkBase.cpp:97] spilled file /tmp/velox_test_5tmfHu/SpillerBenchmarkTest-spill-0-0-0 size 15.30MB I1029 16:12:53.025879 1758616 AggregateSpillBenchmarkBase.cpp:97] spilled file /tmp/velox_test_5tmfHu/SpillerBenchmarkTest-spill-5-0-2 size 15.22MB I1029 16:12:53.025890 1758616 AggregateSpillBenchmarkBase.cpp:97] spilled file /tmp/velox_test_5tmfHu/SpillerBenchmarkTest-spill-4-0-4 size 15.37MB I1029 16:12:53.025902 1758616 AggregateSpillBenchmarkBase.cpp:97] spilled file /tmp/velox_test_5tmfHu/SpillerBenchmarkTest-spill-3-0-3 size 15.23MB I1029 16:12:53.025911 1758616 AggregateSpillBenchmarkBase.cpp:97] spilled file /tmp/velox_test_5tmfHu/SpillerBenchmarkTest-spill-2-0-5 size 15.28MB I1029 16:12:53.025921 1758616 AggregateSpillBenchmarkBase.cpp:97] spilled file /tmp/velox_test_5tmfHu/SpillerBenchmarkTest-spill-1-0-1 size 15.35MB I1029 16:12:53.025933 1758616 AggregateSpillBenchmarkBase.cpp:97] spilled file /tmp/velox_test_5tmfHu/SpillerBenchmarkTest-spill-6-0-7 size 15.22MB I1029 16:12:53.025943 1758616 AggregateSpillBenchmarkBase.cpp:97] spilled file /tmp/velox_test_5tmfHu/SpillerBenchmarkTest-spill-7-0-6 size 15.12MB I1029 16:12:53.025956 1758616 SpillerBenchmarkBase.cpp:143] Remove spill dir: /tmp/velox_test_5tmfHu I1029 16:12:53.045596 1758616 TempDirectoryPath.cpp:29] TempDirectoryPath:: removing all files from /tmp/velox_test_5tmfHu ``` Pull Request resolved: facebookincubator#11384 Test Plan: Meta internal experiment result: The prefix sort on Prestissimo batch query can reduce the spill sort time by 3x from 4.24 days to 1.56 days, e2e execution time reduced from 4.68 mins to 4.17mins. Note disk write time is actually shorter on the master run without this optimization ~3.27 days (but prefix sort run took > 4 days which is probably due to ws time variance). However the timsort doesn't help much even though oss experiments show it has 2x improvement but for this query it actually caused the sort time increased from 4.24 days to 5.39 days and query e2e execution time increased to 5mins. master: 20241106_071151_00001_2t6ep prefix sort: 20241106_224754_00001_bpzfi timsort: 20241106_171314_00001_dwzr8 Reviewed By: tanjialiang Differential Revision: D65408021 Pulled By: xiaoxmeng fbshipit-source-id: dc39dc96547911cf8da9ec889e9b5d123b060999
- Loading branch information
1 parent
64661a3
commit 8c69b8b
Showing
20 changed files
with
245 additions
and
86 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.