Skip to content
This repository has been archived by the owner on Jun 23, 2022. It is now read-only.

Commit

Permalink
feat: add remote command to get tcmalloc status (#832)
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhongChaoqiang authored and acelyc111 committed Jun 3, 2021
1 parent 813377a commit 815a7aa
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/replica/replica_stub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ replica_stub::replica_stub(replica_state_subscriber subscriber /*= nullptr*/,
{
#ifdef DSN_ENABLE_GPERF
_release_tcmalloc_memory_command = nullptr;
_get_tcmalloc_status_command = nullptr;
_max_reserved_memory_percentage_command = nullptr;
#endif
_replica_state_subscriber = subscriber;
Expand Down Expand Up @@ -2203,6 +2204,16 @@ void replica_stub::register_ctrl_command()
_release_tcmalloc_memory, "release-tcmalloc-memory", args);
});

_get_tcmalloc_status_command = ::dsn::command_manager::instance().register_command(
{"replica.get-tcmalloc-status"},
"replica.get-tcmalloc-status",
"replica.get-tcmalloc-status - get status of tcmalloc",
[this](const std::vector<std::string> &args) {
char buf[4096];
MallocExtension::instance()->GetStats(buf, 4096);
return std::string(buf);
});

_max_reserved_memory_percentage_command = dsn::command_manager::instance().register_command(
{"replica.mem-release-max-reserved-percentage"},
"replica.mem-release-max-reserved-percentage [num | DEFAULT]",
Expand Down Expand Up @@ -2384,6 +2395,7 @@ void replica_stub::close()
UNREGISTER_VALID_HANDLER(_query_app_envs_command);
#ifdef DSN_ENABLE_GPERF
UNREGISTER_VALID_HANDLER(_release_tcmalloc_memory_command);
UNREGISTER_VALID_HANDLER(_get_tcmalloc_status_command);
UNREGISTER_VALID_HANDLER(_max_reserved_memory_percentage_command);
#endif
UNREGISTER_VALID_HANDLER(_max_concurrent_bulk_load_downloading_count_command);
Expand All @@ -2397,6 +2409,7 @@ void replica_stub::close()
_query_app_envs_command = nullptr;
#ifdef DSN_ENABLE_GPERF
_release_tcmalloc_memory_command = nullptr;
_get_tcmalloc_status_command = nullptr;
_max_reserved_memory_percentage_command = nullptr;
#endif
_max_concurrent_bulk_load_downloading_count_command = nullptr;
Expand Down
1 change: 1 addition & 0 deletions src/replica/replica_stub.h
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ class replica_stub : public serverlet<replica_stub>, public ref_counter
dsn_handle_t _query_app_envs_command;
#ifdef DSN_ENABLE_GPERF
dsn_handle_t _release_tcmalloc_memory_command;
dsn_handle_t _get_tcmalloc_status_command;
dsn_handle_t _max_reserved_memory_percentage_command;
#endif
dsn_handle_t _max_concurrent_bulk_load_downloading_count_command;
Expand Down

0 comments on commit 815a7aa

Please sign in to comment.