Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please copy-paste ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
220a1ae to
6b0210e
Compare
|
🚧 At least one of the CI tasks failed. HintsTry to run the tests locally, according to the documentation. However, a CI failure may still
Leave a comment here, if you need help tracking down a confusing failure. |
ajtowns
left a comment
There was a problem hiding this comment.
Having a fairly simple bump to the dbcache seems better than adding scaling logic to me, fwiw (hi insta).
|
Concept ACK 6b0210e I agree with Ajtowns, I think it makes more sense to have a simple bump in cache size instead of auto scaling. |
|
We might want to add a release note since this will affect any nodes that currently do not have -dbcache set running on systems with greater than 4 GB RAM |
If dbcache is unset, bump default from 450MB to 1024MB on 64-bit systems that have at least 4GB of detected RAM.
6b0210e to
cdd8eae
Compare
cdd8eae to
aed2f7f
Compare
|
🚧 At least one of the CI tasks failed. HintsTry to run the tests locally, according to the documentation. However, a CI failure may still
Leave a comment here, if you need help tracking down a confusing failure. |
aed2f7f to
4ae9a10
Compare
|
Thanks @ajtowns I took all your suggestions. |
|
ACK 4ae9a10 Checked it gives 450 on a system with less than 4GB and 1024 on a system with more. |
|
If you want to avoid changing kernel behavior in this PR, it would be good to state so in the PR-description. "This change only changes bitcoind behavior, while kernel still defaults to 450 MiB." bitcoin/src/kernel/bitcoinkernel.cpp Line 463 in 2702711 bitcoin/src/kernel/bitcoinkernel.cpp Line 1013 in 2702711 Please also use the correct "GiB" unit in PR title. (Edit: and correct all units in the PR description). |
|
Concept ~0 because i think it's fine if this PR is merged as is, but i reject the premise that we should be supporting systems with very low memory through the default configuration. I think the goal of supporting systems with low resources is better achieved with configuration presets (as was suggested in the meeting where this issue was discussed) than with complicated and surprising system resource detection baked into our code. |
|
Put this on the milestone, to gather any more opinons/make a decision for |
|
Concept ACK |
|
Concept ACK - Prefer incremental improvement |
@yancyribbens do you mean making |
Oh, great! Then, I think if this breaks the default compatibility for some users, then they would simply need to adjust their configuration.. |
|
@yancyribbens It really helps to read PRs before commenting on them. |
Leave it up to @sipa to put me in my place, again. Fair point. |
|
reACK 4ae9a10 This looks good to me, I think it makes sense to continue to support low RAM systems and not do a simple bump. This is good to get into the v31.0 release without being too complicated and revisit the autoscaling RAM in a later release if desired. changes from last ack: |
Been thinking about this some more. I still think it's preferable this PR be merged as-is for 31.0, but a different approach could be:
That lets us set the defaults to a single value that achieve reasonable performance on reasonable hardware, and leaves achieving great performance or running on unreasonable hardware with poor performance up to people to configure. I feel like simple good-enough defaults and flexible configuration options is a better approach than trying to make the defaults automatically optimise themselves for the hardware, a la #34641. Having a check and an early error when we can detect that the good-enough defaults are probably not appropriate for the hardware would be a win on top of that, I think, while also not making things much more complex. For people who specifically want automatic optimisation of their config, then a third party tool (lopp's bitcoin.conf generator?) or AI consultation would let them achieve that. |
| namespace node { | ||
| size_t GetDefaultDBCache() | ||
| { | ||
| if constexpr (sizeof(void*) >= 8) { |
There was a problem hiding this comment.
is this check for 64 bit system actually needed here? I believe it's possible to run PAE kernel versions that allow for 32 bit systems to address 4+ Gigs of memory.
There was a problem hiding this comment.
Also, along those lines, I think if you are running on i86 and have 4gib, it would be preferable to use the 1Gb cache size...
There was a problem hiding this comment.
Maybe not necessary, but of course these users can always set the config themselves.
| The size of some in-memory caches can be reduced. As caches trade off memory usage for performance, reducing these will usually have a negative effect on performance. | ||
|
|
||
| - `-dbcache=<n>` - the UTXO database cache size, this defaults to `450`. The unit is MiB (1024). | ||
| - `-dbcache=<n>` - the UTXO database cache size, this defaults to `1024` (or `450` if less than `4096` MiB system RAM is detected). The unit is MiB (1024). |
There was a problem hiding this comment.
nit: technically this is checking for if is not 64bit and is less than 4096 MiB system RAM
| ## Updated settings | ||
|
|
||
| - The default `-dbcache` value has been increased to `1024` MiB from `450` MiB | ||
| on systems where at least `4096` MiB of RAM is detected. |
There was a problem hiding this comment.
Same as previous nit (64 bit thing).
|
One edge case to consider is how For example, if a Docker container is started with However, the container’s memory limit is exposed through cgroups. In this setup, |
|
ACK 4ae9a10 Reviewed the code, built and ran it. Can attest that it defaults to 1024 without the dbcache set, and still to 450 with dbcache=450. Since I have no machine with less than 4GB available, tried to patch the GetTotalRAM function to set it to 2GB, but it did not work, since the dynamic linker never resolves it. Failed attempt to patch GetTotalRam
// fake_ram.cpp
#include
#include
Compile: Test with fake 2 GB RAM Test results$ ./build/bin/bitcoind --version | grep version $ ./build/bin/bitcoind -regtest -dbcache=450 | grep 2026-03-06T12:53:03Z Cache configuration: $ ./build/bin/bitcoind -regtest | grep -E "Cache|MiB" |
|
It seems I may be too conservative when trying not to break use cases, since most other reviewers don't seem to think it's a big issue. I suppose there are likely very few users running on <4GB that are not already configuring their defaults and reading release notes. The defaults are meant for newbies who aren't yet configuring, which are likely on higher RAM systems. Nevertheless, this PR is meant to be a last minute sneak in to v31. There are already several ACKs, and those with suggestions explicitly said they do not mind it being merged as is. So, I'm going to leave it as is for now and hopefully a maintainer will merge before cutoff.
@ajtowns Since #33333 we warn on oversized dbcache. I think it would make sense to tighten that up to an error. |
|
ACK 4ae9a10 |
Wouldn't that be surprising to merge the detection if it doesn't work on containers:
which are at least as common a setup as VMs are, which were used as the main argument for the detection in the first place:
(In any case anybody technical enough to spin up a VM or a container is able to set a configuration option, it's not like we are breaking a use case, but hey.) Edited for clarity since apparently the condescending comment that ensued was genuine. |
|
I opened #34763 as an alternative that only bumps the default without introducing the detection. |
A VM is not the same as a container, and will present available memory differently. In the case with AWS VPSes, the machine will appear to have the specified amount of memory and not be affected by this issue. |
Oh, really? |
This actually goes back to when chroot was introduced in 1979 as a way to provide an isolated filesystem while still using the same host kernel. FreeBSD extended this idea to also include isolation for other devices in the form of Jails, which was sort of co-opted later in the form of linux containers. Containers also brought along a who ecosystem of reproducible install tools eg Docker. I'm still pretty found of jails though for their simplicity over containers, and of course less overhead than VMs. Anyway, there's a pretty interesting detail of this here: https://hypha.pub/back-to-freebsd-part-1. |
I argue with that. A large number of bitcoin-core runners will give zero thought about RAM sizes and memory limits, and expect things to work, and if things don't work optimally, they will blame the software. Even if there was concrete guidance offered, like "set dbcache to 20% of the available RAM" (there is no such guidance), most users would not comply. I think context-aware meaningful defaults are very useful. Context-aware estimated min/max values are also needed to be able to generate meaningful warnings in case user configuration is present, but nonsensical. I think context-aware defaults that try to cover a wider range of different systems (like #34641) are better overall. But for sure user configuration should be able to override everything. |
Refusing to start on unreasonable values is an interesting idea. But I see inconsistency here: if we trust the software-decided reasonable-limits so much that it can even refuse to start, why not trust a default to be used? The logic/reliability to derive the optimal default and unreasonable limits are very similar. To me it looks more consistent and useful to:
I think this gives the best combo for:
|
|
Post-merge-ACK 4ae9a10 A limited change of the single-value limit to a two-tier limit, benefiting IBD performance on (the majority?) non-low-memory systems, for v31. |
Alternative to #34641
This increases the default
dbcachevalue from450MiBto1024MiBif:dbcacheis unsetOtherwise fallback to previous
450MiBdefault.This should be simple enough to get into v31. The bump to 1GiB shows significant performance increases in #34641. It also alleviates concerns of too high default for steady state, and of lowering the current dbcache for systems with less RAM.
This change only changes bitcoind behavior, while kernel still defaults to 450 MiB.