aboutsummaryrefslogtreecommitdiff
path: root/src/init.cpp
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2012-11-04 17:11:48 +0100
committerPieter Wuille <pieter.wuille@gmail.com>2012-11-04 18:06:25 +0100
commit1c83b0a3771bc601fdc75588f2cd45318b19c526 (patch)
tree3c81936fefc0a962c764522057cb6d68e6c230e4 /src/init.cpp
parenta56d3f8a10e3c9f844aee1f362635ae14b872023 (diff)
Cache size optimizations
Diffstat (limited to 'src/init.cpp')
-rw-r--r--src/init.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/init.cpp b/src/init.cpp
index 1724382bf5..b3ae69d6e3 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -236,7 +236,6 @@ std::string HelpMessage()
" -gen=0 " + _("Don't generate coins") + "\n" +
" -datadir=<dir> " + _("Specify data directory") + "\n" +
" -dbcache=<n> " + _("Set database cache size in megabytes (default: 25)") + "\n" +
- " -dblogsize=<n> " + _("Set database disk log size in megabytes (default: 100)") + "\n" +
" -timeout=<n> " + _("Specify connection timeout in milliseconds (default: 5000)") + "\n" +
" -proxy=<ip:port> " + _("Connect through socks proxy") + "\n" +
" -socks=<n> " + _("Select the version of socks proxy to use (4-5, default: 5)") + "\n" +
@@ -651,11 +650,23 @@ bool AppInit2()
return InitError(msg);
}
+ // cache size calculations
+ size_t nTotalCache = GetArg("-dbcache", 25) << 20;
+ if (nTotalCache < (1 << 22))
+ nTotalCache = (1 << 22); // total cache cannot be less than 4 MiB
+ size_t nBlockTreeDBCache = nTotalCache / 8;
+ if (nBlockTreeDBCache > (1 << 21))
+ nBlockTreeDBCache = (1 << 21); // block tree db cache shouldn't be larger than 2 MiB
+ nTotalCache -= nBlockTreeDBCache;
+ size_t nCoinDBCache = nTotalCache / 2; // use half of the remaining cache for coindb cache
+ nTotalCache -= nCoinDBCache;
+ nCoinCacheSize = nTotalCache / 300; // coins in memory require around 300 bytes
+
uiInterface.InitMessage(_("Loading block index..."));
printf("Loading block index...\n");
nStart = GetTimeMillis();
- pblocktree = new CBlockTreeDB();
- pcoinsdbview = new CCoinsViewDB();
+ pblocktree = new CBlockTreeDB(nBlockTreeDBCache);
+ pcoinsdbview = new CCoinsViewDB(nCoinDBCache);
pcoinsTip = new CCoinsViewCache(*pcoinsdbview);
if (!LoadBlockIndex())