Skip to content

Commit

Permalink
Allow the disabling of websocket updates (#1726)
Browse files Browse the repository at this point in the history
The websocket updates (for the live updates of the "Analysis" tree) can significantly slow down queries with very many cheap operations. This change adds a runtime parameter `websocket-updates-enabled` for controlling whether websocket updates should be performed or not.
  • Loading branch information
joka921 authored Jan 24, 2025
1 parent ff47922 commit d79cf60
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/engine/Operation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ const vector<ColumnIndex>& Operation::getResultSortedOn() const {
// _____________________________________________________________________________

void Operation::signalQueryUpdate() const {
if (_executionContext) {
if (_executionContext && _executionContext->areWebsocketUpdatesEnabled()) {
_executionContext->signalQueryUpdate(*_rootRuntimeInfo);
}
}
Expand Down
12 changes: 12 additions & 0 deletions src/engine/QueryExecutionContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

#pragma once

#include <global/RuntimeParameters.h>

#include <memory>
#include <string>

Expand Down Expand Up @@ -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;

Expand All @@ -158,4 +166,8 @@ class QueryExecutionContext {
QueryPlanningCostFactors _costFactors;
SortPerformanceEstimator _sortPerformanceEstimator;
std::function<void(std::string)> updateCallback_;
// Cache the state of that runtime parameter to reduce the contention of the
// mutex.
bool areWebsocketUpdatesEnabled_ =
RuntimeParameters().get<"websocket-updates-enabled">();
};
2 changes: 2 additions & 0 deletions src/global/RuntimeParameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit d79cf60

Please sign in to comment.