Smityz commented on a change in pull request #604:
URL: https://github.com/apache/incubator-pegasus/pull/604#discussion_r491913903
##########
File path: src/server/hotspot_partition_calculator.cpp
##########
@@ -128,15 +145,44 @@ void hotspot_partition_calculator::data_analyse()
stat_histories_analyse(data_type, hot_points);
update_hot_point(data_type, hot_points);
}
+ if (!FLAGS_enable_hotkey_detect) {
+ return;
+ }
+ for (int data_type = 0; data_type <= 1; data_type++) {
+ detect_hotkey_in_hotpartition(data_type);
+ }
+}
+
+void hotspot_partition_calculator::detect_hotkey_in_hotpartition(int data_type)
+{
+ for (int index = 0; index < _hot_points.size(); index++) {
+ if (_hot_points[index][data_type].get()->get_value() >=
FLAGS_hot_partition_threshold) {
+ if (++_hotpartition_pool[index][data_type] >=
FLAGS_occurrence_threshold) {
+ derror_f("Find a {} hot partition {}.{}",
+ (data_type == partition_qps_type::READ_HOTSPOT_DATA ?
"read" : "write"),
+ _app_name,
+ index);
+ send_hotkey_detect_request(_app_name,
+ index,
+ (data_type ==
dsn::apps::hotkey_type::type::READ)
+ ?
dsn::apps::hotkey_type::type::READ
+ :
dsn::apps::hotkey_type::type::WRITE,
+
dsn::apps::hotkey_detect_action::type::START);
+ }
+ } else {
+ _hotpartition_pool[index][data_type] =
+ std::max(_hotpartition_pool[index][data_type] - 1, 0);
Review comment:
I add some comments in the codes
##########
File path: src/server/test/hotspot_partition_test.cpp
##########
@@ -92,6 +121,37 @@ TEST_F(hotspot_partition_test, hotspot_partition_policy)
test_rows[HOT_SCENARIO_1_WRITE_HOT_PARTITION].put_qps = 5000.0;
expect_vector = {{0, 0, 0, 4, 0, 0, 0, 0}, {0, 0, 4, 0, 0, 0, 0, 0}};
test_policy_in_scenarios(test_rows, expect_vector, calculator);
+ clear_calculator_histories(calculator);
+}
+
+TEST_F(hotspot_partition_test, send_hotkey_detect_request)
+{
+ const int READ_HOT_PARTITION = 7;
+ const int WRITE_HOT_PARTITION = 0;
+ std::vector<row_data> test_rows = generate_row_data();
+ test_rows[READ_HOT_PARTITION].get_qps = 5000.0;
+ test_rows[WRITE_HOT_PARTITION].put_qps = 5000.0;
+ int hotpartition_count = FLAGS_occurrence_threshold;
+ std::vector<std::array<int, 2>> expect_result = {{0, hotpartition_count},
+ {0, 0},
+ {0, 0},
+ {0, 0},
+ {0, 0},
+ {0, 0},
+ {0, 0},
+ {hotpartition_count, 0}};
+ aggregate_analyse_data(calculator, test_rows, expect_result,
FLAGS_occurrence_threshold);
+ const int back_to_normal = 30;
+ hotpartition_count = FLAGS_occurrence_threshold - back_to_normal;
+ expect_result = {{0, hotpartition_count},
+ {0, 0},
+ {0, 0},
+ {0, 0},
+ {0, 0},
+ {0, 0},
+ {0, 0},
+ {hotpartition_count, 0}};
Review comment:
It is a different test case, expext result changed
##########
File path: src/server/test/hotspot_partition_test.cpp
##########
@@ -92,6 +121,37 @@ TEST_F(hotspot_partition_test, hotspot_partition_policy)
test_rows[HOT_SCENARIO_1_WRITE_HOT_PARTITION].put_qps = 5000.0;
expect_vector = {{0, 0, 0, 4, 0, 0, 0, 0}, {0, 0, 4, 0, 0, 0, 0, 0}};
test_policy_in_scenarios(test_rows, expect_vector, calculator);
+ clear_calculator_histories(calculator);
+}
+
+TEST_F(hotspot_partition_test, send_hotkey_detect_request)
+{
+ const int READ_HOT_PARTITION = 7;
+ const int WRITE_HOT_PARTITION = 0;
+ std::vector<row_data> test_rows = generate_row_data();
+ test_rows[READ_HOT_PARTITION].get_qps = 5000.0;
+ test_rows[WRITE_HOT_PARTITION].put_qps = 5000.0;
+ int hotpartition_count = FLAGS_occurrence_threshold;
+ std::vector<std::array<int, 2>> expect_result = {{0, hotpartition_count},
+ {0, 0},
+ {0, 0},
+ {0, 0},
+ {0, 0},
+ {0, 0},
+ {0, 0},
+ {hotpartition_count, 0}};
+ aggregate_analyse_data(calculator, test_rows, expect_result,
FLAGS_occurrence_threshold);
+ const int back_to_normal = 30;
+ hotpartition_count = FLAGS_occurrence_threshold - back_to_normal;
+ expect_result = {{0, hotpartition_count},
+ {0, 0},
+ {0, 0},
+ {0, 0},
+ {0, 0},
+ {0, 0},
+ {0, 0},
+ {hotpartition_count, 0}};
Review comment:
It is a different test case, expect result changed
----------------------------------------------------------------
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:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]