This is an automated email from the ASF dual-hosted git repository.
lihaopeng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new 17ee30c9677 [Performance](exec) Fix sin performance problem (#36358)
17ee30c9677 is described below
commit 17ee30c96775fba051304493b3cb95baff13096d
Author: HappenLee <[email protected]>
AuthorDate: Mon Jun 17 16:12:53 2024 +0800
[Performance](exec) Fix sin performance problem (#36358)
revert the patch after we support the new toolchain in
Doris:https://github.com/amosbird/ldb_toolchain_gen/releases/tag/v0.22
Thanks @amosbird
---
be/src/vec/functions/math.cpp | 25 +++++++++++++++++++++++--
1 file changed, 23 insertions(+), 2 deletions(-)
diff --git a/be/src/vec/functions/math.cpp b/be/src/vec/functions/math.cpp
index bc086ce4447..a3b54c8026d 100644
--- a/be/src/vec/functions/math.cpp
+++ b/be/src/vec/functions/math.cpp
@@ -19,6 +19,8 @@
#include <cstring>
// IWYU pragma: no_include <bits/std_abs.h>
+#include <dlfcn.h>
+
#include <cmath>
#include <string>
#include <type_traits>
@@ -214,10 +216,29 @@ struct NamePositive {
using FunctionPositive = FunctionUnaryArithmetic<PositiveImpl, NamePositive>;
-struct SinName {
+struct UnaryFunctionPlainSin {
+ using Type = DataTypeFloat64;
static constexpr auto name = "sin";
+ using FuncType = double (*)(double);
+
+ static FuncType get_sin_func() {
+ void* handle = dlopen("libm.so.6", RTLD_LAZY);
+ if (handle) {
+ if (auto sin_func = (double (*)(double))dlsym(handle, "sin");
sin_func) {
+ return sin_func;
+ }
+ dlclose(handle);
+ }
+ return std::sin;
+ }
+
+ static void execute(const double* src, double* dst) {
+ static auto sin_func = get_sin_func();
+ *dst = sin_func(*src);
+ }
};
-using FunctionSin = FunctionMathUnary<UnaryFunctionPlain<SinName, std::sin>>;
+
+using FunctionSin = FunctionMathUnary<UnaryFunctionPlainSin>;
struct SqrtName {
static constexpr auto name = "sqrt";
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]