Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(pprof): Supports both heap profiling and heap sampling #1684

Merged
merged 3 commits into from
Nov 20, 2023

Conversation

acelyc111
Copy link
Member

@acelyc111 acelyc111 commented Nov 16, 2023

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.

@github-actions github-actions bot added the cpp label Nov 16, 2023
@acelyc111 acelyc111 merged commit a276661 into apache:master Nov 20, 2023
90 of 92 checks passed
GehaFearless pushed a commit to GehaFearless/incubator-pegasus that referenced this pull request Feb 28, 2024
)

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants