diff options
author | Pieter Wuille <pieter.wuille@gmail.com> | 2012-11-08 14:17:37 -0800 |
---|---|---|
committer | Pieter Wuille <pieter.wuille@gmail.com> | 2012-11-08 14:17:37 -0800 |
commit | 16d9d61f99c2e081585e6634d25da3523804eabf (patch) | |
tree | 5037a2b474e9f6b55630d9ccee68478e619421a5 /src/init.cpp | |
parent | 86406daeca0390b13457cc4f8d5f24fa5bf54557 (diff) | |
parent | 1c83b0a3771bc601fdc75588f2cd45318b19c526 (diff) |
Merge pull request #1981 from sipa/caches
Cache size optimizations
Diffstat (limited to 'src/init.cpp')
-rw-r--r-- | src/init.cpp | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/init.cpp b/src/init.cpp index db5ae5a756..8151fb2a86 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()) |