diff options
author | Xiangyu Yao <xiangyu.yao@mongodb.com> | 2017-10-18 19:00:45 -0400 |
---|---|---|
committer | Xiangyu Yao <xiangyu.yao@mongodb.com> | 2017-11-10 10:33:48 -0500 |
commit | eaf6c96f4893946cd62d6565d3aab92901b92ad8 (patch) | |
tree | af6ba5bffb629c819284a7163b0a5af5af36d9d3 /src/mongo | |
parent | 69ab9781d7a646a6029e5c46d340685e80e404fa (diff) | |
download | mongo-eaf6c96f4893946cd62d6565d3aab92901b92ad8.tar.gz |
SERVER-29465 Add warning about Windows SystemFileCacheSize for WiredTiger
Diffstat (limited to 'src/mongo')
-rw-r--r-- | src/mongo/db/startup_warnings_mongod.cpp | 17 | ||||
-rw-r--r-- | src/mongo/util/processinfo.h | 6 | ||||
-rw-r--r-- | src/mongo/util/processinfo_freebsd.cpp | 4 | ||||
-rw-r--r-- | src/mongo/util/processinfo_linux.cpp | 4 | ||||
-rw-r--r-- | src/mongo/util/processinfo_openbsd.cpp | 4 | ||||
-rw-r--r-- | src/mongo/util/processinfo_osx.cpp | 4 | ||||
-rw-r--r-- | src/mongo/util/processinfo_solaris.cpp | 4 | ||||
-rw-r--r-- | src/mongo/util/processinfo_unknown.cpp | 4 | ||||
-rw-r--r-- | src/mongo/util/processinfo_windows.cpp | 33 |
9 files changed, 80 insertions, 0 deletions
diff --git a/src/mongo/db/startup_warnings_mongod.cpp b/src/mongo/db/startup_warnings_mongod.cpp index a15bf056428..6f0c42263f3 100644 --- a/src/mongo/db/startup_warnings_mongod.cpp +++ b/src/mongo/db/startup_warnings_mongod.cpp @@ -369,6 +369,23 @@ void logMongodStartupWarnings(const StorageGlobalParams& storageParams, warned = true; } + if (storageParams.engine == "wiredTiger") { + // If the filesystemMaxCacheSize / totalMemorySize > 0.4, we should raise this + // warning because it leads to terrible performance for WiredTiger + const double filesystemCachePercentageThreshold = 0.4; + if (p.getMaxSystemFileCachePercentage() > filesystemCachePercentageThreshold) { + log() << startupWarningsLog; + log() + << "** WARNING: The file system cache of this machine is configured to be greater " + << "than " << 100 * filesystemCachePercentageThreshold << "% of the total memory. " + << "This can lead to increased memory pressure and poor performance." + << startupWarningsLog; + log() << "See http://dochub.mongodb.org/core/wt-windows-system-file-cache" + << startupWarningsLog; + warned = true; + } + } + #endif // #ifdef _WIN32 if (storageParams.engine == "ephemeralForTest") { diff --git a/src/mongo/util/processinfo.h b/src/mongo/util/processinfo.h index f44ef37799a..0a2d2cc1d22 100644 --- a/src/mongo/util/processinfo.h +++ b/src/mongo/util/processinfo.h @@ -157,6 +157,12 @@ public: static bool blockInMemory(const void* start); /** + * Returns a positive floating point number between 0.0 and 1.0 that + * reflects the maximum percentage of RAM the filesystem cache is allowed to grow. + */ + static double getMaxSystemFileCachePercentage(); + + /** * Returns a positive floating point number between 0.0 and 1.0 to inform MMapV1 how much it * must remap pages to bring the system page file implementation back below a certain * threshold. A number of 1.0 means remap everything. diff --git a/src/mongo/util/processinfo_freebsd.cpp b/src/mongo/util/processinfo_freebsd.cpp index d9bf1aa72fd..ce07c514753 100644 --- a/src/mongo/util/processinfo_freebsd.cpp +++ b/src/mongo/util/processinfo_freebsd.cpp @@ -120,6 +120,10 @@ int ProcessInfo::getResidentSize() { return rss; } +double ProcessInfo::getMaxSystemFileCachePercentage() { + return 0.0; +} + double ProcessInfo::getSystemMemoryPressurePercentage() { return 0.0; } diff --git a/src/mongo/util/processinfo_linux.cpp b/src/mongo/util/processinfo_linux.cpp index c2813b026b0..a3310e64e95 100644 --- a/src/mongo/util/processinfo_linux.cpp +++ b/src/mongo/util/processinfo_linux.cpp @@ -451,6 +451,10 @@ int ProcessInfo::getResidentSize() { return (int)((p.getResidentSizeInPages() * getPageSize()) / (1024.0 * 1024)); } +double ProcessInfo::getMaxSystemFileCachePercentage() { + return 0.0; +} + double ProcessInfo::getSystemMemoryPressurePercentage() { return 0.0; } diff --git a/src/mongo/util/processinfo_openbsd.cpp b/src/mongo/util/processinfo_openbsd.cpp index dc3e43d8636..a4c1d0f9ab2 100644 --- a/src/mongo/util/processinfo_openbsd.cpp +++ b/src/mongo/util/processinfo_openbsd.cpp @@ -130,6 +130,10 @@ int ProcessInfo::getResidentSize() { return rss; } +double ProcessInfo::getMaxSystemFileCachePercentage() { + return 0.0; +} + double ProcessInfo::getSystemMemoryPressurePercentage() { return 0.0; } diff --git a/src/mongo/util/processinfo_osx.cpp b/src/mongo/util/processinfo_osx.cpp index c82aa3f9411..475016de313 100644 --- a/src/mongo/util/processinfo_osx.cpp +++ b/src/mongo/util/processinfo_osx.cpp @@ -118,6 +118,10 @@ int ProcessInfo::getResidentSize() { return (int)(ti.resident_size / (1024 * 1024)); } +double ProcessInfo::getMaxSystemFileCachePercentage() { + return 0.0; +} + double ProcessInfo::getSystemMemoryPressurePercentage() { return 0.0; } diff --git a/src/mongo/util/processinfo_solaris.cpp b/src/mongo/util/processinfo_solaris.cpp index c8a7110e738..3bd892de4e8 100644 --- a/src/mongo/util/processinfo_solaris.cpp +++ b/src/mongo/util/processinfo_solaris.cpp @@ -127,6 +127,10 @@ int ProcessInfo::getResidentSize() { return static_cast<int>(p.psinfo.pr_rssize / 1024); } +double ProcessInfo::getMaxSystemFileCachePercentage() { + return 0.0; +} + double ProcessInfo::getSystemMemoryPressurePercentage() { return 0.0; } diff --git a/src/mongo/util/processinfo_unknown.cpp b/src/mongo/util/processinfo_unknown.cpp index 8984012b13c..a8960e27de0 100644 --- a/src/mongo/util/processinfo_unknown.cpp +++ b/src/mongo/util/processinfo_unknown.cpp @@ -53,6 +53,10 @@ int ProcessInfo::getResidentSize() { return -1; } +double ProcessInfo::getMaxSystemFileCachePercentage() { + return 0.0; +} + double ProcessInfo::getSystemMemoryPressurePercentage() { return 0.0; } diff --git a/src/mongo/util/processinfo_windows.cpp b/src/mongo/util/processinfo_windows.cpp index 06c81b2e0f8..676204c9856 100644 --- a/src/mongo/util/processinfo_windows.cpp +++ b/src/mongo/util/processinfo_windows.cpp @@ -119,6 +119,39 @@ int ProcessInfo::getResidentSize() { return _wconvertmtos(pmc.WorkingSetSize); } +double ProcessInfo::getMaxSystemFileCachePercentage() { + SIZE_T minCacheSize = 0; + SIZE_T maxCacheSize = 0; + DWORD flags = 0; + BOOL status = GetSystemFileCacheSize(&minCacheSize, &maxCacheSize, &flags); + if (!status) { + DWORD gle = GetLastError(); + severe() << "GetSystemFileCacheSize failed with " << errnoWithDescription(gle); + fassertFailed(40667); + } + + if (!(flags & FILE_CACHE_MAX_HARD_ENABLE)) { + return 1.0; + } + + MEMORYSTATUSEX mse; + mse.dwLength = sizeof(mse); + status = GlobalMemoryStatusEx(&mse); + if (!status) { + DWORD gle = GetLastError(); + severe() << "GlobalMemoryStatusEx failed with " << errnoWithDescription(gle); + fassertFailed(40668); + } + + DWORDLONG totalMemorySize = mse.ullTotalPhys; + if (totalMemorySize == 0) { + severe() << "Total memory is 0"; + fassertFailed(40669); + } + + return static_cast<double>(maxCacheSize) / totalMemorySize; +} + double ProcessInfo::getSystemMemoryPressurePercentage() { MEMORYSTATUSEX mse; mse.dwLength = sizeof(mse); |