diff options
author | Dan Pasette <dan@mongodb.com> | 2016-03-29 14:14:21 -0400 |
---|---|---|
committer | Dan Pasette <dan@mongodb.com> | 2016-04-08 16:56:12 -0400 |
commit | 5ee7b56b5b625dc62ef80ce4f5742ab837097567 (patch) | |
tree | 7ee50759cadc7fd85746c0086695a580560cd132 /src/mongo | |
parent | 8574968bae67abc3c67822d681de550136dfb526 (diff) | |
download | mongo-5ee7b56b5b625dc62ef80ce4f5742ab837097567.tar.gz |
SERVER-23391 Lower WiredTiger cache size floor
Diffstat (limited to 'src/mongo')
-rw-r--r-- | src/mongo/db/storage/wiredtiger/wiredtiger_init.cpp | 13 | ||||
-rw-r--r-- | src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp | 4 |
2 files changed, 10 insertions, 7 deletions
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_init.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_init.cpp index 5ccc1093549..fffbf9c3fc9 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_init.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_init.cpp @@ -62,24 +62,27 @@ public: } size_t cacheSizeGB = wiredTigerGlobalOptions.cacheSizeGB; + size_t cacheSizeMB = 256; // minimum cache size if (cacheSizeGB == 0) { // Since the user didn't provide a cache size, choose a reasonable default value. // We want to reserve 1GB for the system and binaries, but it's not bad to // leave a fair amount left over for pagecache since that's compressed storage. + // If ProcessInfo indicates that there is < 2GB of memory, allocate 256M for cache. + // If ProcessInfo indicates exactly 2GB, allocate 614MB ProcessInfo pi; double memSizeMB = pi.getMemSizeMB(); - if (memSizeMB > 0) { + if (memSizeMB >= 1024 * 2) { double cacheMB = (memSizeMB - 1024) * 0.6; - cacheSizeGB = static_cast<size_t>(cacheMB / 1024); - if (cacheSizeGB < 1) - cacheSizeGB = 1; + cacheSizeMB = static_cast<size_t>(cacheMB); } + } else { + cacheSizeMB = 1024 * cacheSizeGB; } const bool ephemeral = false; WiredTigerKVEngine* kv = new WiredTigerKVEngine(getCanonicalName().toString(), params.dbpath, wiredTigerGlobalOptions.engineConfig, - cacheSizeGB, + cacheSizeMB, params.dur, ephemeral, params.repair, diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp index 51749294c3d..d8547c421f9 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp @@ -171,7 +171,7 @@ TicketServerParameter openReadTransactionParam(&openReadTransaction, WiredTigerKVEngine::WiredTigerKVEngine(const std::string& canonicalName, const std::string& path, const std::string& extraOpenOptions, - size_t cacheSizeGB, + size_t cacheSizeMB, bool durable, bool ephemeral, bool repair, @@ -200,7 +200,7 @@ WiredTigerKVEngine::WiredTigerKVEngine(const std::string& canonicalName, std::stringstream ss; ss << "create,"; - ss << "cache_size=" << cacheSizeGB << "G,"; + ss << "cache_size=" << cacheSizeMB << "M,"; ss << "session_max=20000,"; ss << "eviction=(threads_max=4),"; ss << "config_base=false,"; |