Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow the disabling of websocket updates #1726

Merged
merged 5 commits into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading