mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
[RocksDB] Introduce Fast Mutex option
Summary: This diff adds an option to specify whether PTHREAD_MUTEX_ADAPTIVE_NP will be enabled for the rocksdb single big kernel lock. db_bench also have this option now. Quickly tested 8 thread cpu bound 100 byte random read. No fast mutex: ~750k/s ops With fast mutex: ~880k/s ops Test Plan: make check; db_bench; db_stress Reviewers: dhruba CC: MarkCallaghan, leveldb Differential Revision: https://reviews.facebook.net/D11031
This commit is contained in:
@@ -19,7 +19,24 @@ static void PthreadCall(const char* label, int result) {
|
||||
}
|
||||
}
|
||||
|
||||
Mutex::Mutex() { PthreadCall("init mutex", pthread_mutex_init(&mu_, NULL)); }
|
||||
Mutex::Mutex(bool adaptive) {
|
||||
#ifdef OS_LINUX
|
||||
if (!adaptive) {
|
||||
PthreadCall("init mutex", pthread_mutex_init(&mu_, NULL));
|
||||
} else {
|
||||
pthread_mutexattr_t mutex_attr;
|
||||
PthreadCall("init mutex attr", pthread_mutexattr_init(&mutex_attr));
|
||||
PthreadCall("set mutex attr",
|
||||
pthread_mutexattr_settype(&mutex_attr,
|
||||
PTHREAD_MUTEX_ADAPTIVE_NP));
|
||||
PthreadCall("init mutex", pthread_mutex_init(&mu_, &mutex_attr));
|
||||
PthreadCall("destroy mutex attr",
|
||||
pthread_mutexattr_destroy(&mutex_attr));
|
||||
}
|
||||
#else // ignore adaptive for non-linux platform
|
||||
PthreadCall("init mutex", pthread_mutex_init(&mu_, NULL));
|
||||
#endif // OS_LINUX
|
||||
}
|
||||
|
||||
Mutex::~Mutex() { PthreadCall("destroy mutex", pthread_mutex_destroy(&mu_)); }
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ class CondVar;
|
||||
|
||||
class Mutex {
|
||||
public:
|
||||
Mutex();
|
||||
Mutex(bool adaptive = false);
|
||||
~Mutex();
|
||||
|
||||
void Lock();
|
||||
|
||||
Reference in New Issue
Block a user