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

feat(hotkey): dynamic change some parameters in hotkey detection #679

Merged
merged 5 commits into from
Jan 12, 2021
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
5 changes: 4 additions & 1 deletion src/server/hotkey_collector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,21 @@ DSN_DEFINE_uint32(
hot_bucket_variance_threshold,
7,
"the variance threshold to detect hot bucket during coarse analysis of hotkey detection");
DSN_TAG_VARIABLE(hot_bucket_variance_threshold, FT_MUTABLE);

DSN_DEFINE_uint32(
"pegasus.server",
hot_key_variance_threshold,
5,
"the variance threshold to detect hot key during fine analysis of hotkey detection");
DSN_TAG_VARIABLE(hot_key_variance_threshold, FT_MUTABLE);

DSN_DEFINE_uint32("pegasus.server",
hotkey_buckets_num,
37,
"the number of data capture hash buckets");

DSN_DEFINE_validator(hotkey_buckets_num, [](int32_t bucket_num) -> bool {
DSN_DEFINE_validator(hotkey_buckets_num, [](uint32_t bucket_num) -> bool {
if (bucket_num < 3) {
return false;
}
Expand All @@ -63,6 +65,7 @@ DSN_DEFINE_uint32(
max_seconds_to_detect_hotkey,
150,
"the max time (in seconds) allowed to capture hotkey, will stop if hotkey's not found");
DSN_TAG_VARIABLE(max_seconds_to_detect_hotkey, FT_MUTABLE);

// 68–95–99.7 rule, same algorithm as hotspot_partition_calculator::stat_histories_analyse
/*extern*/ bool
Expand Down
27 changes: 16 additions & 11 deletions src/server/hotspot_partition_calculator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,20 @@ DSN_DEFINE_bool("pegasus.collector",
enable_detect_hotkey,
false,
"auto detect hot key in the hot paritition");
DSN_TAG_VARIABLE(enable_detect_hotkey, FT_MUTABLE);

DSN_DEFINE_int32("pegasus.collector",
hot_partition_threshold,
3,
"threshold of hotspot partition value, if app.stat.hotspots >= "
"FLAGS_hotpartition_threshold, this partition is a hot partition");
DSN_DEFINE_uint32("pegasus.collector",
hot_partition_threshold,
3,
"threshold of hotspot partition value, if app.stat.hotspots >= "
"FLAGS_hotpartition_threshold, this partition is a hot partition");
DSN_TAG_VARIABLE(hot_partition_threshold, FT_MUTABLE);
Smityz marked this conversation as resolved.
Show resolved Hide resolved

DSN_DEFINE_int32("pegasus.collector",
occurrence_threshold,
3,
"hot paritiotion occurrence times' threshold to send rpc to detect hotkey");
DSN_DEFINE_uint32("pegasus.collector",
occurrence_threshold,
3,
"hot paritiotion occurrence times' threshold to send rpc to detect hotkey");
DSN_TAG_VARIABLE(occurrence_threshold, FT_MUTABLE);

void hotspot_partition_calculator::data_aggregate(const std::vector<row_data> &partition_stats)
{
Expand Down Expand Up @@ -149,9 +152,11 @@ void hotspot_partition_calculator::data_analyse()

void hotspot_partition_calculator::detect_hotkey_in_hotpartition(int data_type)
{
auto now_hot_partition_threshold = FLAGS_hot_partition_threshold;
auto now_occurrence_threshold = FLAGS_occurrence_threshold;
for (int index = 0; index < _hot_points.size(); index++) {
if (_hot_points[index][data_type].get()->get_value() >= FLAGS_hot_partition_threshold) {
if (++_hotpartition_counter[index][data_type] >= FLAGS_occurrence_threshold) {
if (_hot_points[index][data_type].get()->get_value() >= now_hot_partition_threshold) {
if (++_hotpartition_counter[index][data_type] >= now_occurrence_threshold) {
derror_f("Find a {} hot partition {}.{}",
(data_type == partition_qps_type::READ_HOTSPOT_DATA ? "read" : "write"),
_app_name,
Expand Down