This is an automated email from the ASF dual-hosted git repository.
chenBright pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/brpc.git
The following commit(s) were added to refs/heads/master by this push:
new 05dac9c1 Freeze bvar dump path flags and cap pprof duration by
FLAGS_max_profiling_seconds (#3523)
05dac9c1 is described below
commit 05dac9c177c144cb22b8e86d968d74082143a954
Author: Bright Chen <[email protected]>
AuthorDate: Sun Sep 6 15:07:39 2026 +0800
Freeze bvar dump path flags and cap pprof duration by
FLAGS_max_profiling_seconds (#3523)
---
src/brpc/builtin/common.cpp | 4 +++
src/brpc/builtin/common.h | 1 +
src/brpc/builtin/hotspots_service.cpp | 3 --
src/brpc/builtin/pprof_service.cpp | 2 +-
src/bvar/variable.cpp | 64 ++++++++++++++++-------------------
5 files changed, 35 insertions(+), 39 deletions(-)
diff --git a/src/brpc/builtin/common.cpp b/src/brpc/builtin/common.cpp
index d9d90202..bfb8e546 100644
--- a/src/brpc/builtin/common.cpp
+++ b/src/brpc/builtin/common.cpp
@@ -26,6 +26,7 @@
#include "butil/third_party/murmurhash3/murmurhash3.h"
#include "butil/process_util.h" // ReadCommandLine
#include "brpc/server.h"
+#include "brpc/reloadable_flags.h"
#include "brpc/builtin/common.h"
namespace brpc {
@@ -33,6 +34,9 @@ namespace brpc {
DEFINE_string(rpc_profiling_dir, "./rpc_data/profiling",
"For storing profiling results.");
+DEFINE_int32(max_profiling_seconds, 300, "upper limit of running time of
profilers");
+BRPC_VALIDATE_GFLAG(max_profiling_seconds, PositiveInteger);
+
bool UseHTML(const HttpHeader& header) {
const std::string* console = header.uri().GetQuery(CONSOLE_STR);
if (console != nullptr) {
diff --git a/src/brpc/builtin/common.h b/src/brpc/builtin/common.h
index d2e77876..413c9afe 100644
--- a/src/brpc/builtin/common.h
+++ b/src/brpc/builtin/common.h
@@ -56,6 +56,7 @@ enum ProfilingType {
};
DECLARE_string(rpc_profiling_dir);
+DECLARE_int32(max_profiling_seconds);
bool UseHTML(const HttpHeader& header);
bool MatchAnyWildcard(const std::string& name,
diff --git a/src/brpc/builtin/hotspots_service.cpp
b/src/brpc/builtin/hotspots_service.cpp
index 2433a1e5..06ca5b27 100644
--- a/src/brpc/builtin/hotspots_service.cpp
+++ b/src/brpc/builtin/hotspots_service.cpp
@@ -106,9 +106,6 @@ static std::string GeneratePerlScriptPath(const
std::string& filename) {
extern bool cpu_profiler_enabled;
-DEFINE_int32(max_profiling_seconds, 300, "upper limit of running time of
profilers");
-BRPC_VALIDATE_GFLAG(max_profiling_seconds, NonNegativeInteger);
-
DEFINE_int32(max_profiles_kept, 32,
"max profiles kept for cpu/heap/growth/contention respectively");
BRPC_VALIDATE_GFLAG(max_profiles_kept, PassValidate);
diff --git a/src/brpc/builtin/pprof_service.cpp
b/src/brpc/builtin/pprof_service.cpp
index 3e445a9c..54a0d9a5 100644
--- a/src/brpc/builtin/pprof_service.cpp
+++ b/src/brpc/builtin/pprof_service.cpp
@@ -68,7 +68,7 @@ static int ReadSeconds(Controller* cntl) {
}
}
- return seconds;
+ return std::min(seconds, FLAGS_max_profiling_seconds);
}
int MakeProfName(ProfilingType type, char* buf, size_t buf_len) {
diff --git a/src/bvar/variable.cpp b/src/bvar/variable.cpp
index 688997d6..bdb6bb71 100644
--- a/src/bvar/variable.cpp
+++ b/src/bvar/variable.cpp
@@ -54,11 +54,35 @@ DEFINE_bool(bvar_abort_on_same_name, false, "Abort when
names of bvar are same")
BUTIL_VALIDATE_GFLAG(bvar_abort_on_same_name,
validate_bvar_abort_on_same_name);
-DEFINE_bool(bvar_log_dumpped, false,
- "[For debugging] print dumpped info"
- " into logstream before call Dumpper");
+DEFINE_bool(bvar_log_dumpped, false, "[For debugging] print dumpped info "
+ "into logstream before call Dumpper");
BUTIL_VALIDATE_GFLAG(bvar_log_dumpped, butil::PassValidate);
+DEFINE_bool(bvar_dump, false, "Create a background thread dumping all bvar
periodically, "
+ "all bvar_dump_* flags are not effective when
this flag is off");
+DEFINE_int32(bvar_dump_interval, 10, "Seconds between consecutive dump");
+DEFINE_string(bvar_dump_file, "monitor/bvar.<app>.data",
+ "Dump bvar into this file, not settable at runtime");
+DEFINE_string(bvar_dump_include, "", "Dump bvar matching these wildcards,
separated "
+ "by semicolon(;), empty means including
all");
+DEFINE_string(bvar_dump_exclude, "", "Dump bvar excluded from these wildcards,
"
+ "separated by semicolon(;), empty means
no exclusion");
+DEFINE_string(bvar_dump_prefix, "<app>", "Every dumped name starts with this
prefix");
+DEFINE_string(bvar_dump_tabs, "latency=*_latency*"
+ ";qps=*_qps*"
+ ";error=*_error*"
+ ";system=*process_*,*malloc_*,*kernel_*",
+ "Dump bvar into different tabs according to the filters
(separated by semicolon), "
+ "format: *(tab_name=wildcards;), not settable at runtime");
+
+DEFINE_bool(mbvar_dump, false, "Create a background thread dumping(shares the
same thread as "
+ "bvar_dump) all mbvar periodically, all
mbvar_dump_* flags are "
+ "not effective when this flag is off");
+DEFINE_string(mbvar_dump_file, "monitor/mbvar.<app>.data",
+ "Dump mbvar into this file, not settable at runtime");
+DEFINE_string(mbvar_dump_prefix, "<app>", "Every dumped name starts with this
prefix");
+DEFINE_string(mbvar_dump_format, "common", "Dump mbvar write format");
+
const size_t SUB_MAP_COUNT = 32; // must be power of 2
BAIDU_CASSERT(!(SUB_MAP_COUNT & (SUB_MAP_COUNT - 1)), must_be_power_of_2);
@@ -120,8 +144,8 @@ inline VarMapWithLock& get_var_map(const std::string& name)
{
}
Variable::~Variable() {
- CHECK(!hide()) << "Subclass of Variable MUST call hide() manually in their"
- " dtors to avoid displaying a variable that is just destructing";
+ CHECK(!hide()) << "Subclass of Variable MUST call hide() manually in their
"
+ "dtors to avoid displaying a variable that is just
destructing";
}
int Variable::expose_impl(const butil::StringPiece& prefix,
@@ -741,30 +765,6 @@ static bool created_dumping_thread = false;
static pthread_mutex_t dump_mutex = PTHREAD_MUTEX_INITIALIZER;
static pthread_cond_t dump_cond = PTHREAD_COND_INITIALIZER;
-DEFINE_bool(bvar_dump, false,
- "Create a background thread dumping all bvar periodically, "
- "all bvar_dump_* flags are not effective when this flag is off");
-DEFINE_int32(bvar_dump_interval, 10, "Seconds between consecutive dump");
-DEFINE_string(bvar_dump_file, "monitor/bvar.<app>.data", "Dump bvar into this
file");
-DEFINE_string(bvar_dump_include, "", "Dump bvar matching these wildcards, "
- "separated by semicolon(;), empty means including all");
-DEFINE_string(bvar_dump_exclude, "", "Dump bvar excluded from these wildcards,
"
- "separated by semicolon(;), empty means no exclusion");
-DEFINE_string(bvar_dump_prefix, "<app>", "Every dumped name starts with this
prefix");
-DEFINE_string(bvar_dump_tabs, "latency=*_latency*"
- ";qps=*_qps*"
- ";error=*_error*"
- ";system=*process_*,*malloc_*,*kernel_*",
- "Dump bvar into different tabs according to the filters
(separated by semicolon), "
- "format: *(tab_name=wildcards;)");
-
-DEFINE_bool(mbvar_dump, false,
- "Create a background thread dumping(shares the same thread as
bvar_dump) all mbvar periodically, "
- "all mbvar_dump_* flags are not effective when this flag is off");
-DEFINE_string(mbvar_dump_file, "monitor/mbvar.<app>.data", "Dump mbvar into
this file");
-DEFINE_string(mbvar_dump_prefix, "<app>", "Every dumped name starts with this
prefix");
-DEFINE_string(mbvar_dump_format, "common", "Dump mbvar write format");
-
#if !defined(BVAR_NOT_LINK_DEFAULT_VARIABLES)
// Expose bvar-releated gflags so that they're collected by noah.
// Maybe useful when debugging process of monitoring.
@@ -951,22 +951,16 @@ static bool wakeup_dumping_thread(const char*, const
std::string&) {
return true;
}
-const bool ALLOW_UNUSED dummy_bvar_dump_file =
GFLAGS_NAMESPACE::RegisterFlagValidator(
- &FLAGS_bvar_dump_file, wakeup_dumping_thread);
const bool ALLOW_UNUSED dummy_bvar_dump_filter =
GFLAGS_NAMESPACE::RegisterFlagValidator(
&FLAGS_bvar_dump_include, wakeup_dumping_thread);
const bool ALLOW_UNUSED dummy_bvar_dump_exclude =
GFLAGS_NAMESPACE::RegisterFlagValidator(
&FLAGS_bvar_dump_exclude, wakeup_dumping_thread);
const bool ALLOW_UNUSED dummy_bvar_dump_prefix =
GFLAGS_NAMESPACE::RegisterFlagValidator(
&FLAGS_bvar_dump_prefix, wakeup_dumping_thread);
-const bool ALLOW_UNUSED dummy_bvar_dump_tabs =
GFLAGS_NAMESPACE::RegisterFlagValidator(
- &FLAGS_bvar_dump_tabs, wakeup_dumping_thread);
BUTIL_VALIDATE_GFLAG(mbvar_dump, validate_bvar_dump);
const bool ALLOW_UNUSED dummy_mbvar_dump_prefix =
GFLAGS_NAMESPACE::RegisterFlagValidator(
&FLAGS_mbvar_dump_prefix, wakeup_dumping_thread);
-const bool ALLOW_UNUSED dump_mbvar_dump_file =
GFLAGS_NAMESPACE::RegisterFlagValidator(
- &FLAGS_mbvar_dump_file, wakeup_dumping_thread);
static bool validate_mbvar_dump_format(const char*, const std::string& format)
{
if (format != "common"
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]