diff --git a/cpp/core/config/GlutenConfig.h b/cpp/core/config/GlutenConfig.h index 16a18f6be903..3c47fb5479bd 100644 --- a/cpp/core/config/GlutenConfig.h +++ b/cpp/core/config/GlutenConfig.h @@ -61,6 +61,13 @@ const std::string kShuffleCompressionCodecBackend = "spark.gluten.sql.columnar.s const std::string kQatBackendName = "qat"; const std::string kIaaBackendName = "iaa"; +// Velox conf +const std::string kGlogVerboseLevel = "spark.gluten.sql.columnar.backend.velox.glogVerboseLevel"; +const uint32_t kGlogVerboseLevelDefault = 0; +const uint32_t kGlogVerboseLevelMaximum = 99; +const std::string kGlogSeverityLevel = "spark.gluten.sql.columnar.backend.velox.glogSeverityLevel"; +const uint32_t kGlogSeverityLevelDefault = 1; + std::unordered_map parseConfMap(JNIEnv* env, const uint8_t* planData, const int32_t planDataLength); diff --git a/cpp/velox/compute/VeloxBackend.cc b/cpp/velox/compute/VeloxBackend.cc index e07d43772f12..6e010ec18a11 100644 --- a/cpp/velox/compute/VeloxBackend.cc +++ b/cpp/velox/compute/VeloxBackend.cc @@ -60,12 +60,6 @@ const std::string kEnableUserExceptionStacktrace = "spark.gluten.sql.columnar.backend.velox.enableUserExceptionStacktrace"; const bool kEnableUserExceptionStacktraceDefault = true; -const std::string kGlogVerboseLevel = "spark.gluten.sql.columnar.backend.velox.glogVerboseLevel"; -const uint32_t kGlogVerboseLevelDefault = 0; - -const std::string kGlogSeverityLevel = "spark.gluten.sql.columnar.backend.velox.glogSeverityLevel"; -const uint32_t kGlogSeverityLevelDefault = 1; - const std::string kEnableSystemExceptionStacktrace = "spark.gluten.sql.columnar.backend.velox.enableSystemExceptionStacktrace"; const bool kEnableSystemExceptionStacktraceDefault = true; @@ -148,12 +142,14 @@ void VeloxBackend::init(const std::unordered_map& conf // Init glog and log level. if (!veloxcfg->get(kDebugModeEnabled, false)) { - uint32_t vlogLevel = veloxcfg->get(kGlogVerboseLevel, kGlogVerboseLevelDefault); - FLAGS_v = vlogLevel; - uint32_t severityLogLevel = veloxcfg->get(kGlogSeverityLevel, kGlogSeverityLevelDefault); - FLAGS_minloglevel = severityLogLevel; + FLAGS_v = veloxcfg->get(kGlogVerboseLevel, kGlogVerboseLevelDefault); + FLAGS_minloglevel = veloxcfg->get(kGlogSeverityLevel, kGlogSeverityLevelDefault); } else { - FLAGS_v = 99; + if (veloxcfg->isValueExists(kGlogVerboseLevel)) { + FLAGS_v = veloxcfg->get(kGlogVerboseLevel, kGlogVerboseLevelDefault); + } else { + FLAGS_v = kGlogVerboseLevelMaximum; + } } FLAGS_logtostderr = true; google::InitGoogleLogging("gluten"); diff --git a/cpp/velox/compute/VeloxRuntime.cc b/cpp/velox/compute/VeloxRuntime.cc index cda40f6c9c4d..654d374a3194 100644 --- a/cpp/velox/compute/VeloxRuntime.cc +++ b/cpp/velox/compute/VeloxRuntime.cc @@ -37,7 +37,13 @@ using namespace facebook; namespace gluten { -VeloxRuntime::VeloxRuntime(const std::unordered_map& confMap) : Runtime(confMap) {} +VeloxRuntime::VeloxRuntime(const std::unordered_map& confMap) : Runtime(confMap) { + // Refresh session config. + veloxCfg_ = std::make_shared(confMap_); + debugModeEnabled_ = veloxCfg_->get(kDebugModeEnabled, false); + FLAGS_minloglevel = veloxCfg_->get(kGlogSeverityLevel, FLAGS_minloglevel); + FLAGS_v = veloxCfg_->get(kGlogVerboseLevel, FLAGS_v); +} void VeloxRuntime::parsePlan( const uint8_t* data, @@ -45,7 +51,7 @@ void VeloxRuntime::parsePlan( SparkTaskInfo taskInfo, std::optional dumpFile) { taskInfo_ = taskInfo; - if (debugModeEnabled(confMap_)) { + if (debugModeEnabled_) { try { auto jsonPlan = substraitFromPbToJson("Plan", data, size, dumpFile); LOG(INFO) << std::string(50, '#') << " received substrait::Plan:"; @@ -59,7 +65,7 @@ void VeloxRuntime::parsePlan( } void VeloxRuntime::parseSplitInfo(const uint8_t* data, int32_t size, std::optional dumpFile) { - if (debugModeEnabled(confMap_)) { + if (debugModeEnabled_) { try { auto jsonPlan = substraitFromPbToJson("ReadRel.LocalFiles", data, size, dumpFile); LOG(INFO) << std::string(50, '#') << " received substrait::ReadRel.LocalFiles:"; @@ -111,7 +117,7 @@ std::shared_ptr VeloxRuntime::createResultIterator( const std::string& spillDir, const std::vector>& inputs, const std::unordered_map& sessionConf) { - if (debugModeEnabled(confMap_)) { + if (debugModeEnabled_) { LOG(INFO) << "VeloxRuntime session config:" << printConfig(confMap_); } diff --git a/cpp/velox/compute/VeloxRuntime.h b/cpp/velox/compute/VeloxRuntime.h index 48854829e358..0233b3f82e97 100644 --- a/cpp/velox/compute/VeloxRuntime.h +++ b/cpp/velox/compute/VeloxRuntime.h @@ -120,6 +120,10 @@ class VeloxRuntime final : public Runtime { return veloxPlan_; } + bool debugModeEnabled() const { + return debugModeEnabled_; + } + static void getInfoAndIds( const std::unordered_map>& splitInfoMap, const std::unordered_set& leafPlanNodeIds, @@ -129,6 +133,8 @@ class VeloxRuntime final : public Runtime { private: std::shared_ptr veloxPlan_; + std::shared_ptr veloxCfg_; + bool debugModeEnabled_{false}; std::unordered_map> emptySchemaBatchLoopUp_; }; diff --git a/cpp/velox/jni/VeloxJniWrapper.cc b/cpp/velox/jni/VeloxJniWrapper.cc index ee03f2dbf752..32f1bd0c8e91 100644 --- a/cpp/velox/jni/VeloxJniWrapper.cc +++ b/cpp/velox/jni/VeloxJniWrapper.cc @@ -23,6 +23,7 @@ #include #include "JniUdf.h" #include "compute/VeloxBackend.h" +#include "compute/VeloxRuntime.h" #include "config/GlutenConfig.h" #include "jni/JniError.h" #include "jni/JniFileSystem.h" @@ -94,7 +95,8 @@ Java_io_glutenproject_vectorized_PlanEvaluatorJniWrapper_nativeValidateWithFailu auto safeArray = gluten::getByteArrayElementsSafe(env, planArray); auto planData = safeArray.elems(); auto planSize = env->GetArrayLength(planArray); - if (gluten::debugModeEnabled(ctx->getConfMap())) { + auto runtime = dynamic_cast(ctx); + if (runtime->debugModeEnabled()) { try { auto jsonPlan = gluten::substraitFromPbToJson("Plan", planData, planSize, std::nullopt); LOG(INFO) << std::string(50, '#') << " received substrait::Plan: for validation"; diff --git a/cpp/velox/utils/ConfigExtractor.cc b/cpp/velox/utils/ConfigExtractor.cc index a4b5280e1640..3889fee6ad76 100644 --- a/cpp/velox/utils/ConfigExtractor.cc +++ b/cpp/velox/utils/ConfigExtractor.cc @@ -52,12 +52,6 @@ std::string getConfigValue( return got->second; } -bool debugModeEnabled(const std::unordered_map& confMap) { - std::shared_ptr veloxCfg = - std::make_shared(confMap); - return veloxCfg->get(kDebugModeEnabled, false); -} - std::shared_ptr getHiveConfig( const std::shared_ptr& conf) { auto hiveConf = std::make_shared(); diff --git a/cpp/velox/utils/ConfigExtractor.h b/cpp/velox/utils/ConfigExtractor.h index e50d058d97c6..09b1178e694a 100644 --- a/cpp/velox/utils/ConfigExtractor.h +++ b/cpp/velox/utils/ConfigExtractor.h @@ -33,8 +33,6 @@ std::string getConfigValue( const std::string& key, const std::optional& fallbackValue); -bool debugModeEnabled(const std::unordered_map& confMap); - std::shared_ptr getHiveConfig( const std::shared_ptr& conf); diff --git a/shims/common/src/main/scala/io/glutenproject/GlutenConfig.scala b/shims/common/src/main/scala/io/glutenproject/GlutenConfig.scala index 69b827e8a5fc..07adacf42079 100644 --- a/shims/common/src/main/scala/io/glutenproject/GlutenConfig.scala +++ b/shims/common/src/main/scala/io/glutenproject/GlutenConfig.scala @@ -1195,14 +1195,14 @@ object GlutenConfig { .createWithDefault(2) val COLUMNAR_VELOX_GLOG_VERBOSE_LEVEL = - buildStaticConf("spark.gluten.sql.columnar.backend.velox.glogVerboseLevel") + buildConf("spark.gluten.sql.columnar.backend.velox.glogVerboseLevel") .internal() .doc("Set glog verbose level in Velox backend, same as FLAGS_v.") .intConf .createWithDefault(0) val COLUMNAR_VELOX_GLOG_SEVERITY_LEVEL = - buildStaticConf("spark.gluten.sql.columnar.backend.velox.glogSeverityLevel") + buildConf("spark.gluten.sql.columnar.backend.velox.glogSeverityLevel") .internal() .doc("Set glog severity level in Velox backend, same as FLAGS_minloglevel.") .intConf