turn on expression compilation and set min_count_to_compile_expression to 1

This commit is contained in:
taiyang-li 2024-10-14 18:11:10 +08:00
parent 458872ba18
commit 47971c9d7a
3 changed files with 23 additions and 5 deletions

View File

@ -861,10 +861,10 @@ In CREATE TABLE statement allows specifying Variant type with similar variant ty
M(Bool, allow_suspicious_primary_key, false, R"( M(Bool, allow_suspicious_primary_key, false, R"(
Allow suspicious `PRIMARY KEY`/`ORDER BY` for MergeTree (i.e. SimpleAggregateFunction). Allow suspicious `PRIMARY KEY`/`ORDER BY` for MergeTree (i.e. SimpleAggregateFunction).
)", 0) \ )", 0) \
M(Bool, compile_expressions, false, R"( M(Bool, compile_expressions, true, R"(
Compile some scalar functions and operators to native code. Due to a bug in the LLVM compiler infrastructure, on AArch64 machines, it is known to lead to a nullptr dereference and, consequently, server crash. Do not enable this setting. Compile some scalar functions and operators to native code. Due to a bug in the LLVM compiler infrastructure, on AArch64 machines, it is known to lead to a nullptr dereference and, consequently, server crash. Do not enable this setting.
)", 0) \ )", 0) \
M(UInt64, min_count_to_compile_expression, 3, R"( M(UInt64, min_count_to_compile_expression, 1, R"(
Minimum count of executing same expression before it is get compiled. Minimum count of executing same expression before it is get compiled.
)", 0) \ )", 0) \
M(Bool, compile_aggregate_expressions, true, R"( M(Bool, compile_aggregate_expressions, true, R"(

View File

@ -11,7 +11,6 @@
#include <Interpreters/Context.h> #include <Interpreters/Context.h>
#include <Common/assert_cast.h> #include <Common/assert_cast.h>
#if USE_EMBEDDED_COMPILER #if USE_EMBEDDED_COMPILER
# include <DataTypes/Native.h> # include <DataTypes/Native.h>
# include <llvm/IR/IRBuilder.h> # include <llvm/IR/IRBuilder.h>
@ -129,11 +128,10 @@ public:
return b.CreateNot(is_null); return b.CreateNot(is_null);
} }
else else
return b.getInt8(true); return b.getInt8(1);
} }
#endif #endif
private: private:
MULTITARGET_FUNCTION_AVX2_SSE42( MULTITARGET_FUNCTION_AVX2_SSE42(
MULTITARGET_FUNCTION_HEADER(static void NO_INLINE), vectorImpl, MULTITARGET_FUNCTION_BODY((const PaddedPODArray<UInt8> & null_map, PaddedPODArray<UInt8> & res) /// NOLINT MULTITARGET_FUNCTION_HEADER(static void NO_INLINE), vectorImpl, MULTITARGET_FUNCTION_BODY((const PaddedPODArray<UInt8> & null_map, PaddedPODArray<UInt8> & res) /// NOLINT

View File

@ -10,6 +10,11 @@
#include <Core/Settings.h> #include <Core/Settings.h>
#include <Interpreters/Context.h> #include <Interpreters/Context.h>
#if USE_EMBEDDED_COMPILER
# include <DataTypes/Native.h>
# include <llvm/IR/IRBuilder.h>
#endif
namespace DB namespace DB
{ {
@ -107,6 +112,21 @@ public:
return DataTypeUInt8().createColumnConst(elem.column->size(), 0u); return DataTypeUInt8().createColumnConst(elem.column->size(), 0u);
} }
#if USE_EMBEDDED_COMPILER
bool isCompilableImpl(const DataTypes & arguments, const DataTypePtr &) const override { return canBeNativeType(arguments[0]); }
llvm::Value *
compileImpl(llvm::IRBuilderBase & builder, const ValuesWithType & arguments, const DataTypePtr & /*result_type*/) const override
{
auto & b = static_cast<llvm::IRBuilder<> &>(builder);
if (arguments[0].type->isNullable())
return b.CreateExtractValue(arguments[0].value, {1});
else
return b.getInt8(0);
}
#endif
private: private:
bool use_analyzer; bool use_analyzer;
}; };