diff options
author | dwight <dwight@10gen.com> | 2010-10-07 00:56:12 -0400 |
---|---|---|
committer | dwight <dwight@10gen.com> | 2010-10-07 00:56:12 -0400 |
commit | 2c8ce154171648faee3b225033a953f03cda60a4 (patch) | |
tree | f7b43d3952bdac68ea50ecf78b8bc85c2e99901f | |
parent | 3c50843ca7b34b48adcbfeaa6533835639f2245d (diff) | |
download | mongo-2c8ce154171648faee3b225033a953f03cda60a4.tar.gz |
put hotter things adjacent for cache friendliness
-rw-r--r-- | db/common.cpp | 11 | ||||
-rw-r--r-- | db/concurrency.h | 11 | ||||
-rw-r--r-- | db/mongomutex.h | 5 | ||||
-rw-r--r-- | util/goodies.h | 2 |
4 files changed, 19 insertions, 10 deletions
diff --git a/db/common.cpp b/db/common.cpp index b7883f5e425..e711df9bfdc 100644 --- a/db/common.cpp +++ b/db/common.cpp @@ -26,4 +26,15 @@ namespace mongo { /* we use new here so we don't have to worry about destructor orders at program shutdown */ MongoMutex &dbMutex( *(new MongoMutex("rw:dbMutex")) ); + MongoMutex::MongoMutex(const char *name) : _m(name) { + static int n; + assert( ++n == 1 ); // singleton class + + /*cout << sizeof(*this) << endl; + cout << sizeof(MutexInfo) << endl; + cout << sizeof(RWLock) << endl; + cout << sizeof(ThreadLocalValue<int>) << endl; + _state.get();*/ + } + } diff --git a/db/concurrency.h b/db/concurrency.h index c74fd7d01e2..b0f2c508fb3 100644 --- a/db/concurrency.h +++ b/db/concurrency.h @@ -43,8 +43,9 @@ namespace mongo { /* mutex time stats */ class MutexInfo { - unsigned long long start, enter, timeLocked; // all in microseconds + unsigned long long enter, timeLocked; // microseconds int locked; + unsigned long long start; // last as we touch this least often public: MutexInfo() : timeLocked(0) , locked(0) { @@ -62,16 +63,12 @@ namespace mongo { if ( locked == 0 ) timeLocked += curTimeMicros64() - enter; } - int isLocked() const { - return locked; - } + int isLocked() const { return locked; } void getTimingInfo(unsigned long long &s, unsigned long long &tl) const { s = start; tl = timeLocked; } - unsigned long long getTimeLocked() const { - return timeLocked; - } + unsigned long long getTimeLocked() const { return timeLocked; } }; } diff --git a/db/mongomutex.h b/db/mongomutex.h index ca8fd128c61..f2493909ca7 100644 --- a/db/mongomutex.h +++ b/db/mongomutex.h @@ -22,7 +22,7 @@ namespace mongo { class MongoMutex { public: - MongoMutex(const char * name) : _m(name) { } + MongoMutex(const char * name); /** @return * > 0 write lock @@ -172,7 +172,6 @@ namespace mongo { MutexInfo& info() { return _minfo; } private: - MutexInfo _minfo; RWLock _m; /* > 0 write lock with recurse count @@ -180,6 +179,8 @@ namespace mongo { */ ThreadLocalValue<int> _state; + MutexInfo _minfo; + /* See the releaseEarly() method. we use a separate TLS value for releasedEarly - that is ok as our normal/common code path, we never even touch it */ diff --git a/util/goodies.h b/util/goodies.h index 0f995aec5f2..aeffd14b976 100644 --- a/util/goodies.h +++ b/util/goodies.h @@ -218,8 +218,8 @@ namespace mongo { } private: - const T _default; boost::thread_specific_ptr<T> _val; + const T _default; }; class ProgressMeter : boost::noncopyable { |