Aggregator compile only part of aggregate functions

This commit is contained in:
Maksim Kita 2021-06-27 20:43:47 +03:00
parent 92a36e38f1
commit 325b54f623
4 changed files with 241 additions and 148 deletions

View File

@ -320,13 +320,15 @@ void Aggregator::compileAggregateFunctions()
size_t aggregate_instructions_size = 0;
String functions_description;
is_aggregate_function_compiled.resize(aggregate_functions.size());
/// Add values to the aggregate functions.
for (size_t i = 0; i < aggregate_functions.size(); ++i)
{
const auto * function = aggregate_functions[i];
size_t offset_of_aggregate_function = offsets_of_aggregate_states[i];
if (function && function->isCompilable())
if (function->isCompilable())
{
AggregateFunctionWithOffset function_to_compile
{
@ -338,13 +340,17 @@ void Aggregator::compileAggregateFunctions()
functions_description += function->getDescription();
functions_description += ' ';
functions_description += std::to_string(offset_of_aggregate_function);
functions_description += ' ';
}
++aggregate_instructions_size;
is_aggregate_function_compiled[i] = function->isCompilable();
}
/// TODO: Probably better to compile more than 2 functions
if (functions_to_compile.empty() || functions_to_compile.size() != aggregate_functions.size())
if (functions_to_compile.empty())
return;
SipHash aggregate_functions_description_hash;
@ -548,10 +554,15 @@ AggregatedDataVariants::Type Aggregator::chooseAggregationMethod()
return AggregatedDataVariants::Type::serialized;
}
void Aggregator::createAggregateStates(size_t aggregate_function_start_index, AggregateDataPtr & aggregate_data) const
template <bool skip_compiled_aggregate_functions>
void Aggregator::createAggregateStates(AggregateDataPtr & aggregate_data) const
{
for (size_t j = aggregate_function_start_index; j < params.aggregates_size; ++j)
for (size_t j = 0; j < params.aggregates_size; ++j)
{
if constexpr (skip_compiled_aggregate_functions)
if (is_aggregate_function_compiled[j])
continue;
try
{
/** An exception may occur if there is a shortage of memory.
@ -563,18 +574,19 @@ void Aggregator::createAggregateStates(size_t aggregate_function_start_index, Ag
catch (...)
{
for (size_t rollback_j = 0; rollback_j < j; ++rollback_j)
{
if constexpr (skip_compiled_aggregate_functions)
if (is_aggregate_function_compiled[j])
continue;
aggregate_functions[rollback_j]->destroy(aggregate_data + offsets_of_aggregate_states[rollback_j]);
}
throw;
}
}
}
void Aggregator::createAggregateStates(AggregateDataPtr & aggregate_data) const
{
createAggregateStates(0, aggregate_data);
}
/** It's interesting - if you remove `noinline`, then gcc for some reason will inline this function, and the performance decreases (~ 10%).
* (Probably because after the inline of this function, more internal functions no longer be inlined.)
* Inline does not make sense, since the inner loop is entirely inside this function.
@ -676,32 +688,6 @@ void NO_INLINE Aggregator::executeImplBatch(
}
}
size_t compiled_functions_count = 0;
#if USE_EMBEDDED_COMPILER
#if defined(MEMORY_SANITIZER)
size_t compiled_functions_places_size = 0;
#endif
if constexpr (use_compiled_functions)
{
compiled_functions_count = compiled_aggregate_functions_holder->compiled_aggregate_functions.functions_count;
#if defined(MEMORY_SANITIZER)
if (compiled_functions_count < offsets_of_aggregate_states.size())
{
compiled_functions_places_size = offsets_of_aggregate_states[compiled_functions_count];
}
else
{
compiled_functions_places_size = total_size_of_aggregate_states;
}
#endif
}
#endif
std::unique_ptr<AggregateDataPtr[]> places(new AggregateDataPtr[rows]);
/// For all rows.
@ -724,15 +710,29 @@ void NO_INLINE Aggregator::executeImplBatch(
#if USE_EMBEDDED_COMPILER
if constexpr (use_compiled_functions)
{
compiled_aggregate_functions_holder->compiled_aggregate_functions.create_aggregate_states_function(aggregate_data);
const auto & compiled_aggregate_functions = compiled_aggregate_functions_holder->compiled_aggregate_functions;
compiled_aggregate_functions.create_aggregate_states_function(aggregate_data);
if (compiled_aggregate_functions.functions_count != aggregate_functions.size())
{
static constexpr bool skip_compiled_aggregate_functions = true;
createAggregateStates<skip_compiled_aggregate_functions>(aggregate_data);
}
#if defined(MEMORY_SANITIZER)
__msan_unpoison(aggregate_data, compiled_functions_places_size);
for (size_t i = 0; i < aggregate_functions.size(); ++i)
{
if (!is_aggregate_function_compiled[i])
continue;
__msan_unpoison(aggregate_data + offsets_of_aggregate_states[i], params.aggregates[i].function->sizeOfData());
}
#endif
}
else
#endif
createAggregateStates(compiled_functions_count, aggregate_data);
{
createAggregateStates(aggregate_data);
}
emplace_result.setMapped(aggregate_data);
}
@ -758,15 +758,17 @@ void NO_INLINE Aggregator::executeImplBatch(
if constexpr (use_compiled_functions)
{
std::vector<ColumnData> columns_data;
columns_data.reserve(aggregate_functions.size());
for (size_t compiled_function_index = 0; compiled_function_index < compiled_functions_count; ++compiled_function_index)
for (size_t i = 0; i < aggregate_functions.size(); ++i)
{
AggregateFunctionInstruction * inst = aggregate_instructions + compiled_function_index;
if (!is_aggregate_function_compiled[i])
continue;
AggregateFunctionInstruction * inst = aggregate_instructions + i;
size_t arguments_size = inst->that->getArgumentTypes().size();
for (size_t i = 0; i < arguments_size; ++i)
columns_data.emplace_back(getColumnData(inst->batch_arguments[i]));
for (size_t argument_index = 0; argument_index < arguments_size; ++argument_index)
columns_data.emplace_back(getColumnData(inst->batch_arguments[argument_index]));
}
auto add_into_aggregate_states_function = compiled_aggregate_functions_holder->compiled_aggregate_functions.add_into_aggregate_states_function;
@ -775,9 +777,16 @@ void NO_INLINE Aggregator::executeImplBatch(
#endif
/// Add values to the aggregate functions.
AggregateFunctionInstruction * inst = aggregate_instructions + compiled_functions_count;
for (; inst->that; ++inst)
for (size_t i = 0; i < aggregate_functions.size(); ++i)
{
#if USE_EMBEDDED_COMPILER
if constexpr (use_compiled_functions)
if (is_aggregate_function_compiled[i])
continue;
#endif
AggregateFunctionInstruction * inst = aggregate_instructions + i;
if (inst->offsets)
inst->batch_that->addBatchArray(rows, places.get(), inst->state_offset, inst->batch_arguments, inst->offsets, aggregates_pool);
else
@ -1360,10 +1369,11 @@ void NO_INLINE Aggregator::convertToBlockImplFinal(
auto compiled_functions = compiled_aggregate_functions_holder->compiled_aggregate_functions;
columns_data.reserve(final_aggregate_columns.size());
for (size_t i = 0; i < compiled_functions.functions_count; ++i)
for (size_t i = 0; i < params.aggregates_size; ++i)
{
if (!is_aggregate_function_compiled[i])
continue;
auto & final_aggregate_column = final_aggregate_columns[i];
final_aggregate_column = final_aggregate_column->cloneResized(places.size());
columns_data.emplace_back(getColumnData(final_aggregate_column.get()));
@ -1371,20 +1381,27 @@ void NO_INLINE Aggregator::convertToBlockImplFinal(
auto insert_aggregates_into_columns_function = compiled_functions.insert_aggregates_into_columns_function;
insert_aggregates_into_columns_function(places.size(), columns_data.data(), places.data());
aggregate_functions_destroy_index = compiled_functions.functions_count;
}
#endif
for (; aggregate_functions_destroy_index < params.aggregates_size;)
{
if constexpr (use_compiled_functions)
{
if (is_aggregate_function_compiled[aggregate_functions_destroy_index])
{
++aggregate_functions_destroy_index;
continue;
}
}
auto & final_aggregate_column = final_aggregate_columns[aggregate_functions_destroy_index];
size_t offset = offsets_of_aggregate_states[aggregate_functions_destroy_index];
/** We increase aggregate_functions_destroy_index because by function contract if insertResultIntoAndDestroyBatch
* throws exception, it also must destroy all necessary states.
* Then code need to continue to destroy other aggregate function states with next function index.
*/
* throws exception, it also must destroy all necessary states.
* Then code need to continue to destroy other aggregate function states with next function index.
*/
size_t destroy_index = aggregate_functions_destroy_index;
++aggregate_functions_destroy_index;
@ -1402,6 +1419,15 @@ void NO_INLINE Aggregator::convertToBlockImplFinal(
for (; aggregate_functions_destroy_index < params.aggregates_size; ++aggregate_functions_destroy_index)
{
if constexpr (use_compiled_functions)
{
if (is_aggregate_function_compiled[aggregate_functions_destroy_index])
{
++aggregate_functions_destroy_index;
continue;
}
}
size_t offset = offsets_of_aggregate_states[aggregate_functions_destroy_index];
aggregate_functions[aggregate_functions_destroy_index]->destroyBatch(places.size(), places.data(), offset);
}
@ -1840,22 +1866,36 @@ void NO_INLINE Aggregator::mergeDataImpl(
{
if (!inserted)
{
size_t compiled_functions_count = 0;
#if USE_EMBEDDED_COMPILER
if constexpr (use_compiled_functions)
{
const auto & compiled_functions = compiled_aggregate_functions_holder->compiled_aggregate_functions;
compiled_functions.merge_aggregate_states_function(dst, src);
compiled_functions_count = compiled_aggregate_functions_holder->compiled_aggregate_functions.functions_count;
if (compiled_aggregate_functions_holder->compiled_aggregate_functions.functions_count != params.aggregates_size)
{
for (size_t i = 0; i < params.aggregates_size; ++i)
{
if (!is_aggregate_function_compiled[i])
aggregate_functions[i]->merge(dst + offsets_of_aggregate_states[i], src + offsets_of_aggregate_states[i], arena);
}
for (size_t i = 0; i < params.aggregates_size; ++i)
{
if (!is_aggregate_function_compiled[i])
aggregate_functions[i]->destroy(src + offsets_of_aggregate_states[i]);
}
}
}
else
#endif
{
for (size_t i = 0; i < params.aggregates_size; ++i)
aggregate_functions[i]->merge(dst + offsets_of_aggregate_states[i], src + offsets_of_aggregate_states[i], arena);
for (size_t i = compiled_functions_count; i < params.aggregates_size; ++i)
aggregate_functions[i]->merge(dst + offsets_of_aggregate_states[i], src + offsets_of_aggregate_states[i], arena);
for (size_t i = compiled_functions_count; i < params.aggregates_size; ++i)
aggregate_functions[i]->destroy(src + offsets_of_aggregate_states[i]);
for (size_t i = 0; i < params.aggregates_size; ++i)
aggregate_functions[i]->destroy(src + offsets_of_aggregate_states[i]);
}
}
else
{

View File

@ -1089,6 +1089,8 @@ private:
std::shared_ptr<CompiledAggregateFunctionsHolder> compiled_aggregate_functions_holder;
#endif
std::vector<bool> is_aggregate_function_compiled;
/** Try to compile aggregate functions.
*/
void compileAggregateFunctions();
@ -1098,8 +1100,7 @@ private:
/** Create states of aggregate functions for one key.
*/
void createAggregateStates(size_t aggregate_function_start_index, AggregateDataPtr & aggregate_data) const;
template <bool skip_compiled_aggregate_functions = false>
void createAggregateStates(AggregateDataPtr & aggregate_data) const;
/** Call `destroy` methods for states of aggregate functions.

View File

@ -1,86 +1,128 @@
Aggregation using JIT compilation
Simple functions
1704509 4611700827100483880 9223360787015464643 10441337359398154812 19954243669348.844 47782393610906.42 523264
732797 4611701940806302259 9223355550934604746 977192643464016658 2054229034942.3723 13207929959132.072 475698
598875 4611701407242345792 9223362250391155632 9312163881623734456 27615161624211.875 33882422470487.816 337212
792887 4611699550286611812 9223290551912005343 6930300520201292824 27479710385933.586 144395676294829.06 252197
3807842 4611710821592843606 9223326163906184987 16710274896338005145 85240848090850.69 111553091480739.77 196036
25703952 4611709443519524003 9223353913449113943 9946868158853570839 67568783303242.086 69940119305585.88 147211
716829 4611852156092872082 9223361623076951140 15381015774917924786 170693446547158.72 149997856481568.4 90109
59183 4611730685242027332 9223354909338698162 8078812522502896568 94622946187035.42 191637641678484.4 85379
33010362 4611704682869732882 9223268545373999677 2064452191838585926 26532987929602.555 270118717805588.94 77807
800784 4611752907938305166 9223340418389788041 18082918611792817587 233352070043266.62 331337406660376.1 77492
20810645 4611712185532639162 9223218900001937412 4996531385439292694 68246505203164.63 316843341306825.3 73213
25843850 4611690025407720929 9223346023778617822 12755881190906812868 185015319325648.16 365076991941184.7 68945
23447120 4611796031755620254 9223329309291309758 17231649548755339966 255019232629204.38 455302271742203.5 67570
14739804 4611692230555590277 9223313509005166531 2458378896777063244 38308020331864.36 143744750966090.75 64174
32077710 4611884228437061959 9223352444952988904 12965822147651192908 214467085941034.7 414236870552090.9 60456
22446879 4611846229717089436 9223124373140579096 13530160492087688838 231724477077663.4 238607624382296.62 58389
170282 4611833225706935900 9223371583739401906 8076893424988479310 141657635880324.8 378452730629064.3 57017
11482817 4611708000353743073 9223337838355779113 14841435427430843458 283531099960470.8 190228928613426.25 52345
63469 4611695097019173921 9223353530156141191 6296784708578574520 120762239817777.88 287000202568456.94 52142
29103473 4611744585914335132 9223333530281362537 5908285283932344933 123712996438970.34 493926654425846.94 47758
1704509 4611700827100483880 9223360787015464643 10441337359398154812 19954243669348.844 9648741.579254271 523264
732797 4611701940806302259 9223355550934604746 977192643464016658 2054229034942.3723 51998323.94457991 475698
598875 4611701407242345792 9223362250391155632 9312163881623734456 27615161624211.875 12261797.824844675 337212
792887 4611699550286611812 9223290551912005343 6930300520201292824 27479710385933.586 53095331.60360441 252197
3807842 4611710821592843606 9223326163906184987 16710274896338005145 85240848090850.69 22373416.533275086 196036
25703952 4611709443519524003 9223353913449113943 9946868158853570839 67568783303242.086 3154349.826950714 147211
716829 4611852156092872082 9223361623076951140 15381015774917924786 170693446547158.72 201431892.4773785 90109
59183 4611730685242027332 9223354909338698162 8078812522502896568 94622946187035.42 1425270865.0901496 85379
33010362 4611704682869732882 9223268545373999677 2064452191838585926 26532987929602.555 3695122.4062526934 77807
800784 4611752907938305166 9223340418389788041 18082918611792817587 233352070043266.62 36535786.81446395 77492
20810645 4611712185532639162 9223218900001937412 4996531385439292694 68246505203164.63 6316535.831023813 73213
25843850 4611690025407720929 9223346023778617822 12755881190906812868 185015319325648.16 9962165.34831339 68945
23447120 4611796031755620254 9223329309291309758 17231649548755339966 255019232629204.38 7937191.271698021 67570
14739804 4611692230555590277 9223313509005166531 2458378896777063244 38308020331864.36 14590240.469105456 64174
32077710 4611884228437061959 9223352444952988904 12965822147651192908 214467085941034.7 7257521.096258734 60456
22446879 4611846229717089436 9223124373140579096 13530160492087688838 231724477077663.4 4737362.521046629 58389
170282 4611833225706935900 9223371583739401906 8076893424988479310 141657635880324.8 1613795518.1065989 57017
11482817 4611708000353743073 9223337838355779113 14841435427430843458 283531099960470.8 9938452.835998287 52345
63469 4611695097019173921 9223353530156141191 6296784708578574520 120762239817777.88 579655378.4603049 52142
29103473 4611744585914335132 9223333530281362537 5908285283932344933 123712996438970.34 867841.595541967 47758
Simple functions with non compilable function
1704509 4611700827100483880 9223360787015464643 10441337359398154812 4611686018427387904 19954243669348.844 9648741.579254271 523264
732797 4611701940806302259 9223355550934604746 977192643464016658 4611686018427387904 2054229034942.3723 51998323.94457991 475698
598875 4611701407242345792 9223362250391155632 9312163881623734456 4611686018427387904 27615161624211.875 12261797.824844675 337212
792887 4611699550286611812 9223290551912005343 6930300520201292824 4611686018427387904 27479710385933.586 53095331.60360441 252197
3807842 4611710821592843606 9223326163906184987 16710274896338005145 4611686018427387904 85240848090850.69 22373416.533275086 196036
25703952 4611709443519524003 9223353913449113943 9946868158853570839 4611686018427387904 67568783303242.086 3154349.826950714 147211
716829 4611852156092872082 9223361623076951140 15381015774917924786 4611686018427387904 170693446547158.72 201431892.4773785 90109
59183 4611730685242027332 9223354909338698162 8078812522502896568 4611686018427387904 94622946187035.42 1425270865.0901496 85379
33010362 4611704682869732882 9223268545373999677 2064452191838585926 4611686018427387904 26532987929602.555 3695122.4062526934 77807
800784 4611752907938305166 9223340418389788041 18082918611792817587 4611686018427387904 233352070043266.62 36535786.81446395 77492
20810645 4611712185532639162 9223218900001937412 4996531385439292694 4611686018427387904 68246505203164.63 6316535.831023813 73213
25843850 4611690025407720929 9223346023778617822 12755881190906812868 4611686018427387904 185015319325648.16 9962165.34831339 68945
23447120 4611796031755620254 9223329309291309758 17231649548755339966 4611686018427387904 255019232629204.38 7937191.271698021 67570
14739804 4611692230555590277 9223313509005166531 2458378896777063244 4611686018427387904 38308020331864.36 14590240.469105456 64174
32077710 4611884228437061959 9223352444952988904 12965822147651192908 4611686018427387904 214467085941034.7 7257521.096258734 60456
22446879 4611846229717089436 9223124373140579096 13530160492087688838 4611686018427387904 231724477077663.4 4737362.521046629 58389
170282 4611833225706935900 9223371583739401906 8076893424988479310 4611686018427387904 141657635880324.8 1613795518.1065989 57017
11482817 4611708000353743073 9223337838355779113 14841435427430843458 4611686018427387904 283531099960470.8 9938452.835998287 52345
63469 4611695097019173921 9223353530156141191 6296784708578574520 4611686018427387904 120762239817777.88 579655378.4603049 52142
29103473 4611744585914335132 9223333530281362537 5908285283932344933 4611686018427387904 123712996438970.34 867841.595541967 47758
Simple functions if combinator
1704509 4611700827100483880 9223310246721229500 16398241567152875142 62618822667209.71 nan 261874
732797 4611721382223060002 9223355550934604746 16281585268876620522 68472164943295.68 nan 237784
598875 4611701407242345792 9223362250391155632 3577699408183553052 21300140553347.42 nan 167966
792887 4611699550286611812 9223164887726235740 7088177025760385824 56461952267903.89 nan 125539
3807842 4611710821592843606 9223283397553859544 5756765290752687660 58835559208469.4 nan 97845
25703952 4611784761593342388 9223241341744449690 4782279928971192568 65182094768443.91 nan 73368
716829 4611852156092872082 9223361623076951140 8613712481895484190 191445613359755.62 nan 44993
59183 4611730685242027332 9223354909338698162 18369075291092794110 429013599530392 nan 42817
33010362 4611704682869732882 9223092117352620518 9991152681891671022 257099731913529.5 nan 38861
800784 4611752907938305166 9223309994342931384 5251877538869750510 135472890315726.03 nan 38767
20810645 4611712185532639162 9223218900001937412 11803718472901310700 323593455407553 nan 36477
25843850 4611744529689964352 9223346023778617822 127137885677350808 3700925266420.715 nan 34353
23447120 4611796031755620254 9223329309291309758 1841522159325376278 54534534450526.42 nan 33768
14739804 4611762063154116632 9223007205463222212 16302703534054321116 506987919332451.8 nan 32156
32077710 4612033458080771112 9223352444952988904 421072759851674408 13955745719596.793 nan 30172
22446879 4611846229717089436 9223124373140579096 6577134317587565298 224866980668999.47 nan 29249
170282 4611833225706935900 9223371583739401906 15764226366913732386 551447384017691 nan 28587
11482817 4611990575414646848 9223302669582414438 9828522700609834800 378121905921203.2 nan 25993
63469 4612175339998036670 9222961628400798084 17239621485933250238 663164390134376.5 nan 25996
29103473 4611744585914335132 9223035551850347954 12590190375872647672 525927999326314.7 nan 23939
1704509 4611700827100483880 9223310246721229500 16398241567152875142 62618822667209.71 2224726.7626273884 261874
732797 4611721382223060002 9223355550934604746 16281585268876620522 68472164943295.68 5898616.931652982 237784
598875 4611701407242345792 9223362250391155632 3577699408183553052 21300140553347.42 53771550.26565126 167966
792887 4611699550286611812 9223164887726235740 7088177025760385824 56461952267903.89 92835869.96920013 125539
3807842 4611710821592843606 9223283397553859544 5756765290752687660 58835559208469.4 39794091.419183925 97845
25703952 4611784761593342388 9223241341744449690 4782279928971192568 65182094768443.91 9276773.708181158 73368
716829 4611852156092872082 9223361623076951140 8613712481895484190 191445613359755.62 291083243.75407773 44993
59183 4611730685242027332 9223354909338698162 18369075291092794110 429013599530392 5925109959.715378 42817
33010362 4611704682869732882 9223092117352620518 9991152681891671022 257099731913529.5 12412830.045471078 38861
800784 4611752907938305166 9223309994342931384 5251877538869750510 135472890315726.03 53535427.52018088 38767
20810645 4611712185532639162 9223218900001937412 11803718472901310700 323593455407553 10496765.20741332 36477
25843850 4611744529689964352 9223346023778617822 127137885677350808 3700925266420.715 18966925.191309396 34353
23447120 4611796031755620254 9223329309291309758 1841522159325376278 54534534450526.42 6271211.193812284 33768
14739804 4611762063154116632 9223007205463222212 16302703534054321116 506987919332451.8 6885575.861759452 32156
32077710 4612033458080771112 9223352444952988904 421072759851674408 13955745719596.793 12220152.393889504 30172
22446879 4611846229717089436 9223124373140579096 6577134317587565298 224866980668999.47 2482202.163802278 29249
170282 4611833225706935900 9223371583739401906 15764226366913732386 551447384017691 2515144222.953728 28587
11482817 4611990575414646848 9223302669582414438 9828522700609834800 378121905921203.2 34845264.2080656 25993
63469 4612175339998036670 9222961628400798084 17239621485933250238 663164390134376.5 7825349797.6059 25996
29103473 4611744585914335132 9223035551850347954 12590190375872647672 525927999326314.7 26049107.15514301 23939
Aggregation without JIT compilation
Simple functions
1704509 4611700827100483880 9223360787015464643 10441337359398154812 19954243669348.844 47782393610906.42 523264
732797 4611701940806302259 9223355550934604746 977192643464016658 2054229034942.3723 13207929959132.072 475698
598875 4611701407242345792 9223362250391155632 9312163881623734456 27615161624211.875 33882422470487.816 337212
792887 4611699550286611812 9223290551912005343 6930300520201292824 27479710385933.586 144395676294829.06 252197
3807842 4611710821592843606 9223326163906184987 16710274896338005145 85240848090850.69 111553091480739.77 196036
25703952 4611709443519524003 9223353913449113943 9946868158853570839 67568783303242.086 69940119305585.88 147211
716829 4611852156092872082 9223361623076951140 15381015774917924786 170693446547158.72 149997856481568.4 90109
59183 4611730685242027332 9223354909338698162 8078812522502896568 94622946187035.42 191637641678484.4 85379
33010362 4611704682869732882 9223268545373999677 2064452191838585926 26532987929602.555 270118717805588.94 77807
800784 4611752907938305166 9223340418389788041 18082918611792817587 233352070043266.62 331337406660376.1 77492
20810645 4611712185532639162 9223218900001937412 4996531385439292694 68246505203164.63 316843341306825.3 73213
25843850 4611690025407720929 9223346023778617822 12755881190906812868 185015319325648.16 365076991941184.7 68945
23447120 4611796031755620254 9223329309291309758 17231649548755339966 255019232629204.38 455302271742203.5 67570
14739804 4611692230555590277 9223313509005166531 2458378896777063244 38308020331864.36 143744750966090.75 64174
32077710 4611884228437061959 9223352444952988904 12965822147651192908 214467085941034.7 414236870552090.9 60456
22446879 4611846229717089436 9223124373140579096 13530160492087688838 231724477077663.4 238607624382296.62 58389
170282 4611833225706935900 9223371583739401906 8076893424988479310 141657635880324.8 378452730629064.3 57017
11482817 4611708000353743073 9223337838355779113 14841435427430843458 283531099960470.8 190228928613426.25 52345
63469 4611695097019173921 9223353530156141191 6296784708578574520 120762239817777.88 287000202568456.94 52142
29103473 4611744585914335132 9223333530281362537 5908285283932344933 123712996438970.34 493926654425846.94 47758
1704509 4611700827100483880 9223360787015464643 10441337359398154812 19954243669348.844 9648741.579254271 523264
732797 4611701940806302259 9223355550934604746 977192643464016658 2054229034942.3723 51998323.94457991 475698
598875 4611701407242345792 9223362250391155632 9312163881623734456 27615161624211.875 12261797.824844675 337212
792887 4611699550286611812 9223290551912005343 6930300520201292824 27479710385933.586 53095331.60360441 252197
3807842 4611710821592843606 9223326163906184987 16710274896338005145 85240848090850.69 22373416.533275086 196036
25703952 4611709443519524003 9223353913449113943 9946868158853570839 67568783303242.086 3154349.826950714 147211
716829 4611852156092872082 9223361623076951140 15381015774917924786 170693446547158.72 201431892.4773785 90109
59183 4611730685242027332 9223354909338698162 8078812522502896568 94622946187035.42 1425270865.0901496 85379
33010362 4611704682869732882 9223268545373999677 2064452191838585926 26532987929602.555 3695122.4062526934 77807
800784 4611752907938305166 9223340418389788041 18082918611792817587 233352070043266.62 36535786.81446395 77492
20810645 4611712185532639162 9223218900001937412 4996531385439292694 68246505203164.63 6316535.831023813 73213
25843850 4611690025407720929 9223346023778617822 12755881190906812868 185015319325648.16 9962165.34831339 68945
23447120 4611796031755620254 9223329309291309758 17231649548755339966 255019232629204.38 7937191.271698021 67570
14739804 4611692230555590277 9223313509005166531 2458378896777063244 38308020331864.36 14590240.469105456 64174
32077710 4611884228437061959 9223352444952988904 12965822147651192908 214467085941034.7 7257521.096258734 60456
22446879 4611846229717089436 9223124373140579096 13530160492087688838 231724477077663.4 4737362.521046629 58389
170282 4611833225706935900 9223371583739401906 8076893424988479310 141657635880324.8 1613795518.1065989 57017
11482817 4611708000353743073 9223337838355779113 14841435427430843458 283531099960470.8 9938452.835998287 52345
63469 4611695097019173921 9223353530156141191 6296784708578574520 120762239817777.88 579655378.4603049 52142
29103473 4611744585914335132 9223333530281362537 5908285283932344933 123712996438970.34 867841.595541967 47758
Simple functions with non compilable function
1704509 4611700827100483880 9223360787015464643 10441337359398154812 4611686018427387904 19954243669348.844 9648741.579254271 523264
732797 4611701940806302259 9223355550934604746 977192643464016658 4611686018427387904 2054229034942.3723 51998323.94457991 475698
598875 4611701407242345792 9223362250391155632 9312163881623734456 4611686018427387904 27615161624211.875 12261797.824844675 337212
792887 4611699550286611812 9223290551912005343 6930300520201292824 4611686018427387904 27479710385933.586 53095331.60360441 252197
3807842 4611710821592843606 9223326163906184987 16710274896338005145 4611686018427387904 85240848090850.69 22373416.533275086 196036
25703952 4611709443519524003 9223353913449113943 9946868158853570839 4611686018427387904 67568783303242.086 3154349.826950714 147211
716829 4611852156092872082 9223361623076951140 15381015774917924786 4611686018427387904 170693446547158.72 201431892.4773785 90109
59183 4611730685242027332 9223354909338698162 8078812522502896568 4611686018427387904 94622946187035.42 1425270865.0901496 85379
33010362 4611704682869732882 9223268545373999677 2064452191838585926 4611686018427387904 26532987929602.555 3695122.4062526934 77807
800784 4611752907938305166 9223340418389788041 18082918611792817587 4611686018427387904 233352070043266.62 36535786.81446395 77492
20810645 4611712185532639162 9223218900001937412 4996531385439292694 4611686018427387904 68246505203164.63 6316535.831023813 73213
25843850 4611690025407720929 9223346023778617822 12755881190906812868 4611686018427387904 185015319325648.16 9962165.34831339 68945
23447120 4611796031755620254 9223329309291309758 17231649548755339966 4611686018427387904 255019232629204.38 7937191.271698021 67570
14739804 4611692230555590277 9223313509005166531 2458378896777063244 4611686018427387904 38308020331864.36 14590240.469105456 64174
32077710 4611884228437061959 9223352444952988904 12965822147651192908 4611686018427387904 214467085941034.7 7257521.096258734 60456
22446879 4611846229717089436 9223124373140579096 13530160492087688838 4611686018427387904 231724477077663.4 4737362.521046629 58389
170282 4611833225706935900 9223371583739401906 8076893424988479310 4611686018427387904 141657635880324.8 1613795518.1065989 57017
11482817 4611708000353743073 9223337838355779113 14841435427430843458 4611686018427387904 283531099960470.8 9938452.835998287 52345
63469 4611695097019173921 9223353530156141191 6296784708578574520 4611686018427387904 120762239817777.88 579655378.4603049 52142
29103473 4611744585914335132 9223333530281362537 5908285283932344933 4611686018427387904 123712996438970.34 867841.595541967 47758
Simple functions if combinator
1704509 4611700827100483880 9223310246721229500 16398241567152875142 nan 261874
732797 4611721382223060002 9223355550934604746 16281585268876620522 nan 237784
598875 4611701407242345792 9223362250391155632 3577699408183553052 nan 167966
792887 4611699550286611812 9223164887726235740 7088177025760385824 nan 125539
3807842 4611710821592843606 9223283397553859544 5756765290752687660 nan 97845
25703952 4611784761593342388 9223241341744449690 4782279928971192568 nan 73368
716829 4611852156092872082 9223361623076951140 8613712481895484190 nan 44993
59183 4611730685242027332 9223354909338698162 18369075291092794110 nan 42817
33010362 4611704682869732882 9223092117352620518 9991152681891671022 nan 38861
800784 4611752907938305166 9223309994342931384 5251877538869750510 nan 38767
20810645 4611712185532639162 9223218900001937412 11803718472901310700 nan 36477
25843850 4611744529689964352 9223346023778617822 127137885677350808 nan 34353
23447120 4611796031755620254 9223329309291309758 1841522159325376278 nan 33768
14739804 4611762063154116632 9223007205463222212 16302703534054321116 nan 32156
32077710 4612033458080771112 9223352444952988904 421072759851674408 nan 30172
22446879 4611846229717089436 9223124373140579096 6577134317587565298 nan 29249
170282 4611833225706935900 9223371583739401906 15764226366913732386 nan 28587
11482817 4611990575414646848 9223302669582414438 9828522700609834800 nan 25993
63469 4612175339998036670 9222961628400798084 17239621485933250238 nan 25996
29103473 4611744585914335132 9223035551850347954 12590190375872647672 nan 23939
1704509 4611700827100483880 9223310246721229500 16398241567152875142 2224726.7626273884 261874
732797 4611721382223060002 9223355550934604746 16281585268876620522 5898616.931652982 237784
598875 4611701407242345792 9223362250391155632 3577699408183553052 53771550.26565126 167966
792887 4611699550286611812 9223164887726235740 7088177025760385824 92835869.96920013 125539
3807842 4611710821592843606 9223283397553859544 5756765290752687660 39794091.419183925 97845
25703952 4611784761593342388 9223241341744449690 4782279928971192568 9276773.708181158 73368
716829 4611852156092872082 9223361623076951140 8613712481895484190 291083243.75407773 44993
59183 4611730685242027332 9223354909338698162 18369075291092794110 5925109959.715378 42817
33010362 4611704682869732882 9223092117352620518 9991152681891671022 12412830.045471078 38861
800784 4611752907938305166 9223309994342931384 5251877538869750510 53535427.52018088 38767
20810645 4611712185532639162 9223218900001937412 11803718472901310700 10496765.20741332 36477
25843850 4611744529689964352 9223346023778617822 127137885677350808 18966925.191309396 34353
23447120 4611796031755620254 9223329309291309758 1841522159325376278 6271211.193812284 33768
14739804 4611762063154116632 9223007205463222212 16302703534054321116 6885575.861759452 32156
32077710 4612033458080771112 9223352444952988904 421072759851674408 12220152.393889504 30172
22446879 4611846229717089436 9223124373140579096 6577134317587565298 2482202.163802278 29249
170282 4611833225706935900 9223371583739401906 15764226366913732386 2515144222.953728 28587
11482817 4611990575414646848 9223302669582414438 9828522700609834800 34845264.2080656 25993
63469 4612175339998036670 9222961628400798084 17239621485933250238 7825349797.6059 25996
29103473 4611744585914335132 9223035551850347954 12590190375872647672 26049107.15514301 23939

View File

@ -2,15 +2,21 @@ SET compile_aggregate_expressions = 1;
SET min_count_to_compile_aggregate_expression = 0;
SELECT 'Aggregation using JIT compilation';
SELECT 'Simple functions';
SELECT CounterID, min(WatchID), max(WatchID), sum(WatchID), avg(WatchID), avgWeighted(WatchID, if(WatchID % 2 == 0, 0, 1)), count(WatchID) FROM test.hits
SELECT CounterID, min(WatchID), max(WatchID), sum(WatchID), avg(WatchID), avgWeighted(WatchID, CounterID), count(WatchID) FROM test.hits
GROUP BY CounterID ORDER BY count() DESC LIMIT 20;
SELECT 'Simple functions with non compilable function';
SELECT CounterID, min(WatchID), max(WatchID), sum(WatchID), groupBitAnd(WatchID), avg(WatchID), avgWeighted(WatchID, CounterID), count(WatchID) FROM test.hits
GROUP BY CounterID ORDER BY count() DESC LIMIT 20;
SELECT 'Simple functions if combinator';
WITH (WatchID % 2 == 0) AS predicate
SELECT CounterID, minIf(WatchID,predicate), maxIf(WatchID, predicate), sumIf(WatchID, predicate), avgIf(WatchID, predicate), avgWeightedIf(WatchID, if(WatchID % 2 == 0, 0, 1), predicate), countIf(WatchID, predicate) FROM test.hits
SELECT CounterID, minIf(WatchID,predicate), maxIf(WatchID, predicate), sumIf(WatchID, predicate), avgIf(WatchID, predicate), avgWeightedIf(WatchID, CounterID, predicate), countIf(WatchID, predicate) FROM test.hits
GROUP BY CounterID ORDER BY count() DESC LIMIT 20;
SET compile_aggregate_expressions = 0;
@ -19,11 +25,15 @@ SELECT 'Aggregation without JIT compilation';
SELECT 'Simple functions';
SELECT CounterID, min(WatchID), max(WatchID), sum(WatchID), avg(WatchID), avgWeighted(WatchID, if(WatchID % 2 == 0, 0, 1)), count(WatchID) FROM test.hits
SELECT CounterID, min(WatchID), max(WatchID), sum(WatchID), avg(WatchID), avgWeighted(WatchID, CounterID), count(WatchID) FROM test.hits
GROUP BY CounterID ORDER BY count() DESC LIMIT 20;
SELECT 'Simple functions with non compilable function';
SELECT CounterID, min(WatchID), max(WatchID), sum(WatchID), groupBitAnd(WatchID), avg(WatchID), avgWeighted(WatchID, CounterID), count(WatchID) FROM test.hits
GROUP BY CounterID ORDER BY count() DESC LIMIT 20;
SELECT 'Simple functions if combinator';
WITH (WatchID % 2 == 0) AS predicate
SELECT CounterID, minIf(WatchID,predicate), maxIf(WatchID, predicate), sumIf(WatchID, predicate), avgWeightedIf(WatchID, if(WatchID % 2 == 0, 0, 1), predicate), countIf(WatchID, predicate) FROM test.hits
SELECT CounterID, minIf(WatchID,predicate), maxIf(WatchID, predicate), sumIf(WatchID, predicate), avgWeightedIf(WatchID, CounterID, predicate), countIf(WatchID, predicate) FROM test.hits
GROUP BY CounterID ORDER BY count() DESC LIMIT 20;