Merge pull request #16347 from ClickHouse/improve-performance-of-functions-logical-2

Improve performance of FunctionsLogical a little by adding "restrict"
This commit is contained in:
alexey-milovidov 2020-10-25 09:14:05 +03:00 committed by GitHub
commit 31b56b92ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -299,28 +299,29 @@ struct OperationApplier
static void apply(Columns & in, ResultData & result_data, bool use_result_data_as_input = false)
{
if (!use_result_data_as_input)
doBatchedApply<false>(in, result_data);
doBatchedApply<false>(in, result_data.data(), result_data.size());
while (!in.empty())
doBatchedApply<true>(in, result_data);
doBatchedApply<true>(in, result_data.data(), result_data.size());
}
template <bool CarryResult, typename Columns, typename ResultData>
static void NO_INLINE doBatchedApply(Columns & in, ResultData & result_data)
template <bool CarryResult, typename Columns, typename Result>
static void NO_INLINE doBatchedApply(Columns & in, Result * __restrict result_data, size_t size)
{
if (N > in.size())
{
OperationApplier<Op, OperationApplierImpl, N - 1>
::template doBatchedApply<CarryResult>(in, result_data);
::template doBatchedApply<CarryResult>(in, result_data, size);
return;
}
const OperationApplierImpl<Op, N> operation_applier_impl(in);
size_t i = 0;
for (auto & res : result_data)
for (size_t i = 0; i < size; ++i)
{
if constexpr (CarryResult)
res = Op::apply(res, operation_applier_impl.apply(i++));
result_data[i] = Op::apply(result_data[i], operation_applier_impl.apply(i));
else
res = operation_applier_impl.apply(i++);
result_data[i] = operation_applier_impl.apply(i);
}
in.erase(in.end() - N, in.end());
}
@ -331,7 +332,7 @@ template <
struct OperationApplier<Op, OperationApplierImpl, 0>
{
template <bool, typename Columns, typename Result>
static void NO_INLINE doBatchedApply(Columns &, Result &)
static void NO_INLINE doBatchedApply(Columns &, Result &, size_t)
{
throw Exception(
"OperationApplier<...>::apply(...): not enough arguments to run this method",