summaryrefslogtreecommitdiff
path: root/util/version.cpp
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2011-04-20 11:58:43 -0400
committerEliot Horowitz <eliot@10gen.com>2011-04-20 11:58:43 -0400
commit2e3f27c3f9654205ecbea2ce28367c138b7282d0 (patch)
treef38eea051cf66b00a9806adf8da91b5b139445ee /util/version.cpp
parentdff2c6b66e29f2d7b91fe5994d07532adca38135 (diff)
downloadmongo-2e3f27c3f9654205ecbea2ce28367c138b7282d0.tar.gz
Print warning when running on NUMA box w/o running numactl --interleave
Conflicts: util/version.cpp
Diffstat (limited to 'util/version.cpp')
-rw-r--r--util/version.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/util/version.cpp b/util/version.cpp
index 91998403acb..6153b4fa6e6 100644
--- a/util/version.cpp
+++ b/util/version.cpp
@@ -23,6 +23,7 @@
#include <string>
#include "unittest.h"
#include "version.h"
+#include "file.h"
namespace mongo {
@@ -94,6 +95,39 @@ namespace mongo {
cout << "** WARNING: You are running in OpenVZ. This is known to be broken!!!" << endl;
warned = true;
}
+
+ if (boost::filesystem::exists("/sys/devices/system/node/node1")){
+ // We are on a box with a NUMA enabled kernel and more than 1 numa node (they start at node0)
+ // Now we look at the first line of /proc/self/numa_maps
+ //
+ // Bad example:
+ // $ cat /proc/self/numa_maps
+ // 00400000 default file=/bin/cat mapped=6 N4=6
+ //
+ // Good example:
+ // $ numactl --interleave=all cat /proc/self/numa_maps
+ // 00400000 interleave:0-7 file=/bin/cat mapped=6 N4=6
+
+ File f;
+ f.open("/proc/self/numa_maps", /*read_only*/true);
+ char line[100]; //we only need the first line
+ f.read(0, line, sizeof(line));
+
+ // just in case...
+ line[98] = ' ';
+ line[99] = '\0';
+
+ // skip over pointer
+ const char* space = strchr(line, ' ');
+
+ if (!startsWith(space+1, "interleave")){
+ cout << endl;
+ cout << "** WARNING: You are running in on a NUMA machine." << endl;
+ cout << "** We suggest launching mongod like this to avoid performance problems:" << endl;
+ cout << "** numactl --interleave=all mongod [other options]" << endl;
+ warned = true;
+ }
+ }
#endif
if (warned)