init: auto-size dbcache to available system RAM#279
Conversation
|
How does this compare to bitcoin#34641 ? |
|
@luke-jr Same idea, although this PR is more aggressive. This PR uses |
|
My first thought is - who are we optimising the default dbcache for? Examples include:
IMHO, home users should not be expected to know how to configure Bitcoin Knots' dbcache. I believe the configuration should be made conservative and safe for this group. Basically, we are making choices on their behalf. For these reasons alone, autosizing to use half of the system's physical RAM is a "Concept NAK" for me. I've found lookups via dbcache are O(1). Lookups via LevelDB are O(log(n)). My gut feeling is, for home users (who are the only group we are making this decision for), that no more than 25% of system RAM should be auto-allocated for Bitcoin Knots. |
This seems like a very sensible suggestion to me. If we're encouraging more people to run Knots for the good of the network, and themselves, it would be better if doing so not be more likely to OOM their apps. |
Auto-size the default dbcache to half of system RAM (capped at 16 GiB) instead of the hardcoded 450 MiB default. Falls back to 450 MiB on platforms where RAM detection fails.
Also enables
-lowmemby default with a 256 MiB threshold so caches are flushed before the system runs out of memory.Platform support: Linux (
sysinfo), Windows (GlobalMemoryStatusEx), macOS (sysctlbyname).Closes #70