mirror of
https://github.com/matrix-construct/construct
synced 2024-11-01 03:18:54 +01:00
ircd::db: Upgrade rocksdb::port verbose debug approach to if constexpr.
This commit is contained in:
parent
4ae50c97d1
commit
ef7065fe88
2 changed files with 145 additions and 110 deletions
|
@ -25,12 +25,12 @@
|
||||||
//#define RB_DEBUG_DB_SEEK_ROW
|
//#define RB_DEBUG_DB_SEEK_ROW
|
||||||
//#define IRCD_DB_DEBUG_PREFETCH
|
//#define IRCD_DB_DEBUG_PREFETCH
|
||||||
|
|
||||||
/// Uncomment or -D this #define to enable extensive log messages for the
|
/// Set this #define to 1 or 2 to enable extensive log messages for the
|
||||||
/// experimental db environment-port implementation. This is only useful
|
/// experimental db environment-port implementation. This is only useful
|
||||||
/// for developers working on the port impl and want to debug all locking
|
/// for developers working on the port impl and want to debug all locking
|
||||||
/// and unlocking etc.
|
/// and unlocking etc.
|
||||||
///
|
///
|
||||||
//#define RB_DEBUG_DB_PORT
|
#define RB_DEBUG_DB_PORT 0
|
||||||
|
|
||||||
#include <rocksdb/version.h>
|
#include <rocksdb/version.h>
|
||||||
#include <rocksdb/status.h>
|
#include <rocksdb/status.h>
|
||||||
|
|
131
ircd/db_port.cc
131
ircd/db_port.cc
|
@ -26,15 +26,18 @@ noexcept
|
||||||
{
|
{
|
||||||
memset(this, 0x0, sizeof(pthread_mutex_t));
|
memset(this, 0x0, sizeof(pthread_mutex_t));
|
||||||
|
|
||||||
#ifdef RB_DEBUG_DB_PORT_
|
if constexpr(RB_DEBUG_DB_PORT > 1)
|
||||||
|
{
|
||||||
if(unlikely(!ctx::current))
|
if(unlikely(!ctx::current))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
log::debug
|
log::debug
|
||||||
{
|
{
|
||||||
db::log, "mutex %lu %p CTOR", ctx::id(), this
|
db::log, "mutex %lu %p CTOR",
|
||||||
|
ctx::id(),
|
||||||
|
this
|
||||||
};
|
};
|
||||||
#endif
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rocksdb::port::Mutex::Mutex(bool adaptive)
|
rocksdb::port::Mutex::Mutex(bool adaptive)
|
||||||
|
@ -46,15 +49,18 @@ noexcept
|
||||||
rocksdb::port::Mutex::~Mutex()
|
rocksdb::port::Mutex::~Mutex()
|
||||||
noexcept
|
noexcept
|
||||||
{
|
{
|
||||||
#ifdef RB_DEBUG_DB_PORT_
|
if constexpr(RB_DEBUG_DB_PORT > 1)
|
||||||
|
{
|
||||||
if(unlikely(!ctx::current))
|
if(unlikely(!ctx::current))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
log::debug
|
log::debug
|
||||||
{
|
{
|
||||||
db::log, "mutex %lu %p DTOR", ctx::id(), this
|
db::log, "mutex %lu %p DTOR",
|
||||||
|
ctx::id(),
|
||||||
|
this
|
||||||
};
|
};
|
||||||
#endif
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -64,12 +70,13 @@ noexcept
|
||||||
if(unlikely(!ctx::current))
|
if(unlikely(!ctx::current))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
#ifdef RB_DEBUG_DB_PORT
|
if constexpr(RB_DEBUG_DB_PORT)
|
||||||
log::debug
|
log::debug
|
||||||
{
|
{
|
||||||
db::log, "mutex %lu %p LOCK", ctx::id(), this
|
db::log, "mutex %lu %p LOCK",
|
||||||
|
ctx::id(),
|
||||||
|
this
|
||||||
};
|
};
|
||||||
#endif
|
|
||||||
|
|
||||||
assert_main_thread();
|
assert_main_thread();
|
||||||
const ctx::uninterruptible::nothrow ui;
|
const ctx::uninterruptible::nothrow ui;
|
||||||
|
@ -83,12 +90,13 @@ noexcept
|
||||||
if(unlikely(!ctx::current))
|
if(unlikely(!ctx::current))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
#ifdef RB_DEBUG_DB_PORT
|
if constexpr(RB_DEBUG_DB_PORT)
|
||||||
log::debug
|
log::debug
|
||||||
{
|
{
|
||||||
db::log, "mutex %lu %p UNLOCK", ctx::id(), this
|
db::log, "mutex %lu %p UNLOCK",
|
||||||
|
ctx::id(),
|
||||||
|
this
|
||||||
};
|
};
|
||||||
#endif
|
|
||||||
|
|
||||||
assert_main_thread();
|
assert_main_thread();
|
||||||
assert(mu.locked());
|
assert(mu.locked());
|
||||||
|
@ -119,29 +127,35 @@ noexcept
|
||||||
{
|
{
|
||||||
memset(this, 0x0, sizeof(pthread_rwlock_t));
|
memset(this, 0x0, sizeof(pthread_rwlock_t));
|
||||||
|
|
||||||
#ifdef RB_DEBUG_DB_PORT_
|
if constexpr(RB_DEBUG_DB_PORT > 1)
|
||||||
|
{
|
||||||
if(unlikely(!ctx::current))
|
if(unlikely(!ctx::current))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
log::debug
|
log::debug
|
||||||
{
|
{
|
||||||
db::log, "shared_mutex %lu %p CTOR", ctx::id(), this
|
db::log, "shared_mutex %lu %p CTOR",
|
||||||
|
ctx::id(),
|
||||||
|
this
|
||||||
};
|
};
|
||||||
#endif
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rocksdb::port::RWMutex::~RWMutex()
|
rocksdb::port::RWMutex::~RWMutex()
|
||||||
noexcept
|
noexcept
|
||||||
{
|
{
|
||||||
#ifdef RB_DEBUG_DB_PORT_
|
if constexpr(RB_DEBUG_DB_PORT > 1)
|
||||||
|
{
|
||||||
if(unlikely(!ctx::current))
|
if(unlikely(!ctx::current))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
log::debug
|
log::debug
|
||||||
{
|
{
|
||||||
db::log, "shared_mutex %lu %p DTOR", ctx::id(), this
|
db::log, "shared_mutex %lu %p DTOR",
|
||||||
|
ctx::id(),
|
||||||
|
this
|
||||||
};
|
};
|
||||||
#endif
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -151,12 +165,13 @@ noexcept
|
||||||
if(unlikely(!ctx::current))
|
if(unlikely(!ctx::current))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
#ifdef RB_DEBUG_DB_PORT
|
if constexpr(RB_DEBUG_DB_PORT)
|
||||||
log::debug
|
log::debug
|
||||||
{
|
{
|
||||||
db::log, "shared_mutex %lu %p LOCK SHARED", ctx::id(), this
|
db::log, "shared_mutex %lu %p LOCK SHARED",
|
||||||
|
ctx::id(),
|
||||||
|
this
|
||||||
};
|
};
|
||||||
#endif
|
|
||||||
|
|
||||||
assert_main_thread();
|
assert_main_thread();
|
||||||
const ctx::uninterruptible::nothrow ui;
|
const ctx::uninterruptible::nothrow ui;
|
||||||
|
@ -170,12 +185,13 @@ noexcept
|
||||||
if(unlikely(!ctx::current))
|
if(unlikely(!ctx::current))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
#ifdef RB_DEBUG_DB_PORT
|
if constexpr(RB_DEBUG_DB_PORT)
|
||||||
log::debug
|
log::debug
|
||||||
{
|
{
|
||||||
db::log, "shared_mutex %lu %p LOCK", ctx::id(), this
|
db::log, "shared_mutex %lu %p LOCK",
|
||||||
|
ctx::id(),
|
||||||
|
this
|
||||||
};
|
};
|
||||||
#endif
|
|
||||||
|
|
||||||
assert_main_thread();
|
assert_main_thread();
|
||||||
const ctx::uninterruptible::nothrow ui;
|
const ctx::uninterruptible::nothrow ui;
|
||||||
|
@ -189,12 +205,13 @@ noexcept
|
||||||
if(unlikely(!ctx::current))
|
if(unlikely(!ctx::current))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
#ifdef RB_DEBUG_DB_PORT
|
if constexpr(RB_DEBUG_DB_PORT)
|
||||||
log::debug
|
log::debug
|
||||||
{
|
{
|
||||||
db::log, "shared_mutex %lu %p UNLOCK SHARED", ctx::id(), this
|
db::log, "shared_mutex %lu %p UNLOCK SHARED",
|
||||||
|
ctx::id(),
|
||||||
|
this
|
||||||
};
|
};
|
||||||
#endif
|
|
||||||
|
|
||||||
assert_main_thread();
|
assert_main_thread();
|
||||||
const ctx::uninterruptible::nothrow ui;
|
const ctx::uninterruptible::nothrow ui;
|
||||||
|
@ -208,12 +225,13 @@ noexcept
|
||||||
if(unlikely(!ctx::current))
|
if(unlikely(!ctx::current))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
#ifdef RB_DEBUG_DB_PORT
|
if constexpr(RB_DEBUG_DB_PORT)
|
||||||
log::debug
|
log::debug
|
||||||
{
|
{
|
||||||
db::log, "shared_mutex %lu %p UNLOCK", ctx::id(), this
|
db::log, "shared_mutex %lu %p UNLOCK",
|
||||||
|
ctx::id(),
|
||||||
|
this
|
||||||
};
|
};
|
||||||
#endif
|
|
||||||
|
|
||||||
assert_main_thread();
|
assert_main_thread();
|
||||||
const ctx::uninterruptible::nothrow ui;
|
const ctx::uninterruptible::nothrow ui;
|
||||||
|
@ -237,29 +255,37 @@ noexcept
|
||||||
memset(this, 0x0, sizeof(pthread_cond_t) + sizeof(Mutex *));
|
memset(this, 0x0, sizeof(pthread_cond_t) + sizeof(Mutex *));
|
||||||
this->mu = mu;
|
this->mu = mu;
|
||||||
|
|
||||||
#ifdef RB_DEBUG_DB_PORT_
|
if constexpr(RB_DEBUG_DB_PORT > 1)
|
||||||
|
{
|
||||||
if(unlikely(!ctx::current))
|
if(unlikely(!ctx::current))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
log::debug
|
log::debug
|
||||||
{
|
{
|
||||||
db::log, "cond %lu %p %p CTOR", ctx::id(), this, mu
|
db::log, "cond %lu %p %p CTOR",
|
||||||
|
ctx::id(),
|
||||||
|
this,
|
||||||
|
mu
|
||||||
};
|
};
|
||||||
#endif
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rocksdb::port::CondVar::~CondVar()
|
rocksdb::port::CondVar::~CondVar()
|
||||||
noexcept
|
noexcept
|
||||||
{
|
{
|
||||||
#ifdef RB_DEBUG_DB_PORT_
|
if constexpr(RB_DEBUG_DB_PORT > 1)
|
||||||
|
{
|
||||||
if(unlikely(!ctx::current))
|
if(unlikely(!ctx::current))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
log::debug
|
log::debug
|
||||||
{
|
{
|
||||||
db::log, "cond %lu %p %p DTOR", ctx::id(), this, mu
|
db::log, "cond %lu %p %p DTOR",
|
||||||
|
ctx::id(),
|
||||||
|
this,
|
||||||
|
mu
|
||||||
};
|
};
|
||||||
#endif
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -268,12 +294,14 @@ noexcept
|
||||||
{
|
{
|
||||||
assert(ctx::current);
|
assert(ctx::current);
|
||||||
|
|
||||||
#ifdef RB_DEBUG_DB_PORT
|
if constexpr(RB_DEBUG_DB_PORT)
|
||||||
log::debug
|
log::debug
|
||||||
{
|
{
|
||||||
db::log, "cond %lu %p %p WAIT", ctx::id(), this, mu
|
db::log, "cond %lu %p %p WAIT",
|
||||||
|
ctx::id(),
|
||||||
|
this,
|
||||||
|
mu
|
||||||
};
|
};
|
||||||
#endif
|
|
||||||
|
|
||||||
assert(mu);
|
assert(mu);
|
||||||
assert_main_thread();
|
assert_main_thread();
|
||||||
|
@ -289,12 +317,15 @@ noexcept
|
||||||
{
|
{
|
||||||
assert(ctx::current);
|
assert(ctx::current);
|
||||||
|
|
||||||
#ifdef RB_DEBUG_DB_PORT
|
if constexpr(RB_DEBUG_DB_PORT)
|
||||||
log::debug
|
log::debug
|
||||||
{
|
{
|
||||||
db::log, "cond %lu %p %p WAIT_UNTIL %lu", ctx::id(), this, mu, abs_time_us
|
db::log, "cond %lu %p %p WAIT_UNTIL %lu",
|
||||||
|
ctx::id(),
|
||||||
|
this,
|
||||||
|
mu,
|
||||||
|
abs_time_us
|
||||||
};
|
};
|
||||||
#endif
|
|
||||||
|
|
||||||
assert(mu);
|
assert(mu);
|
||||||
assert_main_thread();
|
assert_main_thread();
|
||||||
|
@ -309,12 +340,14 @@ void
|
||||||
rocksdb::port::CondVar::Signal()
|
rocksdb::port::CondVar::Signal()
|
||||||
noexcept
|
noexcept
|
||||||
{
|
{
|
||||||
#ifdef RB_DEBUG_DB_PORT
|
if constexpr(RB_DEBUG_DB_PORT)
|
||||||
log::debug
|
log::debug
|
||||||
{
|
{
|
||||||
db::log, "cond %lu %p %p NOTIFY", ctx::id(), this, mu
|
db::log, "cond %lu %p %p NOTIFY",
|
||||||
|
ctx::id(),
|
||||||
|
this,
|
||||||
|
mu
|
||||||
};
|
};
|
||||||
#endif
|
|
||||||
|
|
||||||
assert_main_thread();
|
assert_main_thread();
|
||||||
cv.notify_one();
|
cv.notify_one();
|
||||||
|
@ -324,12 +357,14 @@ void
|
||||||
rocksdb::port::CondVar::SignalAll()
|
rocksdb::port::CondVar::SignalAll()
|
||||||
noexcept
|
noexcept
|
||||||
{
|
{
|
||||||
#ifdef RB_DEBUG_DB_PORT
|
if constexpr(RB_DEBUG_DB_PORT)
|
||||||
log::debug
|
log::debug
|
||||||
{
|
{
|
||||||
db::log, "cond %lu %p %p BROADCAST", ctx::id(), this, mu
|
db::log, "cond %lu %p %p BROADCAST",
|
||||||
|
ctx::id(),
|
||||||
|
this,
|
||||||
|
mu
|
||||||
};
|
};
|
||||||
#endif
|
|
||||||
|
|
||||||
assert_main_thread();
|
assert_main_thread();
|
||||||
cv.notify_all();
|
cv.notify_all();
|
||||||
|
|
Loading…
Reference in a new issue