apache / brpc

brpc is an Industrial-grade RPC framework using C++ Language, which is often used in high performance system such as Search, Storage, Machine learning, Advertisement, Recommendation etc. "brpc" means "better RPC".

Home Page:https://brpc.apache.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

动态设置"TCMALLOC_SAMPLE_PARAMETER"以支持动态开关pprof/heap采样

promoon opened this issue · comments

Is your feature request related to a problem? (你需要的功能是否与某个问题有关?)
pprof/heap 无法动态开启或关闭tcmalloc采样。

bool has_TCMALLOC_SAMPLE_PARAMETER() {

    static bool val = check_TCMALLOC_SAMPLE_PARAMETER();

    return val;

}

Describe the solution you'd like (描述你期望的解决方法)
能够支持通过设置"TCMALLOC_SAMPLE_PARAMETER" 环境变量动态开启/关闭tcmalloc采样

Describe alternatives you've considered (描述你想到的折衷方案)
这个val值为什么要设为static,是否可以去掉从而支持动态设置"TCMALLOC_SAMPLE_PARAMETER" 环境变量

Additional context/screenshots (更多上下文/截图)

这是tcmalloc库的行为,tcmalloc在启动时读取TCMALLOC_SAMPLE_PARAMETER环境变量,即使你后面修改了这个环境变量,也是不生效的

@wwbmmm 明白了,看了下gperftools源码中是不支持动态设置的