Skip to content
This repository has been archived by the owner on Feb 20, 2023. It is now read-only.

Commit

Permalink
Enable changing the compiled_query_execution setting at runtime (#1609)
Browse files Browse the repository at this point in the history
  • Loading branch information
linmagit authored Jun 7, 2021
1 parent ac8fa84 commit 39d598b
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/include/settings/settings_callbacks.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ class Callbacks {
static void MetricsQueryTraceOutput(void *old_value, void *new_value, DBMain *db_main,
common::ManagedPointer<common::ActionContext> action_context);

/** Update the query execution mode in TrafficCop */
static void CompiledQueryExecution(void *old_value, void *new_value, DBMain *db_main,
common::ManagedPointer<common::ActionContext> action_context);

/** Set the forecast sample limit. */
static void ForecastSampleLimit(void *old_value, void *new_value, DBMain *db_main,
common::ManagedPointer<common::ActionContext> action_context);
Expand Down
4 changes: 2 additions & 2 deletions src/include/settings/settings_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -409,8 +409,8 @@ SETTING_bool(
compiled_query_execution,
"Compile queries to native machine code using LLVM, rather than relying on TPL interpretation (default: false).",
false,
false,
noisepage::settings::Callbacks::NoOp
true,
noisepage::settings::Callbacks::CompiledQueryExecution
)

SETTING_string(
Expand Down
10 changes: 9 additions & 1 deletion src/include/traffic_cop/traffic_cop.h
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,14 @@ class TrafficCop {
*/
void SetOptimizerTimeout(const uint64_t optimizer_timeout) { optimizer_timeout_ = optimizer_timeout; }

/**
* Adjust the TrafficCop's execution mode value (for use by SettingsManager)
* @param is_compiled set execution_mode_ to Compiled if true; Interpret if false
*/
void SetExecutionMode(bool is_compiled) {
execution_mode_ = is_compiled ? execution::vm::ExecutionMode::Compiled : execution::vm::ExecutionMode::Interpret;
}

/**
* @return true if query caching enabled, false otherwise
*/
Expand All @@ -274,7 +282,7 @@ class TrafficCop {
common::ManagedPointer<optimizer::StatsStorage> stats_storage_;
uint64_t optimizer_timeout_;
const bool use_query_cache_;
const execution::vm::ExecutionMode execution_mode_;
execution::vm::ExecutionMode execution_mode_;
};

} // namespace noisepage::trafficcop
8 changes: 8 additions & 0 deletions src/settings/settings_callbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,14 @@ void Callbacks::MetricsQueryTraceOutput(void *const old_value, void *const new_v
action_context->SetState(common::ActionState::SUCCESS);
}

void Callbacks::CompiledQueryExecution(void *const old_value, void *const new_value, DBMain *const db_main,
common::ManagedPointer<common::ActionContext> action_context) {
action_context->SetState(common::ActionState::IN_PROGRESS);
bool is_compiled = *static_cast<bool *>(new_value);
db_main->GetTrafficCop()->SetExecutionMode(is_compiled);
action_context->SetState(common::ActionState::SUCCESS);
}

void Callbacks::ForecastSampleLimit(void *old_value, void *new_value, DBMain *db_main,
common::ManagedPointer<common::ActionContext> action_context) {
action_context->SetState(common::ActionState::IN_PROGRESS);
Expand Down

0 comments on commit 39d598b

Please sign in to comment.