0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-10-31 19:08:59 +01:00

ircd::db: Upgrade rocksdb::port verbose debug approach to if constexpr.

This commit is contained in:
Jason Volk 2022-06-14 15:16:57 -07:00
parent 4ae50c97d1
commit ef7065fe88
2 changed files with 145 additions and 110 deletions

View file

@ -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>

View file

@ -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))
return;
log::debug
{ {
db::log, "mutex %lu %p CTOR", ctx::id(), this if(unlikely(!ctx::current))
}; return;
#endif
log::debug
{
db::log, "mutex %lu %p CTOR",
ctx::id(),
this
};
}
} }
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))
return;
log::debug
{ {
db::log, "mutex %lu %p DTOR", ctx::id(), this if(unlikely(!ctx::current))
}; return;
#endif
log::debug
{
db::log, "mutex %lu %p DTOR",
ctx::id(),
this
};
}
} }
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(),
#endif this
};
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(),
#endif this
};
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))
return;
log::debug
{ {
db::log, "shared_mutex %lu %p CTOR", ctx::id(), this if(unlikely(!ctx::current))
}; return;
#endif
log::debug
{
db::log, "shared_mutex %lu %p CTOR",
ctx::id(),
this
};
}
} }
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))
return;
log::debug
{ {
db::log, "shared_mutex %lu %p DTOR", ctx::id(), this if(unlikely(!ctx::current))
}; return;
#endif
log::debug
{
db::log, "shared_mutex %lu %p DTOR",
ctx::id(),
this
};
}
} }
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(),
#endif this
};
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(),
#endif this
};
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(),
#endif this
};
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(),
#endif this
};
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))
return;
log::debug
{ {
db::log, "cond %lu %p %p CTOR", ctx::id(), this, mu if(unlikely(!ctx::current))
}; return;
#endif
log::debug
{
db::log, "cond %lu %p %p CTOR",
ctx::id(),
this,
mu
};
}
} }
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))
return;
log::debug
{ {
db::log, "cond %lu %p %p DTOR", ctx::id(), this, mu if(unlikely(!ctx::current))
}; return;
#endif
log::debug
{
db::log, "cond %lu %p %p DTOR",
ctx::id(),
this,
mu
};
}
} }
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(),
#endif this,
mu
};
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(),
#endif this,
mu,
abs_time_us
};
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(),
#endif this,
mu
};
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(),
#endif this,
mu
};
assert_main_thread(); assert_main_thread();
cv.notify_all(); cv.notify_all();