Cache size optimizations

This commit is contained in:
Pieter Wuille
2012-11-04 17:11:48 +01:00
parent a56d3f8a10
commit 1c83b0a377
7 changed files with 27 additions and 14 deletions

View File

@@ -12,22 +12,22 @@
#include <boost/filesystem.hpp>
static leveldb::Options GetOptions() {
static leveldb::Options GetOptions(size_t nCacheSize) {
leveldb::Options options;
int nCacheSizeMB = GetArg("-dbcache", 25);
options.block_cache = leveldb::NewLRUCache(nCacheSizeMB * 1048576);
options.block_cache = leveldb::NewLRUCache(nCacheSize / 2);
options.write_buffer_size = nCacheSize / 4; // up to two write buffers may be held in memory simultaneously
options.filter_policy = leveldb::NewBloomFilterPolicy(10);
options.compression = leveldb::kNoCompression;
return options;
}
CLevelDB::CLevelDB(const boost::filesystem::path &path, bool fMemory) {
CLevelDB::CLevelDB(const boost::filesystem::path &path, size_t nCacheSize, bool fMemory) {
penv = NULL;
readoptions.verify_checksums = true;
iteroptions.verify_checksums = true;
iteroptions.fill_cache = false;
syncoptions.sync = true;
options = GetOptions();
options = GetOptions(nCacheSize);
options.create_if_missing = true;
if (fMemory) {
penv = leveldb::NewMemEnv(leveldb::Env::Default());