You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pegasus.apache.org by GitBox <gi...@apache.org> on 2020/11/13 08:22:45 UTC

[GitHub] [incubator-pegasus] Shuo-Jia commented on a change in pull request #632: fix(hotkey): fix two hidden dangers in hotkey_collector

Shuo-Jia commented on a change in pull request #632:
URL: https://github.com/apache/incubator-pegasus/pull/632#discussion_r522764624



##########
File path: src/server/hotkey_collector.cpp
##########
@@ -102,20 +101,78 @@ find_outlier_index(const std::vector<uint64_t> &captured_keys, int threshold, in
 }
 
 // TODO: (Tangyanzhao) replace it to xxhash
-static int get_bucket_id(dsn::string_view data)
+static int get_bucket_id(dsn::string_view data, int bucket_num)
 {
-    size_t hash_value = boost::hash_range(data.begin(), data.end());
-    return static_cast<int>(hash_value % FLAGS_hotkey_buckets_num);
+    return static_cast<int>(boost::hash_range(data.begin(), data.end()) % bucket_num);
 }
 
 hotkey_collector::hotkey_collector(dsn::replication::hotkey_type::type hotkey_type,
                                    dsn::replication::replica_base *r_base)
-    : replica_base(r_base),
-      _state(hotkey_collector_state::STOPPED),
-      _hotkey_type(hotkey_type),
-      _internal_collector(std::make_shared<hotkey_empty_data_collector>(this)),
-      _collector_start_time_second(0)
+    : replica_base(r_base), _hotkey_type(hotkey_type)
 {
+    int now_hash_bucket_num = FLAGS_hotkey_buckets_num;
+    _internal_coarse_collector =
+        std::make_shared<hotkey_coarse_data_collector>(this, now_hash_bucket_num);
+    _internal_fine_collector =
+        std::make_shared<hotkey_fine_data_collector>(this, now_hash_bucket_num);
+    _internal_empty_collector = std::make_shared<hotkey_empty_data_collector>(this);
+    hotkey_collector::change_state_to_stopped();

Review comment:
       is the line necessary? At the beginning of the `hotkey_collector`, the all varible should have been default value.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pegasus.apache.org
For additional commands, e-mail: dev-help@pegasus.apache.org