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

Commit f9ae317

Browse files
authored
Merge branch 'master' into groupby
2 parents 481a334 + ac8fa84 commit f9ae317

25 files changed

+292
-259
lines changed

src/include/catalog/catalog.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ class GarbageCollector;
2121
class RecoveryManager;
2222
} // namespace noisepage::storage
2323

24-
namespace noisepage::selfdriving {
24+
namespace noisepage::selfdriving::pilot {
2525
class PilotUtil;
26-
} // namespace noisepage::selfdriving
26+
} // namespace noisepage::selfdriving::pilot
2727

2828
namespace noisepage::catalog {
2929

@@ -141,7 +141,7 @@ class Catalog {
141141
private:
142142
DISALLOW_COPY_AND_MOVE(Catalog);
143143
friend class storage::RecoveryManager;
144-
friend class selfdriving::PilotUtil;
144+
friend class selfdriving::pilot::PilotUtil;
145145
const common::ManagedPointer<transaction::TransactionManager> txn_manager_;
146146
const common::ManagedPointer<storage::BlockStore> catalog_block_store_;
147147
const common::ManagedPointer<storage::GarbageCollector> garbage_collector_;

src/include/execution/compiler/executable_query.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
namespace noisepage {
1515
namespace selfdriving {
1616
class PipelineOperatingUnits;
17+
namespace pilot {
1718
class PilotUtil;
19+
} // namespace pilot
1820
} // namespace selfdriving
1921

2022
namespace execution {
@@ -207,7 +209,7 @@ class ExecutableQuery {
207209
// MiniRunners needs to set query_identifier and pipeline_operating_units_.
208210
friend class noisepage::runner::ExecutionRunners;
209211
friend class noisepage::runner::ExecutionRunners_SEQ0_OutputRunners_Benchmark;
210-
friend class noisepage::selfdriving::PilotUtil;
212+
friend class noisepage::selfdriving::pilot::PilotUtil;
211213
friend class noisepage::execution::compiler::CompilationContext; // SetQueryId
212214
friend class noisepage::runner::ExecutionRunners_SEQ10_0_IndexInsertRunners_Benchmark;
213215
};

src/include/execution/exec/execution_settings.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ class Workload;
3333
} // namespace noisepage::tpch
3434

3535
namespace noisepage::selfdriving {
36+
namespace pilot {
3637
class PilotUtil;
38+
} // namespace pilot
3739
} // namespace noisepage::selfdriving
3840

3941
namespace noisepage::task {
@@ -115,6 +117,6 @@ class EXPORT ExecutionSettings {
115117
friend class noisepage::optimizer::IdxJoinTest_BarOnlyScan_Test;
116118
friend class noisepage::optimizer::IdxJoinTest_IndexToIndexJoin_Test;
117119
friend class noisepage::task::TaskDML;
118-
friend class noisepage::selfdriving::PilotUtil;
120+
friend class noisepage::selfdriving::pilot::PilotUtil;
119121
};
120122
} // namespace noisepage::execution::exec

src/include/loggers/loggers_util.h

+9
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
// flush the debug logs, every <n> seconds
44
#define DEBUG_LOG_FLUSH_INTERVAL 3
55

6+
#include <optional>
7+
#include <string_view>
8+
69
#include "common/sanctioned_shared_pointer.h"
710
#include "spdlog/fmt/ostr.h"
811
#include "spdlog/sinks/basic_file_sink.h"
@@ -29,5 +32,11 @@ class LoggersUtil {
2932
* Shut down all of the debug loggers in the system.
3033
*/
3134
static void ShutDown();
35+
36+
/** @return The specified level. */
37+
static std::optional<spdlog::level::level_enum> GetLevel(const std::string_view &name);
38+
39+
/** @return The logger for the specified component. */
40+
static noisepage::common::SanctionedSharedPtr<spdlog::logger>::Ptr GetLogger(const std::string_view &name);
3241
};
3342
} // namespace noisepage

src/include/main/db_main.h

+10-10
Original file line numberDiff line numberDiff line change
@@ -532,21 +532,21 @@ class DBMain {
532532
model_server_path_, messenger_layer->GetMessenger(), model_server_enable_python_coverage_);
533533
}
534534

535-
std::unique_ptr<selfdriving::PilotThread> pilot_thread = DISABLED;
536-
std::unique_ptr<selfdriving::Pilot> pilot = DISABLED;
535+
std::unique_ptr<selfdriving::pilot::PilotThread> pilot_thread = DISABLED;
536+
std::unique_ptr<selfdriving::pilot::Pilot> pilot = DISABLED;
537537
if (use_pilot_thread_) {
538538
NOISEPAGE_ASSERT(use_model_server_, "Pilot requires model server manager.");
539539
std::unique_ptr<util::QueryExecUtil> util =
540540
query_exec_util ? util::QueryExecUtil::ConstructThreadLocal(common::ManagedPointer(query_exec_util))
541541
: nullptr;
542-
pilot = std::make_unique<selfdriving::Pilot>(
542+
pilot = std::make_unique<selfdriving::pilot::Pilot>(
543543
ou_model_save_path_, interference_model_save_path_, forecast_model_save_path_,
544544
common::ManagedPointer(catalog_layer->GetCatalog()), common::ManagedPointer(metrics_thread),
545545
common::ManagedPointer(model_server_manager), common::ManagedPointer(settings_manager),
546546
common::ManagedPointer(stats_storage), common::ManagedPointer(txn_layer->GetTransactionManager()),
547547
std::move(util), common::ManagedPointer(task_manager), workload_forecast_interval_, sequence_length_,
548548
horizon_length_);
549-
pilot_thread = std::make_unique<selfdriving::PilotThread>(
549+
pilot_thread = std::make_unique<selfdriving::pilot::PilotThread>(
550550
common::ManagedPointer(pilot), std::chrono::microseconds{pilot_interval_},
551551
std::chrono::microseconds{forecast_train_interval_}, pilot_planning_);
552552
}
@@ -1060,8 +1060,8 @@ class DBMain {
10601060
bytecode_handlers_path_ = settings_manager->GetString(settings::Param::bytecode_handlers_path);
10611061

10621062
query_trace_metrics_ = settings_manager->GetBool(settings::Param::query_trace_metrics_enable);
1063-
query_trace_metrics_output_ = static_cast<metrics::MetricsOutput>(metrics::MetricsUtil::FromMetricsOutputString(
1064-
settings_manager->GetString(settings::Param::query_trace_metrics_output)));
1063+
query_trace_metrics_output_ = *metrics::MetricsUtil::FromMetricsOutputString(
1064+
settings_manager->GetString(settings::Param::query_trace_metrics_output));
10651065
forecast_sample_limit_ = settings_manager->GetInt(settings::Param::forecast_sample_limit);
10661066
pipeline_metrics_ = settings_manager->GetBool(settings::Param::pipeline_metrics_enable);
10671067
pipeline_metrics_sample_rate_ = settings_manager->GetInt(settings::Param::pipeline_metrics_sample_rate);
@@ -1182,12 +1182,12 @@ class DBMain {
11821182
/**
11831183
* @return ManagedPointer to the component, can be nullptr if disabled
11841184
*/
1185-
common::ManagedPointer<selfdriving::Pilot> GetPilot() const { return common::ManagedPointer(pilot_); }
1185+
common::ManagedPointer<selfdriving::pilot::Pilot> GetPilot() const { return common::ManagedPointer(pilot_); }
11861186

11871187
/**
11881188
* @return ManagedPointer to the component, can be nullptr if disabled
11891189
*/
1190-
common::ManagedPointer<selfdriving::PilotThread> GetPilotThread() const {
1190+
common::ManagedPointer<selfdriving::pilot::PilotThread> GetPilotThread() const {
11911191
return common::ManagedPointer(pilot_thread_);
11921192
}
11931193

@@ -1249,8 +1249,8 @@ class DBMain {
12491249
std::unique_ptr<MessengerLayer> messenger_layer_;
12501250
std::unique_ptr<replication::ReplicationManager> replication_manager_; // Depends on messenger.
12511251
std::unique_ptr<storage::RecoveryManager> recovery_manager_; // Depends on replication manager.
1252-
std::unique_ptr<selfdriving::PilotThread> pilot_thread_;
1253-
std::unique_ptr<selfdriving::Pilot> pilot_;
1252+
std::unique_ptr<selfdriving::pilot::PilotThread> pilot_thread_;
1253+
std::unique_ptr<selfdriving::pilot::Pilot> pilot_;
12541254
std::unique_ptr<modelserver::ModelServerManager> model_server_manager_;
12551255
std::unique_ptr<util::QueryExecUtil> query_exec_util_;
12561256
std::unique_ptr<task::TaskManager> task_manager_;

src/include/metrics/metrics_util.h

+11-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#pragma once
22

33
#include <chrono> // NOLINT
4+
#include <optional>
45
#include <string>
56

67
#include "execution/util/cpu_info.h"
@@ -39,15 +40,16 @@ struct MetricsUtil {
3940
* @param metrics output string
4041
* @return MetricsOutput corresponding to it
4142
*/
42-
static MetricsOutput FromMetricsOutputString(const std::string &metrics) {
43-
if (metrics == "CSV") return MetricsOutput::CSV;
44-
45-
if (metrics == "DB") return MetricsOutput::DB;
46-
47-
if (metrics == "CSV_AND_DB") return MetricsOutput::CSV_AND_DB;
48-
49-
NOISEPAGE_ASSERT(false, "Unknown metrics type specified");
50-
return MetricsOutput::CSV;
43+
static std::optional<MetricsOutput> FromMetricsOutputString(const std::string_view &metrics) {
44+
std::optional<MetricsOutput> type{std::nullopt};
45+
if (metrics == "CSV") {
46+
type = MetricsOutput::CSV;
47+
} else if (metrics == "DB") {
48+
type = MetricsOutput::DB;
49+
} else if (metrics == "CSV_AND_DB") {
50+
type = MetricsOutput::CSV_AND_DB;
51+
}
52+
return type;
5153
}
5254

5355
/**

src/include/metrics/pipeline_metric.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
#include "self_driving/modeling/operating_unit_util.h"
1818
#include "transaction/transaction_defs.h"
1919

20-
namespace noisepage::selfdriving {
20+
namespace noisepage::selfdriving::pilot {
2121
class PilotUtil;
2222
class Pilot;
23-
} // namespace noisepage::selfdriving
23+
} // namespace noisepage::selfdriving::pilot
2424

2525
namespace noisepage::metrics {
2626

@@ -90,8 +90,8 @@ class PipelineMetricRawData : public AbstractRawData {
9090

9191
private:
9292
friend class PipelineMetric;
93-
friend class selfdriving::PilotUtil;
94-
friend class selfdriving::Pilot;
93+
friend class selfdriving::pilot::PilotUtil;
94+
friend class selfdriving::pilot::Pilot;
9595
FRIEND_TEST(MetricsTests, PipelineCSVTest);
9696
struct PipelineData;
9797

src/include/self_driving/forecasting/workload_forecast.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
#include "self_driving/forecasting/workload_forecast_segment.h"
1414

1515
namespace noisepage::selfdriving {
16+
namespace pilot {
17+
class PilotUtil;
18+
}
1619

1720
/**
1821
* A workload forecast prediction is described as:
@@ -86,7 +89,7 @@ class WorkloadForecast {
8689
}
8790

8891
private:
89-
friend class PilotUtil;
92+
friend class pilot::PilotUtil;
9093

9194
uint64_t GetForecastInterval() const { return forecast_interval_; }
9295

src/include/self_driving/planning/mcts/monte_carlo_tree_search.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,10 @@
1212
#include "self_driving/planning/mcts/tree_node.h"
1313

1414
namespace noisepage::selfdriving {
15-
class Pilot;
1615
class WorkloadForecast;
1716

1817
namespace pilot {
19-
18+
class Pilot;
2019
class PlanningContext;
2120

2221
/**

src/include/self_driving/planning/mcts/tree_node.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,10 @@
1515
#define NULL_ACTION INT32_MAX
1616

1717
namespace noisepage::selfdriving {
18-
class Pilot;
1918
class WorkloadForecast;
2019

2120
namespace pilot {
22-
21+
class Pilot;
2322
class PlanningContext;
2423

2524
STRONG_TYPEDEF_HEADER(tree_node_id_t, uint64_t);

src/include/self_driving/planning/pilot.h

+4-8
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,10 @@ class TaskManager;
6262

6363
} // namespace noisepage
6464

65-
namespace noisepage::selfdriving {
66-
namespace pilot {
65+
namespace noisepage::selfdriving::pilot {
6766
class AbstractAction;
68-
class MonteCarloTreeSearch;
6967
class TreeNode;
7068
class ActionTreeNode;
71-
} // namespace pilot
72-
7369
class PilotUtil;
7470

7571
/**
@@ -127,7 +123,7 @@ class Pilot {
127123
* Search for and apply the best action for the current timestamp
128124
* @param best_action_seq pointer to the vector to be filled with the sequence of best actions to take at current time
129125
*/
130-
void ActionSearch(std::vector<pilot::ActionTreeNode> *best_action_seq);
126+
void ActionSearch(std::vector<ActionTreeNode> *best_action_seq);
131127

132128
/**
133129
* Search for and apply the best set of actions for the current timestamp using the Sequence Tuning baseline
@@ -155,7 +151,7 @@ class Pilot {
155151
*/
156152
static void EmptySetterCallback(common::ManagedPointer<common::ActionContext> action_context UNUSED_ATTRIBUTE) {}
157153

158-
pilot::PlanningContext planning_context_;
154+
PlanningContext planning_context_;
159155

160156
Forecaster forecaster_;
161157
uint64_t action_planning_horizon_{15};
@@ -164,4 +160,4 @@ class Pilot {
164160
std::mutex forecaster_train_mutex_;
165161
};
166162

167-
} // namespace noisepage::selfdriving
163+
} // namespace noisepage::selfdriving::pilot

src/include/self_driving/planning/pilot_thread.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
#include "self_driving/planning/pilot.h"
77

8-
namespace noisepage::selfdriving {
8+
namespace noisepage::selfdriving::pilot {
99

1010
/**
1111
* Class for spinning off a thread that runs the pilot to process query predictions.
@@ -19,7 +19,7 @@ class PilotThread {
1919
* @param forecaster_train_interval Sleep time between training forecast model
2020
* @param pilot_planning if the pilot is enabled
2121
*/
22-
PilotThread(common::ManagedPointer<selfdriving::Pilot> pilot, std::chrono::microseconds pilot_interval,
22+
PilotThread(common::ManagedPointer<Pilot> pilot, std::chrono::microseconds pilot_interval,
2323
std::chrono::microseconds forecaster_train_interval, bool pilot_planning);
2424

2525
~PilotThread() { StopPilot(); }
@@ -66,7 +66,7 @@ class PilotThread {
6666
common::ManagedPointer<Pilot> GetPilot() { return pilot_; }
6767

6868
private:
69-
const common::ManagedPointer<selfdriving::Pilot> pilot_;
69+
const common::ManagedPointer<Pilot> pilot_;
7070
volatile bool run_pilot_;
7171
volatile bool pilot_paused_;
7272
std::chrono::microseconds pilot_interval_;
@@ -92,4 +92,4 @@ class PilotThread {
9292
}
9393
};
9494

95-
} // namespace noisepage::selfdriving
95+
} // namespace noisepage::selfdriving::pilot

src/include/self_driving/planning/pilot_util.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,15 @@ class AbstractPlanNode;
3535

3636
namespace noisepage::selfdriving {
3737
class WorkloadForecast;
38-
class Pilot;
3938

4039
namespace pilot {
40+
class Pilot;
4141
class CreateIndexAction;
4242
class DropIndexAction;
4343
struct MemoryInfo;
4444
class ActionState;
4545
class AbstractAction;
4646
class PlanningContext;
47-
} // namespace pilot
4847

4948
/**
5049
* Utility class for helper functions
@@ -256,4 +255,5 @@ class PilotUtil {
256255
static const uint64_t INTERFERENCE_DIMENSION{27};
257256
};
258257

258+
} // namespace pilot
259259
} // namespace noisepage::selfdriving

0 commit comments

Comments
 (0)