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): build a fundamental framework of hotkey detection #603

Merged
merged 23 commits into from
Oct 12, 2020

Conversation

Smityz
Copy link
Contributor

@Smityz Smityz commented Sep 16, 2020

Hotkey detection process

+--------------------+  +----------------------------------------------------+
|   Replcia server   |  | Hotkey collector                                   |
|                    |  | +-----------------------------------------------+  |
| +----------------+ |  | | Corase capture                                |  |
| |                | |--> |                 +----------+                  |  |
| |  RPC received  | || | |                 |   Data   |                  |  |
| |                | || | |                 +-----+----+                  |  |
| +-------+--------+ || | |                       |                       |  |
|         |          || | |  +---------------+----v--+-------+---------+  |  |
|         v          || | |  |       |Hot    |       |       |         |  |  |
| +-------+--------+ || | |  |Bucket |Bucket |Bucket |Bucket |Bucket   |  |  |
| |   Replication  | || | |  +-----------+-----------------------------+  |  |
| | (only on the   | || | |              |                                |  |
| |  write path))  | || | +--------------|--------------------------------+  |
| +-------+--------+ || |             +--v---+                               |
|         |          || |             | Data |                               |
|         v          || |             +------+                               |
| +-------+--------+ || |          +-----|-------+-------------+             |
| |                | || |   +------|-------------|-------------|---------+   |
| |  Capture data  ---| |   | Fine |capture      |             |         |   |
| |                | |  |   |      |             |             |         |   |
| +-------+--------+ |  |   | +----v----+   +----v----+   +----v----+    |   |
|         |          |  |   | |  queue  |   |  queue  |   |  queue  |    |   |
|         v          |  |   | +----+----+   +----+----+   +----+----+    |   |
| +-------+--------+ |  |   |      |             |             |         |   |
| |                | |  |   | +----v-------------v-------------v------+  |   |
| |   Place data   | |  |   | |             Analsis pool              |  |   |
| |   to the disk  | |  |   | +-----------------|---------------------+  |   |
| |                | |  |   +-------------------|------------------------+   |
| +----------------+ |  |                       v                            |
|                    |  |                     Hotkey                         |
+--------------------+  +----------------------------------------------------+

What problem does this PR solve?

Rely PR: XiaoMi/rdsn#634
In this PR, I define two interfaces of hotkey_collector.
capture_raw_key is to capture data in capacity_unit_calculator, in the future PR, I will analyze these data to find the hotkey.
handle_operation is to receive the control RPC of hotkey detection.
capture_raw_key is executed in capacity_unit_calculator, I will implentment it in the next PR

@Smityz Smityz changed the title feat(hotkey detection): add a fundamental construct of hotkey detection feat(hotkey detection): build a fundamental framework of hotkey detection Sep 16, 2020
src/server/hotkey_coarse_data_collector.h Outdated Show resolved Hide resolved
src/server/hotkey_collector.h Outdated Show resolved Hide resolved
src/server/hotkey_collector.h Outdated Show resolved Hide resolved
src/server/hotkey_fine_data_collector.h Outdated Show resolved Hide resolved
@Smityz Smityz mentioned this pull request Sep 17, 2020
src/server/hotkey_coarse_data_collector.h Outdated Show resolved Hide resolved
src/server/hotkey_coarse_data_collector.h Outdated Show resolved Hide resolved
src/server/hotkey_coarse_data_collector.h Outdated Show resolved Hide resolved
src/server/hotkey_coarse_data_collector.h Outdated Show resolved Hide resolved
src/server/hotkey_collector.h Outdated Show resolved Hide resolved
src/server/hotkey_collector.h Outdated Show resolved Hide resolved
src/server/hotkey_fine_data_collector.h Outdated Show resolved Hide resolved
src/server/hotkey_coarse_data_collector.cpp Outdated Show resolved Hide resolved
src/server/hotkey_coarse_data_collector.h Outdated Show resolved Hide resolved
src/server/hotkey_coarse_data_collector.h Outdated Show resolved Hide resolved
src/server/hotkey_coarse_data_collector.h Outdated Show resolved Hide resolved
src/server/hotkey_collector.h Show resolved Hide resolved
src/server/hotkey_collector.h Outdated Show resolved Hide resolved
src/server/hotkey_collector.h Outdated Show resolved Hide resolved
src/server/hotkey_fine_data_collector.h Outdated Show resolved Hide resolved
@Smityz Smityz marked this pull request as draft September 18, 2020 10:39
@Smityz Smityz marked this pull request as ready for review September 30, 2020 06:03
@Smityz Smityz changed the title feat(hotkey detection): build a fundamental framework of hotkey detection feat(hotkey): build a fundamental framework of hotkey detection Sep 30, 2020
src/server/hotkey_collector.h Outdated Show resolved Hide resolved
Comment on lines 108 to 109
_read_hotkey_collector->capture_raw_key(key, key.size() + value.size());

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's not needed to add capture_raw_key in this PR, since only this is just a 'fundamental framework' PR, and some othe read/write paths like add_write_cu missing call it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

capture_raw_key is a fundamental interface of hotkey_collector, I want to show how to use this function

src/server/pegasus_server_impl.cpp Outdated Show resolved Hide resolved
src/server/pegasus_server_impl.cpp Outdated Show resolved Hide resolved
acelyc111
acelyc111 previously approved these changes Oct 9, 2020
acelyc111
acelyc111 previously approved these changes Oct 9, 2020
@@ -122,21 +134,25 @@ void capacity_unit_calculator::add_multi_get_cu(int32_t status,
}

if (status == rocksdb::Status::kNotFound) {
_read_hotkey_collector->capture_hash_key(hash_key, 1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe you can move this into func add_read_cu
same with add_write_cu

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

capture_hash_key and add_read_cu are two independent function. It will destroy the original semantics.

@@ -122,21 +134,25 @@ void capacity_unit_calculator::add_multi_get_cu(int32_t status,
}

if (status == rocksdb::Status::kNotFound) {
_read_hotkey_collector->capture_hash_key(hash_key, 1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I notice that you try to capture not-found key for multi_get, but not for single get, could you please explain why you design it?

void add_scan_cu(int32_t status, const std::vector<::dsn::apps::key_value> &kvs);
void add_scan_cu(int32_t status,
const std::vector<::dsn::apps::key_value> &kvs,
const dsn::blob &hash_key_filter_pattern = dsn::blob());
Copy link
Contributor

@hycdong hycdong Oct 10, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the usage of hash_key_filter_pattern?

@@ -55,6 +64,9 @@ class capacity_unit_calculator : public dsn::replication::replica_base
#endif

private:
void count_read_data(const dsn::blob &key, key_type type, int64_t size);
void count_write_data(const dsn::blob &key, key_type type, int64_t size);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is function count_wirte_data used for add cu and capture key for hotkey detection?

@hycdong hycdong merged commit 3b96b26 into apache:master Oct 12, 2020
@Smityz Smityz deleted the hotkey-platform branch October 12, 2020 08:04
@neverchanje neverchanje mentioned this pull request Mar 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants