init: Simplify coinsdb cache calculation

(total_cache / 4) + (1 << 23) is at least 8 MiB and nMaxCoinsDBCache is
also 8 MiB, so the minimum between the two will always be
nMaxCoinsDBCache.

Co-authored-by: Ryan Ofsky <ryan@ofsky.org>
This commit is contained in:
TheCharlatan 2024-12-17 21:33:56 +01:00
parent 5db7d4d3d2
commit 19316eccaf
No known key found for this signature in database
GPG key ID: 9B79B45691DB4173

View file

@ -24,8 +24,7 @@ CacheSizes CalculateCacheSizes(const ArgsManager& args, size_t n_indexes)
sizes.filter_index = max_cache / n_indexes;
nTotalCache -= sizes.filter_index * n_indexes;
}
sizes.coins_db = std::min(nTotalCache / 2, (nTotalCache / 4) + (1 << 23)); // use 25%-50% of the remainder for disk cache
sizes.coins_db = std::min(sizes.coins_db, nMaxCoinsDBCache << 20); // cap total coins db cache
sizes.coins_db = std::min(nTotalCache / 2, nMaxCoinsDBCache << 20);
nTotalCache -= sizes.coins_db;
sizes.coins = nTotalCache; // the rest goes to in-memory cache
return sizes;