This is an automated email from the ASF dual-hosted git repository.

dataroaring pushed a commit to branch branch-3.0
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-3.0 by this push:
     new 5394bf363e4 branch-3.0: [Fix](SIMDJson) manually selecting the 
implementation for different CPU architecture (#53893)
5394bf363e4 is described below

commit 5394bf363e4c9ae7322b5e04abfbd0a977d11cb1
Author: lihangyu <[email protected]>
AuthorDate: Tue Aug 12 11:06:05 2025 +0800

    branch-3.0: [Fix](SIMDJson) manually selecting the implementation for 
different CPU architecture (#53893)
    
    cherry-pick #52732
---
 be/src/runtime/exec_env_init.cpp | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/be/src/runtime/exec_env_init.cpp b/be/src/runtime/exec_env_init.cpp
index 8faaffd2831..3ec7fed673f 100644
--- a/be/src/runtime/exec_env_init.cpp
+++ b/be/src/runtime/exec_env_init.cpp
@@ -19,6 +19,7 @@
 #include <common/multi_version.h>
 #include <gen_cpp/HeartbeatService_types.h>
 #include <gen_cpp/Metrics_types.h>
+#include <simdjson.h>
 #include <sys/resource.h>
 
 #include <cerrno> // IWYU pragma: keep
@@ -121,6 +122,7 @@
 #endif
 
 namespace doris {
+
 class PBackendService_Stub;
 class PFunctionService_Stub;
 
@@ -168,6 +170,26 @@ Status ExecEnv::init(ExecEnv* env, const 
std::vector<StorePath>& store_paths,
     return env->_init(store_paths, spill_store_paths, broken_paths);
 }
 
+// pick simdjson implementation based on CPU capabilities
+inline void init_simdjson_parser() {
+    // haswell: AVX2 (2013 Intel Haswell or later, all AMD Zen processors)
+    const auto* haswell_implementation = 
simdjson::get_available_implementations()["haswell"];
+    if (!haswell_implementation || 
!haswell_implementation->supported_by_runtime_system()) {
+        // pick available implementation
+        for (const auto* implementation : 
simdjson::get_available_implementations()) {
+            if (implementation->supported_by_runtime_system()) {
+                LOG(INFO) << "Using SimdJSON implementation : " << 
implementation->name() << ": "
+                          << implementation->description();
+                simdjson::get_active_implementation() = implementation;
+                return;
+            }
+        }
+        LOG(WARNING) << "No available SimdJSON implementation found.";
+    } else {
+        LOG(INFO) << "Using SimdJSON Haswell implementation";
+    }
+}
+
 Status ExecEnv::_init(const std::vector<StorePath>& store_paths,
                       const std::vector<StorePath>& spill_store_paths,
                       const std::set<std::string>& broken_paths) {
@@ -356,6 +378,8 @@ Status ExecEnv::_init(const std::vector<StorePath>& 
store_paths,
     _runtime_query_statistics_mgr->start_report_thread();
     _s_ready = true;
 
+    init_simdjson_parser();
+
     // Make aws-sdk-cpp InitAPI and ShutdownAPI called in the same thread
     S3ClientFactory::instance();
     return Status::OK();


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to