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".
https://brpc.apache.org
Apache License 2.0
16.05k stars 3.92k forks source link

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

Closed promoon closed 1 month ago

promoon commented 1 month ago

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 (更多上下文/截图)

wwbmmm commented 1 month ago

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

promoon commented 1 month ago

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