-
Notifications
You must be signed in to change notification settings - Fork 312
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'duplicate_huaf_bug' of github.com:Shuo-Jia/pegasus into…
… duplicate_huaf_bug
- Loading branch information
Showing
10 changed files
with
372 additions
and
86 deletions.
There are no files selected for viewing
Submodule rdsn
updated
11 files
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,25 @@ | ||
// Copyright (c) 2017, Xiaomi, Inc. All rights reserved. | ||
// This source code is licensed under the Apache License Version 2.0, which | ||
// can be found in the LICENSE file in the root directory of this source tree. | ||
|
||
#pragma once | ||
|
||
#include "shell/commands.h" | ||
|
||
namespace pegasus { | ||
namespace server { | ||
|
||
struct hotspot_partition_data | ||
{ | ||
hotspot_partition_data(const row_data &row) | ||
: total_qps(row.get_total_qps()), | ||
total_cu(row.get_total_cu()), | ||
partition_name(row.row_name){}; | ||
hotspot_partition_data() {} | ||
double total_qps; | ||
double total_cu; | ||
std::string partition_name; | ||
}; | ||
|
||
} // namespace server | ||
} // namespace pegasus |
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,40 @@ | ||
// Copyright (c) 2017, Xiaomi, Inc. All rights reserved. | ||
// This source code is licensed under the Apache License Version 2.0, which | ||
// can be found in the LICENSE file in the root directory of this source tree. | ||
|
||
#include "table_hotspot_policy.h" | ||
|
||
#include <dsn/dist/fmt_logging.h> | ||
|
||
namespace pegasus { | ||
namespace server { | ||
|
||
void hotspot_calculator::aggregate(const std::vector<row_data> &partitions) | ||
{ | ||
while (_app_data.size() > kMaxQueueSize - 1) { | ||
_app_data.pop(); | ||
} | ||
std::vector<hotspot_partition_data> temp(partitions.size()); | ||
for (int i = 0; i < partitions.size(); i++) { | ||
temp[i] = std::move(hotspot_partition_data(partitions[i])); | ||
} | ||
_app_data.emplace(temp); | ||
} | ||
|
||
void hotspot_calculator::init_perf_counter(const int perf_counter_count) | ||
{ | ||
std::string counter_name; | ||
std::string counter_desc; | ||
for (int i = 0; i < perf_counter_count; i++) { | ||
string paritition_desc = _app_name + '.' + std::to_string(i); | ||
counter_name = fmt::format("app.stat.hotspots@{}", paritition_desc); | ||
counter_desc = fmt::format("statistic the hotspots of app {}", paritition_desc); | ||
_points[i].init_app_counter( | ||
"app.pegasus", counter_name.c_str(), COUNTER_TYPE_NUMBER, counter_desc.c_str()); | ||
} | ||
} | ||
|
||
void hotspot_calculator::start_alg() { _policy->analysis(_app_data, _points); } | ||
|
||
} // namespace server | ||
} // namespace pegasus |
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,68 @@ | ||
// Copyright (c) 2017, Xiaomi, Inc. All rights reserved. | ||
// This source code is licensed under the Apache License Version 2.0, which | ||
// can be found in the LICENSE file in the root directory of this source tree. | ||
|
||
#pragma once | ||
|
||
#include "hotspot_partition_data.h" | ||
|
||
#include <algorithm> | ||
#include <gtest/gtest_prod.h> | ||
#include <dsn/perf_counter/perf_counter.h> | ||
|
||
namespace pegasus { | ||
namespace server { | ||
class hotspot_policy | ||
{ | ||
public: | ||
// hotspot_app_data store the historical data which related to hotspot | ||
// it uses rolling queue to save one app's data | ||
// vector is used to save the partitions' data of this app | ||
// hotspot_partition_data is used to save data of one partition | ||
virtual void analysis(const std::queue<std::vector<hotspot_partition_data>> &hotspot_app_data, | ||
std::vector<::dsn::perf_counter_wrapper> &hot_points) = 0; | ||
}; | ||
|
||
class hotspot_algo_qps_skew : public hotspot_policy | ||
{ | ||
public: | ||
void analysis(const std::queue<std::vector<hotspot_partition_data>> &hotspot_app_data, | ||
std::vector<::dsn::perf_counter_wrapper> &hot_points) | ||
{ | ||
const auto &anly_data = hotspot_app_data.back(); | ||
double min_total_qps = INT_MAX; | ||
for (auto partition_anly_data : anly_data) { | ||
min_total_qps = std::min(min_total_qps, partition_anly_data.total_qps); | ||
} | ||
min_total_qps = std::max(1.0, min_total_qps); | ||
dassert(anly_data.size() == hot_points.size(), "partition counts error, please check"); | ||
for (int i = 0; i < hot_points.size(); i++) { | ||
hot_points[i]->set(anly_data[i].total_qps / min_total_qps); | ||
} | ||
} | ||
}; | ||
|
||
// hotspot_calculator is used to find the hotspot in Pegasus | ||
class hotspot_calculator | ||
{ | ||
public: | ||
hotspot_calculator(const std::string &app_name, const int partition_num) | ||
: _app_name(app_name), _points(partition_num), _policy(new hotspot_algo_qps_skew()) | ||
{ | ||
init_perf_counter(partition_num); | ||
} | ||
void aggregate(const std::vector<row_data> &partitions); | ||
void start_alg(); | ||
void init_perf_counter(const int perf_counter_count); | ||
|
||
private: | ||
const std::string _app_name; | ||
std::vector<::dsn::perf_counter_wrapper> _points; | ||
std::queue<std::vector<hotspot_partition_data>> _app_data; | ||
std::unique_ptr<hotspot_policy> _policy; | ||
static const int kMaxQueueSize = 100; | ||
|
||
FRIEND_TEST(table_hotspot_policy, hotspot_algo_qps_skew); | ||
}; | ||
} // namespace server | ||
} // namespace pegasus |
Oops, something went wrong.