diff --git a/presto-native-execution/presto_cpp/main/PrestoServer.cpp b/presto-native-execution/presto_cpp/main/PrestoServer.cpp index 0a422c66e16b..4d2c56856878 100644 --- a/presto-native-execution/presto_cpp/main/PrestoServer.cpp +++ b/presto-native-execution/presto_cpp/main/PrestoServer.cpp @@ -409,6 +409,12 @@ void PrestoServer::run() { << exchangeHttpIoExecutor_->getName() << "' has " << exchangeHttpIoExecutor_->numThreads() << " threads."; + for (auto evb : exchangeHttpIoExecutor_->getAllEventBases()) { + evb->setMaxLatency( + std::chrono::milliseconds(systemConfig->exchangeIoEvbViolationThresholdMs()), + []() { RECORD_METRIC_VALUE(kCounterExchangeIoEvbViolation, 1); }, + false); + } const auto numExchangeHttpClientCpuThreads = std::max( systemConfig->exchangeHttpClientNumCpuThreadsHwMultiplier() * @@ -524,6 +530,12 @@ void PrestoServer::run() { PRESTO_STARTUP_LOG(INFO) << "HTTP Server CPU executor '" << httpSrvCpuExecutor_->getName() << "' has " << httpSrvCpuExecutor_->numThreads() << " threads."; + for (auto evb : httpSrvIoExecutor_->getAllEventBases()) { + evb->setMaxLatency( + std::chrono::milliseconds(systemConfig->httpSrvIoEvbViolationThresholdMs()), + []() { RECORD_METRIC_VALUE(kCounterHttpServerIoEvbViolation, 1); }, + false); + } } if (spillerExecutor_ != nullptr) { PRESTO_STARTUP_LOG(INFO) diff --git a/presto-native-execution/presto_cpp/main/common/Configs.cpp b/presto-native-execution/presto_cpp/main/common/Configs.cpp index 2ef3d8253ab3..173c45bb5944 100644 --- a/presto-native-execution/presto_cpp/main/common/Configs.cpp +++ b/presto-native-execution/presto_cpp/main/common/Configs.cpp @@ -240,6 +240,8 @@ SystemConfig::SystemConfig() { BOOL_PROP(kEnableRuntimeMetricsCollection, false), BOOL_PROP(kPlanValidatorFailOnNestedLoopJoin, false), STR_PROP(kPrestoDefaultNamespacePrefix, "presto.default"), + NUM_PROP(kExchangeIoEvbViolationThresholdMs, 1000), + NUM_PROP(kHttpSrvIoEvbViolationThresholdMs, 1000), }; } @@ -763,6 +765,16 @@ std::string SystemConfig::prestoDefaultNamespacePrefix() const { return optionalProperty(kPrestoDefaultNamespacePrefix).value().append("."); } +int32_t SystemConfig::exchangeIoEvbViolationThresholdMs() const { + return optionalProperty(kExchangeIoEvbViolationThresholdMs) + .value(); +} + +int32_t SystemConfig::httpSrvIoEvbViolationThresholdMs() const { + return optionalProperty(kHttpSrvIoEvbViolationThresholdMs) + .value(); +} + NodeConfig::NodeConfig() { registeredProps_ = std::unordered_map>{ diff --git a/presto-native-execution/presto_cpp/main/common/Configs.h b/presto-native-execution/presto_cpp/main/common/Configs.h index 5969006e6257..91c04f026fe8 100644 --- a/presto-native-execution/presto_cpp/main/common/Configs.h +++ b/presto-native-execution/presto_cpp/main/common/Configs.h @@ -144,7 +144,7 @@ class ConfigBase { protected: ConfigBase() : config_(std::make_unique( - std::unordered_map())){}; + std::unordered_map())) {}; // Check if all properties are registered. void checkRegisteredProperties( @@ -659,6 +659,11 @@ class SystemConfig : public ConfigBase { static constexpr std::string_view kPrestoDefaultNamespacePrefix{ "presto.default-namespace"}; + static constexpr std::string_view kExchangeIoEvbViolationThresholdMs{ + "exchange.io-evb-violation-threshold-ms"}; + static constexpr std::string_view kHttpSrvIoEvbViolationThresholdMs{ + "http-server.io-evb-violation-threshold-ms"}; + SystemConfig(); virtual ~SystemConfig() = default; @@ -898,6 +903,10 @@ class SystemConfig : public ConfigBase { bool prestoNativeSidecar() const; std::string prestoDefaultNamespacePrefix() const; + + int32_t exchangeIoEvbViolationThresholdMs() const; + + int32_t httpSrvIoEvbViolationThresholdMs() const; }; /// Provides access to node properties defined in node.properties file. diff --git a/presto-native-execution/presto_cpp/main/common/Counters.cpp b/presto-native-execution/presto_cpp/main/common/Counters.cpp index e8eeb246ed9c..61edd3ea547a 100644 --- a/presto-native-execution/presto_cpp/main/common/Counters.cpp +++ b/presto-native-execution/presto_cpp/main/common/Counters.cpp @@ -130,6 +130,10 @@ void registerPrestoMetrics() { 99, 100); + DEFINE_METRIC(kCounterExchangeIoEvbViolation, facebook::velox::StatType::COUNT); + + DEFINE_METRIC(kCounterHttpServerIoEvbViolation, facebook::velox::StatType::COUNT); + // NOTE: Metrics type exporting for thread pool executor counters are in // PeriodicTaskManager because they have dynamic names and report configs. The // following counters have their type exported there: diff --git a/presto-native-execution/presto_cpp/main/common/Counters.h b/presto-native-execution/presto_cpp/main/common/Counters.h index 55d1147e3127..fff6c08c64fd 100644 --- a/presto-native-execution/presto_cpp/main/common/Counters.h +++ b/presto-native-execution/presto_cpp/main/common/Counters.h @@ -170,6 +170,12 @@ constexpr std::string_view kCounterThreadPoolNumTotalTasksFormat{ constexpr std::string_view kCounterThreadPoolMaxIdleTimeNsFormat{ "presto_cpp.{}.max_idle_time_ns"}; +/// ================== EVB Counters ==================== +constexpr folly::StringPiece kCounterExchangeIoEvbViolation{ + "presto_cpp.exchange_io_evb_violation_count"}; +constexpr folly::StringPiece kCounterHttpServerIoEvbViolation{ + "presto_cpp.http_server_io_evb_violation_count"}; + /// ================== Memory Pushback Counters ================= /// Number of times memory pushback mechanism is triggered.