This repository has been archived by the owner on Feb 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 503
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
966 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#pragma once | ||
|
||
#include "loggers/loggers_util.h" | ||
|
||
#ifdef NOISEPAGE_USE_LOGGING | ||
|
||
namespace noisepage::selfdriving { | ||
extern common::SanctionedSharedPtr<spdlog::logger>::Ptr selfdriving_logger; | ||
|
||
void InitSelfDrivingLogger(); | ||
} // namespace noisepage::selfdriving | ||
|
||
#define SELFDRIVING_LOG_TRACE(...) ::noisepage::selfdriving::selfdriving_logger->trace(__VA_ARGS__); | ||
#define SELFDRIVING_LOG_DEBUG(...) ::noisepage::selfdriving::selfdriving_logger->debug(__VA_ARGS__); | ||
#define SELFDRIVING_LOG_INFO(...) ::noisepage::selfdriving::selfdriving_logger->info(__VA_ARGS__); | ||
#define SELFDRIVING_LOG_WARN(...) ::noisepage::selfdriving::selfdriving_logger->warn(__VA_ARGS__); | ||
#define SELFDRIVING_LOG_ERROR(...) ::noisepage::selfdriving::selfdriving_logger->error(__VA_ARGS__); | ||
|
||
#else | ||
|
||
#define SELFDRIVING_LOG_TRACE(...) ((void)0) | ||
#define SELFDRIVING_LOG_DEBUG(...) ((void)0) | ||
#define SELFDRIVING_LOG_INFO(...) ((void)0) | ||
#define SELFDRIVING_LOG_WARN(...) ((void)0) | ||
#define SELFDRIVING_LOG_ERROR(...) ((void)0) | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#pragma once | ||
|
||
#include <map> | ||
#include <memory> | ||
#include <string> | ||
#include <unordered_map> | ||
#include <utility> | ||
#include <vector> | ||
|
||
#include "parser/expression/constant_value_expression.h" | ||
#include "self_driving/forecast/workload_forecast_segment.h" | ||
|
||
namespace noisepage::selfdriving { | ||
|
||
/** | ||
* Breaking predicted queries passed in by the Pilot into segments by their associated timestamps | ||
* Executing each query while extracting pipeline features | ||
*/ | ||
class WorkloadForecast { | ||
public: | ||
/** | ||
* Constructor for WorkloadForecast | ||
* @param forecast_interval Interval used to partition the queries into segments | ||
* | ||
*/ | ||
explicit WorkloadForecast(uint64_t forecast_interval); | ||
|
||
private: | ||
friend class PilotUtil; | ||
|
||
void LoadQueryTrace(); | ||
void LoadQueryText(); | ||
void CreateSegments(); | ||
|
||
std::multimap<uint64_t, execution::query_id_t> query_timestamp_to_id_; | ||
std::unordered_map<execution::query_id_t, std::vector<std::vector<parser::ConstantValueExpression>>> | ||
query_id_to_params_; | ||
std::unordered_map<execution::query_id_t, std::vector<type::TypeId>> query_id_to_param_types_; | ||
std::unordered_map<execution::query_id_t, std::string> query_id_to_text_; | ||
std::unordered_map<std::string, execution::query_id_t> query_text_to_id_; | ||
std::unordered_map<execution::query_id_t, uint64_t> query_id_to_dboid_; | ||
uint64_t num_sample_{5}; | ||
|
||
std::vector<WorkloadForecastSegment> forecast_segments_; | ||
uint64_t num_forecast_segment_{0}; | ||
uint64_t forecast_interval_; | ||
uint64_t optimizer_timeout_{10000000}; | ||
}; | ||
|
||
} // namespace noisepage::selfdriving |
26 changes: 26 additions & 0 deletions
26
src/include/self_driving/forecast/workload_forecast_segment.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#pragma once | ||
|
||
#include <queue> | ||
#include <tuple> | ||
#include <unordered_map> | ||
#include <utility> | ||
|
||
#include "execution/exec_defs.h" | ||
|
||
namespace noisepage::selfdriving { | ||
/** | ||
* Contains query ids and number of executions for each query for queries predicted to be in this time interval | ||
*/ | ||
class WorkloadForecastSegment { | ||
public: | ||
/** | ||
* Constructor for WorkloadForecastSegment | ||
* @param id_to_num_exec Map from qids to number of execution of this query in this interval | ||
*/ | ||
explicit WorkloadForecastSegment(std::unordered_map<execution::query_id_t, uint64_t> id_to_num_exec); | ||
|
||
private: | ||
std::unordered_map<execution::query_id_t, uint64_t> id_to_num_exec_; | ||
}; | ||
|
||
} // namespace noisepage::selfdriving |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
#pragma once | ||
|
||
#include <fstream> | ||
#include <iostream> | ||
#include <map> | ||
#include <memory> | ||
#include <string> | ||
#include <tuple> | ||
#include <unordered_map> | ||
#include <utility> | ||
#include <vector> | ||
|
||
#include "catalog/catalog.h" | ||
#include "common/action_context.h" | ||
#include "common/macros.h" | ||
#include "common/managed_pointer.h" | ||
#include "execution/exec_defs.h" | ||
#include "self_driving/forecast/workload_forecast.h" | ||
|
||
namespace noisepage { | ||
namespace messenger { | ||
class Messenger; | ||
} | ||
|
||
namespace metrics { | ||
class MetricsThread; | ||
} | ||
|
||
namespace modelserver { | ||
class ModelServerManager; | ||
} | ||
|
||
namespace optimizer { | ||
class StatsStorage; | ||
} | ||
|
||
namespace settings { | ||
class SettingsManager; | ||
} | ||
|
||
namespace transaction { | ||
class TransactionManager; | ||
} | ||
|
||
} // namespace noisepage | ||
|
||
namespace noisepage::selfdriving { | ||
class PilotUtil; | ||
|
||
/** | ||
* The pilot processes the query trace predictions by executing them and extracting pipeline features | ||
*/ | ||
class Pilot { | ||
protected: | ||
/** @return Name of the environment variable to be set as the absolute path of build directory */ | ||
static constexpr const char *BUILD_ABS_PATH = "BUILD_ABS_PATH"; | ||
|
||
public: | ||
/** | ||
* Constructor for Pilot | ||
* @param model_save_path model save path | ||
* @param catalog catalog | ||
* @param metrics_thread metrics thread for metrics manager | ||
* @param model_server_manager model server manager | ||
* @param settings_manager settings manager | ||
* @param stats_storage stats_storage | ||
* @param txn_manager transaction manager | ||
* @param workload_forecast_interval Interval used in the forecastor | ||
*/ | ||
Pilot(std::string model_save_path, common::ManagedPointer<catalog::Catalog> catalog, | ||
common::ManagedPointer<metrics::MetricsThread> metrics_thread, | ||
common::ManagedPointer<modelserver::ModelServerManager> model_server_manager, | ||
common::ManagedPointer<settings::SettingsManager> settings_manager, | ||
common::ManagedPointer<optimizer::StatsStorage> stats_storage, | ||
common::ManagedPointer<transaction::TransactionManager> txn_manager, uint64_t workload_forecast_interval); | ||
|
||
/** | ||
* Performs Pilot Logic, load and execute the predict queries while extracting pipeline features | ||
*/ | ||
void PerformPlanning(); | ||
|
||
private: | ||
/** | ||
* WorkloadForecast object performing the query execution and feature gathering | ||
*/ | ||
std::unique_ptr<selfdriving::WorkloadForecast> forecast_; | ||
|
||
/** | ||
* Empty Setter Callback for setting bool value for flags | ||
*/ | ||
static void EmptySetterCallback(common::ManagedPointer<common::ActionContext> action_context UNUSED_ATTRIBUTE) {} | ||
|
||
void ExecuteForecast(); | ||
|
||
std::string model_save_path_; | ||
common::ManagedPointer<catalog::Catalog> catalog_; | ||
common::ManagedPointer<metrics::MetricsThread> metrics_thread_; | ||
common::ManagedPointer<modelserver::ModelServerManager> model_server_manager_; | ||
common::ManagedPointer<settings::SettingsManager> settings_manager_; | ||
common::ManagedPointer<optimizer::StatsStorage> stats_storage_; | ||
common::ManagedPointer<transaction::TransactionManager> txn_manager_; | ||
uint64_t workload_forecast_interval_{10000000}; | ||
friend class noisepage::selfdriving::PilotUtil; | ||
}; | ||
|
||
} // namespace noisepage::selfdriving |
Oops, something went wrong.