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

Add mallocinfo mode to `getmemoryinfo` RPC #10038

Merged
merged 1 commit into from Mar 20, 2017

Conversation

Projects
None yet
6 participants
@laanwj
Copy link
Member

laanwj commented Mar 20, 2017

This adds a mode argument to getmemoryinfo. By default the output will remain the same. However if a mode argument of mallocinfo is provided the result of glibc malloc_info (if available) will be returned as a string, as-is.

This output contains detailed malloc heap statistics, and is useful for tracking heap usage over time or troubleshooting memory fragmentation issues.

@laanwj laanwj added the RPC/REST/ZMQ label Mar 20, 2017

Add mallocinfo mode to `getmemoryinfo` RPC
This adds a mode argument to `getmemoryinfo`. By default the output
will remain the same. However if a mode argument of `mallocinfo` is
provided the result of glibc `malloc_info` (if available) will
be returned as a string, as-is.

This is useful for tracking heap usage over time or troubleshooting
memory fragmentation issues.
std::string mode = (request.params.size() < 1 || request.params[0].isNull()) ? "stats" : request.params[0].get_str();
if (mode == "stats") {
UniValue obj(UniValue::VOBJ);
obj.push_back(Pair("locked", RPCLockedMemoryInfo()));

This comment has been minimized.

@jonasschnelli

jonasschnelli Mar 20, 2017

Member

Don't we need to escape this in some ways? Or is that handled by UniValue?

This comment has been minimized.

@laanwj

laanwj Mar 20, 2017

Author Member

That's handled by UniValue. The whole object is returned as a JSON string.
(UniValue has an implicit constructor from string).

@laanwj

This comment has been minimized.

Copy link
Member Author

laanwj commented Mar 20, 2017

As for the GLIBC 2.10 symbol requirement, the minimum version of glibc in our symbol checker is 2.11, so this is acceptable for binary releases: https://github.com/bitcoin/bitcoin/blob/master/contrib/devtools/symbol-check.py#L43

@jonasschnelli

This comment has been minimized.

Copy link
Member

jonasschnelli commented Mar 20, 2017

Nice. To bad there is no clang equivalent of malloc_info(). This will be linux only.
Tested ACK e141aa4
https://bitcoin.jonasschnelli.ch/build/PR/10038

bildschirmfoto 2017-03-20 um 12 12 06

bildschirmfoto 2017-03-20 um 12 16 54

@laanwj

This comment has been minimized.

Copy link
Member Author

laanwj commented Mar 20, 2017

Nice. To bad there is no clang equivalent of malloc_info(). This will be linux only.

Clang on Linux simply uses glibc. But yeah, other libc's will either have equivalent calls or maybe not, it's specific to the malloc implementation.

@fanquake

This comment has been minimized.

Copy link
Member

fanquake commented Mar 20, 2017

Tested on OSX ACK e141aa4
screen shot

@laanwj laanwj merged commit e141aa4 into bitcoin:master Mar 20, 2017

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

laanwj added a commit that referenced this pull request Mar 20, 2017

Merge #10038: Add mallocinfo mode to `getmemoryinfo` RPC
e141aa4 Add mallocinfo mode to `getmemoryinfo` RPC (Wladimir J. van der Laan)

Tree-SHA512: e778631765c29b3b5fb94eb66e5f50a8f108a234891bdcc4883f1e6e2fdd223f7660fad987eb2d7cbda5b800482d78adc1a309a3f6f83a84c556af43ebee2ed7
@paveljanik

This comment has been minimized.

Copy link
Contributor

paveljanik commented Mar 20, 2017

postmerge ACK (was merged in the middle of my testing)

@laanwj

This comment has been minimized.

Copy link
Member Author

laanwj commented Mar 20, 2017

postmerge ACK (was merged in the middle of my testing)

Yeah sorry for that, getting this in soon is kind of important due to all the reported OOM issues with 0.14.

@TheBlueMatt

This comment has been minimized.

Copy link
Contributor

TheBlueMatt commented Mar 20, 2017

postumous utACK e141aa4

@luke-jr

This comment has been minimized.

Copy link
Member

luke-jr commented Apr 8, 2017

Is there a reason not to just add it as an additional key in the result?

@laanwj

This comment has been minimized.

Copy link
Member Author

laanwj commented Apr 10, 2017

Is there a reason not to just add it as an additional key in the result?

I did that first, but having a huge encoded XML string field in the default JSON object output was ugly. Also this information is potentially slow to compile, so it's better to have it on an separate entry point.

PastaPastaPasta added a commit to PastaPastaPasta/dash that referenced this pull request Mar 10, 2019

Merge bitcoin#10038: Add mallocinfo mode to `getmemoryinfo` RPC
e141aa4 Add mallocinfo mode to `getmemoryinfo` RPC (Wladimir J. van der Laan)

Tree-SHA512: e778631765c29b3b5fb94eb66e5f50a8f108a234891bdcc4883f1e6e2fdd223f7660fad987eb2d7cbda5b800482d78adc1a309a3f6f83a84c556af43ebee2ed7

PastaPastaPasta added a commit to PastaPastaPasta/dash that referenced this pull request Mar 11, 2019

Merge bitcoin#10038: Add mallocinfo mode to `getmemoryinfo` RPC
e141aa4 Add mallocinfo mode to `getmemoryinfo` RPC (Wladimir J. van der Laan)

Tree-SHA512: e778631765c29b3b5fb94eb66e5f50a8f108a234891bdcc4883f1e6e2fdd223f7660fad987eb2d7cbda5b800482d78adc1a309a3f6f83a84c556af43ebee2ed7

PastaPastaPasta added a commit to PastaPastaPasta/dash that referenced this pull request Mar 11, 2019

Merge bitcoin#10038: Add mallocinfo mode to `getmemoryinfo` RPC
e141aa4 Add mallocinfo mode to `getmemoryinfo` RPC (Wladimir J. van der Laan)

Tree-SHA512: e778631765c29b3b5fb94eb66e5f50a8f108a234891bdcc4883f1e6e2fdd223f7660fad987eb2d7cbda5b800482d78adc1a309a3f6f83a84c556af43ebee2ed7

PastaPastaPasta added a commit to PastaPastaPasta/dash that referenced this pull request Mar 12, 2019

Merge bitcoin#10038: Add mallocinfo mode to `getmemoryinfo` RPC
e141aa4 Add mallocinfo mode to `getmemoryinfo` RPC (Wladimir J. van der Laan)

Tree-SHA512: e778631765c29b3b5fb94eb66e5f50a8f108a234891bdcc4883f1e6e2fdd223f7660fad987eb2d7cbda5b800482d78adc1a309a3f6f83a84c556af43ebee2ed7

PastaPastaPasta added a commit to PastaPastaPasta/dash that referenced this pull request Mar 13, 2019

Merge bitcoin#10038: Add mallocinfo mode to `getmemoryinfo` RPC
e141aa4 Add mallocinfo mode to `getmemoryinfo` RPC (Wladimir J. van der Laan)

Tree-SHA512: e778631765c29b3b5fb94eb66e5f50a8f108a234891bdcc4883f1e6e2fdd223f7660fad987eb2d7cbda5b800482d78adc1a309a3f6f83a84c556af43ebee2ed7

UdjinM6 added a commit to UdjinM6/dash that referenced this pull request Mar 13, 2019

Merge bitcoin#10038: Add mallocinfo mode to `getmemoryinfo` RPC
e141aa4 Add mallocinfo mode to `getmemoryinfo` RPC (Wladimir J. van der Laan)

Tree-SHA512: e778631765c29b3b5fb94eb66e5f50a8f108a234891bdcc4883f1e6e2fdd223f7660fad987eb2d7cbda5b800482d78adc1a309a3f6f83a84c556af43ebee2ed7

PastaPastaPasta added a commit to PastaPastaPasta/dash that referenced this pull request Mar 13, 2019

Merge bitcoin#10038: Add mallocinfo mode to `getmemoryinfo` RPC
e141aa4 Add mallocinfo mode to `getmemoryinfo` RPC (Wladimir J. van der Laan)

Tree-SHA512: e778631765c29b3b5fb94eb66e5f50a8f108a234891bdcc4883f1e6e2fdd223f7660fad987eb2d7cbda5b800482d78adc1a309a3f6f83a84c556af43ebee2ed7

PastaPastaPasta added a commit to PastaPastaPasta/dash that referenced this pull request Mar 14, 2019

Merge bitcoin#10038: Add mallocinfo mode to `getmemoryinfo` RPC
e141aa4 Add mallocinfo mode to `getmemoryinfo` RPC (Wladimir J. van der Laan)

Tree-SHA512: e778631765c29b3b5fb94eb66e5f50a8f108a234891bdcc4883f1e6e2fdd223f7660fad987eb2d7cbda5b800482d78adc1a309a3f6f83a84c556af43ebee2ed7

PastaPastaPasta added a commit to PastaPastaPasta/dash that referenced this pull request Mar 14, 2019

Merge bitcoin#10038: Add mallocinfo mode to `getmemoryinfo` RPC
e141aa4 Add mallocinfo mode to `getmemoryinfo` RPC (Wladimir J. van der Laan)

Tree-SHA512: e778631765c29b3b5fb94eb66e5f50a8f108a234891bdcc4883f1e6e2fdd223f7660fad987eb2d7cbda5b800482d78adc1a309a3f6f83a84c556af43ebee2ed7

PastaPastaPasta added a commit to PastaPastaPasta/dash that referenced this pull request Mar 15, 2019

Merge bitcoin#10038: Add mallocinfo mode to `getmemoryinfo` RPC
e141aa4 Add mallocinfo mode to `getmemoryinfo` RPC (Wladimir J. van der Laan)

Tree-SHA512: e778631765c29b3b5fb94eb66e5f50a8f108a234891bdcc4883f1e6e2fdd223f7660fad987eb2d7cbda5b800482d78adc1a309a3f6f83a84c556af43ebee2ed7

PastaPastaPasta added a commit to PastaPastaPasta/dash that referenced this pull request Mar 16, 2019

Merge bitcoin#10038: Add mallocinfo mode to `getmemoryinfo` RPC
e141aa4 Add mallocinfo mode to `getmemoryinfo` RPC (Wladimir J. van der Laan)

Tree-SHA512: e778631765c29b3b5fb94eb66e5f50a8f108a234891bdcc4883f1e6e2fdd223f7660fad987eb2d7cbda5b800482d78adc1a309a3f6f83a84c556af43ebee2ed7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.