summaryrefslogtreecommitdiff
path: root/src/mongo/db/stats
diff options
context:
space:
mode:
authorMathias Stearn <mathias@10gen.com>2015-10-01 17:32:25 -0400
committerMathias Stearn <mathias@10gen.com>2015-10-08 12:06:52 -0400
commit804ad14001e1a58538974a327e9943c338fd0925 (patch)
treeba34ab7034b61ab256e520af64441a854e23d270 /src/mongo/db/stats
parentd6f74cfcbcaddff79b09de1fc8b07d30236d7972 (diff)
downloadmongo-804ad14001e1a58538974a327e9943c338fd0925.tar.gz
SERVER-20668 Support prehashing StringMap keys
This allows computing the hash outside of a mutex guarding the StringMap. This commit applies this optimization in Top::record().
Diffstat (limited to 'src/mongo/db/stats')
-rw-r--r--src/mongo/db/stats/top.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/mongo/db/stats/top.cpp b/src/mongo/db/stats/top.cpp
index f4f66d42a05..5b06b7b3c0d 100644
--- a/src/mongo/db/stats/top.cpp
+++ b/src/mongo/db/stats/top.cpp
@@ -77,6 +77,8 @@ void Top::record(StringData ns, int op, int lockType, long long micros, bool com
if (ns[0] == '?')
return;
+ auto hashedNs = UsageMap::HashedKey(ns);
+
// cout << "record: " << ns << "\t" << op << "\t" << command << endl;
stdx::lock_guard<SimpleMutex> lk(_lock);
@@ -85,7 +87,7 @@ void Top::record(StringData ns, int op, int lockType, long long micros, bool com
return;
}
- CollectionData& coll = _usage[ns];
+ CollectionData& coll = _usage[hashedNs];
_record(coll, op, lockType, micros, command);
}