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
init: add MALLOC_ARENA_MAX=1 to systemd #27642
Conversation
This adds the `MALLOC_ARENA_MAX=1` environment variable as suggested in https://github.com/bitcoin/bitcoin/blob/master/doc/reduce-memory.md#linux-specific to the systemd service file definition. Without this env var, memory usage can grow significantly especially when `rpcthreads` is increased above its default value. Closes bitcoin#24542.
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ReviewsSee the guideline for information on the review process. |
I don't believe this affects the majority of users (where the two pools per core default works fine), so I don't see why we'd update the default service file like this. We have documentation that describes what to do to reduce memory in the event that one wants to do that? |
Maybe it's my fault for not digging into the docs more but I went over a year with inflated, unpredictable RAM usage and even occasional OOM crashes on a machine that I wouldn't consider particularly memory-constrained. It looks like the reason I was seeing it was due to a higher My thinking is that if in fact the performance impact is "small or absent" in bitcoind then this is a sensible default for linux machines. |
From the doc:
The "expected to be" could use some benchmarks before making it a default. Does the problem only happen with high |
From my understanding/reading of |
More relevant discussion here: #6876 (comment) |
@sangaman maybe |
Now that #25325 has been merged, this might be less of an issue. This pool allocator significantly reduces the number of allocations used for |
Thanks! I'll try that branch out and see if resolves the underlying issue without this env var, in which case I'd agree this PR is probably not necessary. |
Note that internally we already set |
I'm 64 bit indeed, but wouldn't the same concern be present on 32 bit systems? I just restarted my node with the changes from #25325 and without the |
There hasn't been much activity lately. What is the status here? Finding reviewers may take time. However, if the patch is no longer relevant, please close this pull request. If the author lost interest or time to work on this, please close it and mark it 'Up for grabs' with the label, so that it can be picked up in the future. |
Just because it's desirable for the purpose of running on low-memory systems does not mean it should be a default for all systemd users of bitcoind? If it's useful always, it should probably be recommended outside a doc about reducing memory usage. Alternatively, it sounds like maybe we need to document that increasing |
Any insights here? Has the issue been resolved for you? Note that https://www.gnu.org/software/libc/manual/html_node/Memory-Allocation-Tunables.html says:
This means what we say in https://github.com/bitcoin/bitcoin/blob/master/doc/reduce-memory.md#linux-specific is wrong (i.e., only true for 32 bits):
|
Before this commit, we claim that glibc's malloc implementation uses 2 arenas by default. But that's true only on 32-bit systems, and even there, it uses *up* to 2 arenas. This commit fixes the wrong statement. The new statement is intentionally vague to reduce our maintenance burden. For details, see: https://www.gnu.org/software/libc/manual/html_node/Memory-Allocation-Tunables.html#index-glibc_002emalloc_002earena_005fmax Noticed in: bitcoin#27642 (comment)
This PR does not seem to have conceptual support. Please leave a comment if you would like this to be reopened. |
…LOC_ARENA_MAX 12f7257 doc: Be vague instead of wrong about MALLOC_ARENA_MAX (Tim Ruffing) Pull request description: Before this commit, we claim that glibc's malloc implementation uses 2 arenas by default. But that's true only on 32-bit systems, and even there, it uses *up* to 2 arenas. This commit fixes the wrong statement. The new statement is intentionally vague to reduce our maintenance burden. For details, see: https://www.gnu.org/software/libc/manual/html_node/Memory-Allocation-Tunables.html#index-glibc_002emalloc_002earena_005fmax Noticed in: bitcoin/bitcoin#27642 (comment) ACKs for top commit: fanquake: ACK 12f7257 Tree-SHA512: c0ff1e35b682a841e366a1cad26e18ff79a93d97103529be35a972c7dcbb95f5354e7a7b98a86731f491434d64685bb58cc3cc9100f0577d8f75db05e951b09a
Before this commit, we claim that glibc's malloc implementation uses 2 arenas by default. But that's true only on 32-bit systems, and even there, it uses *up* to 2 arenas. This commit fixes the wrong statement. The new statement is intentionally vague to reduce our maintenance burden. For details, see: https://www.gnu.org/software/libc/manual/html_node/Memory-Allocation-Tunables.html#index-glibc_002emalloc_002earena_005fmax Noticed in: bitcoin#27642 (comment)
Before this commit, we claim that glibc's malloc implementation uses 2 arenas by default. But that's true only on 32-bit systems, and even there, it uses *up* to 2 arenas. This commit fixes the wrong statement. The new statement is intentionally vague to reduce our maintenance burden. For details, see: https://www.gnu.org/software/libc/manual/html_node/Memory-Allocation-Tunables.html#index-glibc_002emalloc_002earena_005fmax Noticed in: bitcoin/bitcoin#27642 (comment)
This adds the MALLOC_ARENA_MAX=1 environment variable as suggested in https://github.com/bitcoin/bitcoin/blob/master/doc/reduce-memory.md#linux-specific to the systemd service file definition.
Without this env var, memory usage can grow significantly especially when rpcthreads is increased above its default value.
Closes #24542.
I have tested this change myself with positive results after dealing with memory consumption issues for a long time using systemd on a 8GB RAM raspi4. I figure a similar change may be desirable for the OpenRC and CentOS init files, but I don't have a way to test them and I'm not even exactly sure how environment variables should be added there (via export statements?).