Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
tangyanzhao committed Oct 20, 2020
1 parent 4d5cbd6 commit 9b82ac9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
11 changes: 6 additions & 5 deletions src/server/hotkey_collector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,10 @@ detect_hotkey_result
hotkey_coarse_data_collector::internal_analysis_method(const std::vector<uint64_t> &captured_keys,
int threshold)
{

int data_size = captured_keys.size();
dassert(captured_keys.size() > 2, "data_capture_hash_bucket_num is too small");

dcheck_gt(captured_keys.size(), 2);
// empirical rule to calculate hot point of each partition
// same algorithm as hotspot_partition_calculator::stat_histories_analyse
double table_captured_key_sum = 0;
int hot_index = 0;
int hot_value = 0;
Expand All @@ -197,8 +197,9 @@ hotkey_coarse_data_collector::internal_analysis_method(const std::vector<uint64_
standard_deviation = sqrt(standard_deviation / (data_size - 2));
double hot_point = (hot_value - captured_keys_avg_count) / standard_deviation;
detect_hotkey_result result;
hot_point > threshold ? result.coarse_bucket_index = hot_index
: result.coarse_bucket_index = -1;
if (hot_point > threshold) {
result.coarse_bucket_index = hot_index;
}
return result;
}

Expand Down
5 changes: 2 additions & 3 deletions src/server/hotkey_collector.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ class internal_collector_base;

struct detect_hotkey_result
{
int coarse_bucket_index;
detect_hotkey_result() : coarse_bucket_index(-1) {}
int coarse_bucket_index = -1;
};

// hotkey_collector is responsible to find the hot keys after the partition
Expand Down Expand Up @@ -105,7 +104,7 @@ class internal_collector_base : public dsn::replication::replica_base
class hotkey_empty_data_collector : public internal_collector_base
{
public:
explicit hotkey_empty_data_collector(replica_base *base) : internal_collector_base(base){};
explicit hotkey_empty_data_collector(replica_base *base) : internal_collector_base(base) {}
void capture_data(const dsn::blob &hash_key, uint64_t weight) override {}
void analyse_data(detect_hotkey_result &result) override {}
};
Expand Down

0 comments on commit 9b82ac9

Please sign in to comment.