diff --git a/src/init.cpp b/src/init.cpp index 1163f756e..c1b53af7b 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -2002,8 +2002,14 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) int64_t nBlockTreeDBCache = nTotalCache / 8; if (GetBoolArg("-addressindex", DEFAULT_ADDRESSINDEX) || GetBoolArg("-spentindex", DEFAULT_SPENTINDEX)) { - // enable 3/4 of the cache if addressindex and/or spentindex is enabled + // Give indexed (address/spent-index) nodes a larger index LevelDB read cache, but CAP it. + // With adaptive dbcache, nTotalCache is now multi-GB, so 3/4 of it is several GB -- far more + // than the index cache can use, while starving the in-memory UTXO set that actually speeds + // IBD (and this chunk is not shrinkable by the memory-pressure controller, which only adjusts + // the coins cache). Cap at 1 GiB so the adaptive budget flows to the coins cache. Tunable. nBlockTreeDBCache = nTotalCache * 3 / 4; + if (nBlockTreeDBCache > ((int64_t)1024 << 20)) + nBlockTreeDBCache = ((int64_t)1024 << 20); } else { if (nBlockTreeDBCache > (1 << 21) && !GetBoolArg("-txindex", false)) { nBlockTreeDBCache = (1 << 21); // block tree db cache shouldn't be larger than 2 MiB