aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbugaevskiy <bugaevskiy@yandex-team.com>2022-09-29 20:07:53 +0300
committerbugaevskiy <bugaevskiy@yandex-team.com>2022-09-29 20:07:53 +0300
commitf556e448fbb43b5dc92d8a36ba1aace052cddade (patch)
tree3dd71a896fa48059d413abad213c8130303eaf37
parentb971ccb280d2a81b35ad1c647381577fa2896128 (diff)
downloadydb-f556e448fbb43b5dc92d8a36ba1aace052cddade.tar.gz
Add more params for jemalloc
-rw-r--r--library/cpp/malloc/jemalloc/malloc-info.cpp41
1 files changed, 40 insertions, 1 deletions
diff --git a/library/cpp/malloc/jemalloc/malloc-info.cpp b/library/cpp/malloc/jemalloc/malloc-info.cpp
index 2643ca4766..21b079519b 100644
--- a/library/cpp/malloc/jemalloc/malloc-info.cpp
+++ b/library/cpp/malloc/jemalloc/malloc-info.cpp
@@ -16,7 +16,7 @@ TMallocInfo NMalloc::MallocInfo() {
#include <contrib/libs/jemalloc/include/jemalloc/jemalloc.h>
namespace {
- bool JESetParam(const char* param, const char*) {
+ bool JESetParam(const char* param, const char* value) {
if (param) {
if (strcmp(param, "j:reset_epoch") == 0) {
uint64_t epoch = 1;
@@ -27,6 +27,45 @@ namespace {
return true;
}
+ if (strcmp(param, "j:prof") == 0) {
+ if (strcmp(value, "start") == 0) {
+ bool is_active = true;
+ const int ret = mallctl("prof.active", nullptr, nullptr, &is_active, sizeof(is_active));
+ return ret == 0;
+ }
+ if (strcmp(value, "stop") == 0) {
+ bool is_active = false;
+ const int ret = mallctl("prof.active", nullptr, nullptr, &is_active, sizeof(is_active));
+ return ret == 0;
+ }
+ if (strcmp(value, "dump") == 0) {
+ const int ret = mallctl("prof.dump", nullptr, nullptr, nullptr, 0);
+ return ret == 0;
+ }
+ }
+ if (strcmp(param, "j:bg_threads") == 0) {
+ if (strcmp(value, "start") == 0) {
+ bool is_active = true;
+ const int ret = mallctl("background_thread", nullptr, nullptr, &is_active, sizeof(is_active));
+ return ret == 0;
+ }
+ if (strcmp(value, "stop") == 0) {
+ bool is_active = false;
+ // NOTE: joins bg thread
+ const int ret = mallctl("background_thread", nullptr, nullptr, &is_active, sizeof(is_active));
+ return ret == 0;
+ }
+ if (strncmp(value, "max=", 4) == 0) {
+ int num_value = atoi(value + 4);
+ if (num_value <= 0) {
+ return false;
+ }
+ size_t max_threads = num_value;
+ const int ret = mallctl("max_background_threads", nullptr, nullptr, &max_threads, sizeof(max_threads));
+ return ret == 0;
+ }
+ }
+
return false;
}