Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(pprof): Supports both heap profiling and heap sampling (#1684)
In XiaoMi/rdsn#433, we updated the way to get heap profile by using ``` HeapProfilerStart(...); sleep(seconds); GetHeapProfile(); HeapProfilerStop(); ``` instead of ``` MallocExtension::instance()->GetHeapSample(...); ``` It provides a way to analyse which pieces of code allocated (and possibly freed) how much memory during the time the request processed on the server. However, in the scenario of a server already in heavy memory consumption but growing very slow, it's hard to tell which pieces of code allocated the most of the memory. This patch adds the heap sampling back, and keep the heap profiling as well. Both of the two ways are using the `pprof/heap` method, the difference is whether the `seconds` parameter appears. When the `seconds` parameter appears, using `GetHeapProfile()`, otherwise, using `GetHeapSample()`. Remember to set environment variable TCMALLOC_SAMPLE_PARAMETER when using heap sampling.
- Loading branch information