pdqsort performance check

This commit is contained in:
Maksim Kita 2022-01-29 21:47:32 +00:00
parent a5fc8289ae
commit 1eacd7a00c
4 changed files with 9 additions and 5 deletions

View File

@ -17,6 +17,7 @@
#include <Common/HashTable/Hash.h>
#include <base/unaligned.h>
#include <cstring> // memcpy
#include <pdqsort.h>
namespace DB
@ -812,7 +813,7 @@ void ColumnArray::getPermutationImpl(size_t limit, Permutation & res, Comparator
if (limit)
partial_sort(res.begin(), res.begin() + limit, res.end(), less);
else
std::sort(res.begin(), res.end(), less);
pdqsort(res.begin(), res.end(), less);
}
void ColumnArray::getPermutation(bool reverse, size_t limit, int nan_direction_hint, Permutation & res) const

View File

@ -8,6 +8,7 @@
#include <base/unaligned.h>
#include <base/sort.h>
#include <base/scope_guard.h>
#include <pdqsort.h>
#include <IO/WriteHelpers.h>
@ -132,7 +133,7 @@ template <is_decimal T>
void ColumnDecimal<T>::updatePermutation(bool reverse, size_t limit, int, IColumn::Permutation & res, EqualRanges & equal_ranges) const
{
auto equals = [this](size_t lhs, size_t rhs) { return data[lhs] == data[rhs]; };
auto sort = [](auto begin, auto end, auto pred) { std::sort(begin, end, pred); };
auto sort = [](auto begin, auto end, auto pred) { pdqsort(begin, end, pred); };
auto partial_sort = [](auto begin, auto mid, auto end, auto pred) { ::partial_sort(begin, mid, end, pred); };
if (reverse)

View File

@ -13,6 +13,7 @@
#include <Common/memcpySmall.h>
#include <base/sort.h>
#include <base/scope_guard.h>
#include <pdqsort.h>
#if defined(__SSE2__)
# include <emmintrin.h>
@ -192,9 +193,9 @@ void ColumnFixedString::getPermutation(bool reverse, size_t limit, int /*nan_dir
else
{
if (reverse)
std::sort(res.begin(), res.end(), greater(*this));
pdqsort(res.begin(), res.end(), greater(*this));
else
std::sort(res.begin(), res.end(), less(*this));
pdqsort(res.begin(), res.end(), less(*this));
}
}

View File

@ -13,6 +13,7 @@
#include <base/sort.h>
#include <base/unaligned.h>
#include <base/scope_guard.h>
#include <pdqsort.h>
namespace DB
@ -337,7 +338,7 @@ void ColumnString::getPermutationImpl(size_t limit, Permutation & res, Comparato
if (limit)
partial_sort(res.begin(), res.begin() + limit, res.end(), less);
else
std::sort(res.begin(), res.end(), less);
pdqsort(res.begin(), res.end(), less);
}
void ColumnString::getPermutation(bool reverse, size_t limit, int /*nan_direction_hint*/, Permutation & res) const