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/09/16 17:08:14 UTC

[GitHub] [incubator-pegasus] acelyc111 commented on a change in pull request #603: feat(hotkey detection): build a fundamental framework of hotkey detection

acelyc111 commented on a change in pull request #603:
URL: https://github.com/apache/incubator-pegasus/pull/603#discussion_r489590652



##########
File path: src/server/hotkey_collector.h
##########
@@ -0,0 +1,45 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#pragma once
+
+#include <dsn/utility/string_view.h>
+
+namespace pegasus {
+namespace server {
+
+class hotkey_coarse_data_collector;
+class hotkey_fine_data_collector;
+
+// hotkey_collector is responsible to find the hot keys after the partition
+// was detected to be hot. The two types of hotkey, READ & WRITE, are detected
+// separately.
+class hotkey_collector
+{
+public:
+    // common function to find outlier in both coarse capture and fine capture

Review comment:
       ```suggestion
       // find outlier in both coarse capture and fine capture
   ```

##########
File path: src/server/hotkey_collector.h
##########
@@ -0,0 +1,45 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#pragma once
+
+#include <dsn/utility/string_view.h>
+
+namespace pegasus {
+namespace server {
+
+class hotkey_coarse_data_collector;
+class hotkey_fine_data_collector;
+
+// hotkey_collector is responsible to find the hot keys after the partition
+// was detected to be hot. The two types of hotkey, READ & WRITE, are detected
+// separately.
+class hotkey_collector
+{
+public:
+    // common function to find outlier in both coarse capture and fine capture
+    static int outlier_cal(const std::vector<uint64_t> &data_samples, int threshold);
+    // common function to unify the hash way in both coarse capture and fine capture

Review comment:
       ```suggestion
       // unify the hash way in both coarse capture and fine capture
   ```

##########
File path: src/server/hotkey_coarse_data_collector.h
##########
@@ -0,0 +1,33 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+namespace pegasus {
+namespace server {
+
+// hotkey_coarse_data_collector handles the first procedure (COARSE) of hotkey detection.
+// It captures the data without recording them, but simply divides the incoming requests
+// into a number of buckets and counts the accessed times of each bucket.
+// If the variance among the buckets exceeds the threshold, the most accessed bucket
+// is regarded to contain the hotkey.
+//
+// This technique intends to reduce the load of data recording during FINE procedure,
+// filtering what's unnecessary to catch.
+class hotkey_coarse_data_collector
+{

Review comment:
       Better to add interfaces of this class, even with empty implementation, then we know what you want to do by this class.

##########
File path: src/server/hotkey_fine_data_collector.h
##########
@@ -0,0 +1,32 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+namespace pegasus {
+namespace server {
+
+// hotkey_fine_data_collector handles the second procedure (FINE) of hotkey detection.
+// It captures only the data mapping to the "hot" bucket.
+//
+// To prevent locking on the read path, we create one queue per thread of THREAD_POOL_LOCAL_APP.
+// The read request is captured right inside its execution thread.
+//
+// For writes we do not apply this optimization.
+class hotkey_fine_data_collector
+{

Review comment:
       Add interfaces




----------------------------------------------------------------
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