0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-05-19 19:33:45 +02:00

ircd::db: Move allocator log debug to separate define; use constexpr.

This commit is contained in:
Jason Volk 2022-07-11 14:47:34 -07:00
parent 5e3ae3771d
commit 305c6e8075
2 changed files with 112 additions and 120 deletions

View file

@ -26,6 +26,7 @@
#define RB_DEBUG_DB_PREFETCH 0 #define RB_DEBUG_DB_PREFETCH 0
#define RB_DEBUG_DB_CACHE 0 #define RB_DEBUG_DB_CACHE 0
#define RB_DEBUG_DB_CACHE_HIT 0 #define RB_DEBUG_DB_CACHE_HIT 0
#define RB_DEBUG_DB_ALLOCATOR 0
/// Set this #define to 1 or 2 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

View file

@ -142,21 +142,20 @@ noexcept
assert(their_cache_arena_hooks); assert(their_cache_arena_hooks);
const auto &their_hooks(*their_cache_arena_hooks); const auto &their_hooks(*their_cache_arena_hooks);
#ifdef RB_DEBUG_DB_ENV
assert(zero); assert(zero);
assert(commit); assert(commit);
log::debug if constexpr(RB_DEBUG_DB_ALLOCATOR)
{ log::debug
log, "cache arena:%u alloc addr:%p size:%zu align:%zu z:%b c:%b ind:%u", {
database::allocator::cache_arena, log, "cache arena:%u alloc addr:%p size:%zu align:%zu z:%b c:%b ind:%u",
new_addr, database::allocator::cache_arena,
size, new_addr,
alignment, size,
*zero, alignment,
*commit, *zero,
arena_ind, *commit,
}; arena_ind,
#endif };
void *const ret void *const ret
{ {
@ -189,17 +188,16 @@ noexcept
assert(their_cache_arena_hooks); assert(their_cache_arena_hooks);
const auto &their_hooks(*their_cache_arena_hooks); const auto &their_hooks(*their_cache_arena_hooks);
#ifdef RB_DEBUG_DB_ENV if constexpr(RB_DEBUG_DB_ALLOCATOR)
log::debug log::debug
{ {
log, "cache arena:%u dalloc addr:%p size:%zu align:%zu z:%b c:%b ind:%u", log, "cache arena:%u dalloc addr:%p size:%zu align:%zu z:%b c:%b ind:%u",
database::allocator::cache_arena, database::allocator::cache_arena,
ptr, ptr,
size, size,
committed, committed,
arena_ind, arena_ind,
}; };
#endif
const bool ret const bool ret
{ {
@ -231,17 +229,17 @@ noexcept
assert(their_cache_arena_hooks); assert(their_cache_arena_hooks);
const auto &their_hooks(*their_cache_arena_hooks); const auto &their_hooks(*their_cache_arena_hooks);
#ifdef RB_DEBUG_DB_ENV
log::debug if constexpr(RB_DEBUG_DB_ALLOCATOR)
{ log::debug
log, "cache arena:%u destroy addr:%p size:%zu align:%zu z:%b c:%b ind:%u", {
database::allocator::cache_arena, log, "cache arena:%u destroy addr:%p size:%zu align:%zu z:%b c:%b ind:%u",
ptr, database::allocator::cache_arena,
size, ptr,
committed, size,
arena_ind, committed,
}; arena_ind,
#endif };
#if defined(HAVE_MLOCK2) #if defined(HAVE_MLOCK2)
if(database::allocator::mlock_current) if(database::allocator::mlock_current)
@ -269,18 +267,17 @@ noexcept
assert(their_cache_arena_hooks); assert(their_cache_arena_hooks);
const auto &their_hooks(*their_cache_arena_hooks); const auto &their_hooks(*their_cache_arena_hooks);
#ifdef RB_DEBUG_DB_ENV if constexpr(RB_DEBUG_DB_ALLOCATOR)
log::debug log::debug
{ {
log, "cache arena:%u commit addr:%p size:%zu offset:%zu length:%zu ind:%u", log, "cache arena:%u commit addr:%p size:%zu offset:%zu length:%zu ind:%u",
database::allocator::cache_arena, database::allocator::cache_arena,
ptr, ptr,
size, size,
offset, offset,
length, length,
arena_ind, arena_ind,
}; };
#endif
return their_hooks.commit(hooks, ptr, size, offset, length, arena_ind); return their_hooks.commit(hooks, ptr, size, offset, length, arena_ind);
} }
@ -299,18 +296,17 @@ noexcept
assert(their_cache_arena_hooks); assert(their_cache_arena_hooks);
const auto &their_hooks(*their_cache_arena_hooks); const auto &their_hooks(*their_cache_arena_hooks);
#ifdef RB_DEBUG_DB_ENV if constexpr(RB_DEBUG_DB_ALLOCATOR)
log::debug log::debug
{ {
log, "cache arena:%u decommit addr:%p size:%zu offset:%zu length:%zu ind:%u", log, "cache arena:%u decommit addr:%p size:%zu offset:%zu length:%zu ind:%u",
database::allocator::cache_arena, database::allocator::cache_arena,
ptr, ptr,
size, size,
offset, offset,
length, length,
arena_ind, arena_ind,
}; };
#endif
return their_hooks.decommit(hooks, ptr, size, offset, length, arena_ind); return their_hooks.decommit(hooks, ptr, size, offset, length, arena_ind);
} }
@ -329,18 +325,17 @@ noexcept
assert(their_cache_arena_hooks); assert(their_cache_arena_hooks);
const auto &their_hooks(*their_cache_arena_hooks); const auto &their_hooks(*their_cache_arena_hooks);
#ifdef RB_DEBUG_DB_ENV if constexpr(RB_DEBUG_DB_ALLOCATOR)
log::debug log::debug
{ {
log, "cache arena:%u purge lazy addr:%p size:%zu offset:%zu length:%zu ind:%u", log, "cache arena:%u purge lazy addr:%p size:%zu offset:%zu length:%zu ind:%u",
database::allocator::cache_arena, database::allocator::cache_arena,
ptr, ptr,
size, size,
offset, offset,
length, length,
arena_ind, arena_ind,
}; };
#endif
return their_hooks.purge_lazy(hooks, ptr, size, offset, length, arena_ind); return their_hooks.purge_lazy(hooks, ptr, size, offset, length, arena_ind);
} }
@ -359,18 +354,17 @@ noexcept
assert(their_cache_arena_hooks); assert(their_cache_arena_hooks);
const auto &their_hooks(*their_cache_arena_hooks); const auto &their_hooks(*their_cache_arena_hooks);
#ifdef RB_DEBUG_DB_ENV if constexpr(RB_DEBUG_DB_ALLOCATOR)
log::debug log::debug
{ {
log, "cache arena:%u purge forced addr:%p size:%zu offset:%zu length:%zu ind:%u", log, "cache arena:%u purge forced addr:%p size:%zu offset:%zu length:%zu ind:%u",
database::allocator::cache_arena, database::allocator::cache_arena,
ptr, ptr,
size, size,
offset, offset,
length, length,
arena_ind, arena_ind,
}; };
#endif
return their_hooks.purge_forced(hooks, ptr, size, offset, length, arena_ind); return their_hooks.purge_forced(hooks, ptr, size, offset, length, arena_ind);
} }
@ -390,19 +384,18 @@ noexcept
assert(their_cache_arena_hooks); assert(their_cache_arena_hooks);
const auto &their_hooks(*their_cache_arena_hooks); const auto &their_hooks(*their_cache_arena_hooks);
#ifdef RB_DEBUG_DB_ENV if constexpr(RB_DEBUG_DB_ALLOCATOR)
log::debug log::debug
{ {
log, "cache arena:%u split addr:%p size:%zu size_a:%zu size_b:%zu committed:%b ind:%u", log, "cache arena:%u split addr:%p size:%zu size_a:%zu size_b:%zu committed:%b ind:%u",
database::allocator::cache_arena, database::allocator::cache_arena,
ptr, ptr,
size, size,
size_a, size_a,
size_b, size_b,
committed, committed,
arena_ind, arena_ind,
}; };
#endif
return their_hooks.split(hooks, ptr, size, size_a, size_b, committed, arena_ind); return their_hooks.split(hooks, ptr, size, size_a, size_b, committed, arena_ind);
} }
@ -422,19 +415,18 @@ noexcept
assert(their_cache_arena_hooks); assert(their_cache_arena_hooks);
const auto &their_hooks(*their_cache_arena_hooks); const auto &their_hooks(*their_cache_arena_hooks);
#ifdef RB_DEBUG_DB_ENV if constexpr(RB_DEBUG_DB_ALLOCATOR)
log::debug log::debug
{ {
log, "cache arena:%u merge a[addr:%p size:%zu] b[addr:%p size:%zu] committed:%b ind:%u", log, "cache arena:%u merge a[addr:%p size:%zu] b[addr:%p size:%zu] committed:%b ind:%u",
database::allocator::cache_arena, database::allocator::cache_arena,
addr_a, addr_a,
size_a, size_a,
addr_b, addr_b,
size_b, size_b,
committed, committed,
arena_ind, arena_ind,
}; };
#endif
return their_hooks.merge(hooks, addr_a, size_a, addr_b, size_b, committed, arena_ind); return their_hooks.merge(hooks, addr_a, size_a, addr_b, size_b, committed, arena_ind);
} }
@ -521,18 +513,17 @@ noexcept
#endif #endif
}; };
#ifdef RB_DEBUG_DB_ENV
assert(d); assert(d);
log::debug if constexpr(RB_DEBUG_DB_ALLOCATOR)
{ log::debug
log, "[%s]'%s' allocate:%zu alignment:%zu %p", {
db::name(*d), log, "[%s]'%s' allocate:%zu alignment:%zu %p",
c? string_view(db::name(*c)): string_view{}, db::name(*d),
size, c? string_view(db::name(*c)): string_view{},
alignment, size,
ptr, alignment,
}; ptr,
#endif };
return ptr; return ptr;
} }