-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Try to improve radix sort with memory prefetching #77029
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
Closed
Closed
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
a639ed2
improve perf of order by single column
taiyang-li 5856391
commit again
taiyang-li de073b8
fix conflict
taiyang-li 97b37d8
opt2: binary search
taiyang-li 648bc91
improve radix sort
taiyang-li c1da119
Revert "improve radix sort" for no improvement
taiyang-li a3d064b
fix perf error
taiyang-li 1446130
commit again
taiyang-li 697f21f
improve radix sort
taiyang-li a168495
remove comments
taiyang-li db9ad81
change as request
taiyang-li 98f6190
Merge branch 'ClickHouse:master' into opt_single_order_by
taiyang-li d01f8fb
split prs
taiyang-li 5a3b8a2
Merge branch 'opt_single_order_by' of https://github.com/bigo-sg/Clic…
taiyang-li 6f0b51a
Merge branch 'master' into opt_single_order_by
taiyang-li ab38d6d
Merge branch 'ClickHouse:master' into opt_single_order_by
taiyang-li 0364ef6
Merge branch 'ClickHouse:master' into opt_single_order_by
taiyang-li 1ddc3ad
Merge branch 'ClickHouse:master' into opt_single_order_by
taiyang-li 59fd82d
Merge remote-tracking branch 'origin/master' into opt_single_order_by
taiyang-li f459c30
revert files
taiyang-li 92f6117
Merge branch 'opt_single_order_by' of https://github.com/bigo-sg/clic…
taiyang-li 59abf58
Merge branch 'ClickHouse:master' into opt_single_order_by
taiyang-li 45e9fd1
fix building
taiyang-li ebf72fd
Merge remote-tracking branch 'origin/master' into opt_single_order_by
taiyang-li cbafd91
improve performance
taiyang-li faff07b
add prefetch distance
taiyang-li 246272e
improve radix sort
taiyang-li 2b927d1
revert allocation alignment
taiyang-li fe47e13
Merge branch 'ClickHouse:master' into opt_single_order_by
taiyang-li 18081a3
Merge branch 'ClickHouse:master' into opt_single_order_by
taiyang-li c04bcdd
minimize CountType according to actual rows
taiyang-li File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| #include <DataTypes/DataTypesNumber.h> | ||
| #include <Functions/FunctionHelpers.h> | ||
| #include <Storages/StorageGenerateRandom.h> | ||
| #include <benchmark/benchmark.h> | ||
| #include "pcg_random.hpp" | ||
taiyang-li marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| using namespace DB; | ||
|
|
||
| static void BM_RadixSort_UInt8(benchmark::State & state) | ||
| { | ||
| pcg64 rng; | ||
| UInt64 limit = DEFAULT_BLOCK_SIZE; | ||
| auto type = std::make_shared<DataTypeUInt8>(); | ||
| auto column = fillColumnWithRandomData(type, limit, 0, 0, rng, nullptr); | ||
|
|
||
| for (auto _ : state) | ||
| { | ||
| IColumn::Permutation res; | ||
| column->getPermutation(IColumn::PermutationSortDirection::Ascending, IColumn::PermutationSortStability::Unstable, 0, 0, res); | ||
| benchmark::DoNotOptimize(res); | ||
| } | ||
| } | ||
|
|
||
| static void BM_RadixSort_Int16(benchmark::State & state) | ||
| { | ||
| pcg64 rng; | ||
| UInt64 limit = DEFAULT_BLOCK_SIZE; | ||
| auto type = std::make_shared<DataTypeInt16>(); | ||
| auto column = fillColumnWithRandomData(type, limit, 0, 0, rng, nullptr); | ||
|
|
||
| for (auto _ : state) | ||
| { | ||
| IColumn::Permutation res; | ||
| column->getPermutation(IColumn::PermutationSortDirection::Ascending, IColumn::PermutationSortStability::Unstable, 0, 0, res); | ||
| benchmark::DoNotOptimize(res); | ||
| } | ||
| } | ||
|
|
||
| static void BM_RadixSort_Int32(benchmark::State & state) | ||
| { | ||
| pcg64 rng; | ||
| UInt64 limit = DEFAULT_BLOCK_SIZE; | ||
| auto type = std::make_shared<DataTypeInt32>(); | ||
| auto column = fillColumnWithRandomData(type, limit, 0, 0, rng, nullptr); | ||
|
|
||
| for (auto _ : state) | ||
| { | ||
| IColumn::Permutation res; | ||
| column->getPermutation(IColumn::PermutationSortDirection::Ascending, IColumn::PermutationSortStability::Unstable, 0, 0, res); | ||
| benchmark::DoNotOptimize(res); | ||
| } | ||
| } | ||
|
|
||
| static void BM_RadixSort_UInt64(benchmark::State & state) | ||
| { | ||
| pcg64 rng; | ||
| UInt64 limit = DEFAULT_BLOCK_SIZE; | ||
| auto type = std::make_shared<DataTypeUInt64>(); | ||
| auto column = fillColumnWithRandomData(type, limit, 0, 0, rng, nullptr); | ||
|
|
||
| for (auto _ : state) | ||
| { | ||
| IColumn::Permutation res; | ||
| column->getPermutation(IColumn::PermutationSortDirection::Ascending, IColumn::PermutationSortStability::Unstable, 0, 0, res); | ||
| benchmark::DoNotOptimize(res); | ||
| } | ||
| } | ||
|
|
||
| BENCHMARK(BM_RadixSort_UInt8); | ||
| BENCHMARK(BM_RadixSort_Int16); | ||
| BENCHMARK(BM_RadixSort_Int32); | ||
| BENCHMARK(BM_RadixSort_UInt64); | ||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.