diff --git a/src/engine/Operation.cpp b/src/engine/Operation.cpp index 3a25e7521c..ed5d9d3cc6 100644 --- a/src/engine/Operation.cpp +++ b/src/engine/Operation.cpp @@ -598,7 +598,7 @@ const vector& Operation::getResultSortedOn() const { // _____________________________________________________________________________ void Operation::signalQueryUpdate() const { - if (_executionContext) { + if (_executionContext && _executionContext->areWebsocketUpdatesEnabled()) { _executionContext->signalQueryUpdate(*_rootRuntimeInfo); } } diff --git a/src/engine/QueryExecutionContext.h b/src/engine/QueryExecutionContext.h index dd9adf12b2..1e891a398f 100644 --- a/src/engine/QueryExecutionContext.h +++ b/src/engine/QueryExecutionContext.h @@ -5,6 +5,8 @@ #pragma once +#include + #include #include @@ -143,6 +145,12 @@ class QueryExecutionContext { bool _pinSubtrees; bool _pinResult; + // If false, then no updates of the runtime information should be sent via the + // websocket connection for performance reasons. + bool areWebsocketUpdatesEnabled() const { + return areWebsocketUpdatesEnabled_; + } + private: const Index& _index; @@ -158,4 +166,8 @@ class QueryExecutionContext { QueryPlanningCostFactors _costFactors; SortPerformanceEstimator _sortPerformanceEstimator; std::function updateCallback_; + // Cache the state of that runtime parameter to reduce the contention of the + // mutex. + bool areWebsocketUpdatesEnabled_ = + RuntimeParameters().get<"websocket-updates-enabled">(); }; diff --git a/src/global/RuntimeParameters.h b/src/global/RuntimeParameters.h index cce7e321b9..c082b14ca4 100644 --- a/src/global/RuntimeParameters.h +++ b/src/global/RuntimeParameters.h @@ -20,6 +20,7 @@ inline auto& RuntimeParameters() { // clearly misunderstand something about static initialization. static ad_utility::Parameters params = []() { using namespace std::chrono_literals; + using namespace ad_utility::memory_literals; auto ensureStrictPositivity = [](auto&& parameter) { parameter.setParameterConstraint( [](std::chrono::seconds value, std::string_view parameterName) { @@ -54,6 +55,7 @@ inline auto& RuntimeParameters() { // Control up until which size lazy results should be cached. Caching // does cause significant overhead for this case. MemorySizeParameter<"lazy-result-max-cache-size">{5_MB}, + Bool<"websocket-updates-enabled">{true}, // When the result of an index scan is smaller than a single block, then // its size estimate will be the size of the block divided by this // value.