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"(
Allow suspicious `PRIMARY KEY`/`ORDER BY` for MergeTree (i.e. SimpleAggregateFunction).
)", 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.
)", 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.
)", 0) \
M(Bool, compile_aggregate_expressions, true, R"(

View File

@ -11,7 +11,6 @@
#include <Interpreters/Context.h>
#include <Common/assert_cast.h>
#if USE_EMBEDDED_COMPILER
# include <DataTypes/Native.h>
# include <llvm/IR/IRBuilder.h>
@ -129,11 +128,10 @@ public:
return b.CreateNot(is_null);
}
else
return b.getInt8(true);
return b.getInt8(1);
}
#endif
private:
MULTITARGET_FUNCTION_AVX2_SSE42(
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 <Interpreters/Context.h>
#if USE_EMBEDDED_COMPILER
# include <DataTypes/Native.h>
# include <llvm/IR/IRBuilder.h>
#endif
namespace DB
{
@ -107,6 +112,21 @@ public:
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:
bool use_analyzer;
};