xo-alloc2: misc refactoring / debug logging
This commit is contained in:
parent
04c506261d
commit
7e8f49d256
4 changed files with 45 additions and 15 deletions
|
|
@ -48,7 +48,7 @@ namespace xo {
|
|||
std::uint32_t tseq() const noexcept { return p_config_->tseq(*p_header_); }
|
||||
/** Allocation age in garbage collector **/
|
||||
std::uint32_t age() const noexcept { return p_config_->age (*p_header_); }
|
||||
/** Allocation size (including allocator-supplied padding) **/
|
||||
/** Allocation size (including allocator-supplied padding, excluding alloc header) **/
|
||||
size_type size() const noexcept { return p_config_->size(*p_header_); }
|
||||
/** Payload for this allocation. This is the memory available to application **/
|
||||
span_type payload() const noexcept;
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ namespace xo {
|
|||
cmpresult
|
||||
DArenaIterator::compare(const DArenaIterator & other_ix) const noexcept
|
||||
{
|
||||
scope log(XO_DEBUG(true),
|
||||
scope log(XO_DEBUG(false),
|
||||
xtag("arena", arena_),
|
||||
xtag("pos", pos_),
|
||||
xtag("other.arena", other_ix.arena_),
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
//#include "gc/DX1Collector.hpp"
|
||||
#include <xo/randomgen/xoshiro256.hpp>
|
||||
#include <xo/randomgen/random_seed.hpp>
|
||||
#include <xo/indentlog/scope.hpp>
|
||||
#include <xo/indentlog/print/tag.hpp>
|
||||
#include <xo/indentlog/print/array.hpp>
|
||||
#include <catch2/catch.hpp>
|
||||
|
|
@ -29,6 +30,7 @@ namespace xo {
|
|||
using xo::mm::generation;
|
||||
using xo::mm::c_max_generation;
|
||||
using xo::facet::with_facet;
|
||||
using xo::scope;
|
||||
|
||||
namespace ut {
|
||||
// checklist
|
||||
|
|
@ -151,6 +153,8 @@ namespace xo {
|
|||
|
||||
TEST_CASE("collector-x1-alloc", "[alloc2][gc]")
|
||||
{
|
||||
scope log(XO_DEBUG(true), "DX1Collector alloc test");
|
||||
|
||||
ArenaConfig arena_cfg = { .name_ = "_test_unused",
|
||||
.size_ = 4*1024*1024,
|
||||
.store_header_flag_ = true,
|
||||
|
|
@ -190,14 +194,17 @@ namespace xo {
|
|||
|
||||
TEST_CASE("collector-x1-alloc2", "[alloc2][gc]")
|
||||
{
|
||||
scope log(XO_DEBUG(true), "DX1Collector alloc test2");
|
||||
|
||||
ArenaConfig arena_cfg = { .name_ = "_test_unused",
|
||||
.size_ = 4*1024*1024,
|
||||
.store_header_flag_ = true,
|
||||
.header_ = AllocHeaderConfig(8 /*guard_z*/,
|
||||
.header_ = AllocHeaderConfig(8 /*guard_z*/,
|
||||
0xfd /*guard-byte*/,
|
||||
0 /*tseq-bits*/,
|
||||
0 /*age-bits*/,
|
||||
16 /*size-bits*/), };
|
||||
0 /*tseq-bits*/,
|
||||
0 /*age-bits*/,
|
||||
16 /*size-bits*/),
|
||||
};
|
||||
|
||||
/* collector with one generation collapses to a non-generational copying collector */
|
||||
CollectorConfig cfg = { .arena_config_ = arena_cfg,
|
||||
|
|
@ -222,7 +229,7 @@ namespace xo {
|
|||
REQUIRE(x1alloc.data());
|
||||
|
||||
rng::Seed<rng::xoshiro256ss> seed;
|
||||
std::cerr << "ratio: seed=" << seed << std::endl;
|
||||
log && log("ratio: seed=", seed);
|
||||
|
||||
auto rng = rng::xoshiro256ss(seed);
|
||||
|
||||
|
|
|
|||
|
|
@ -52,9 +52,9 @@ namespace utest {
|
|||
*
|
||||
* allocs sorted on Alloc::lo
|
||||
*/
|
||||
std::map<byte *, Alloc> allocs_by_lo_map;
|
||||
std::map<const byte *, Alloc> allocs_by_lo_map;
|
||||
/* allocs sorted on Alloc::hi */
|
||||
std::map<byte *, Alloc*> allocs_by_hi_map;
|
||||
std::map<const byte *, Alloc*> allocs_by_hi_map;
|
||||
|
||||
for (uint32_t i_alloc = 0; i_alloc < n_alloc; ++i_alloc) {
|
||||
std::normal_distribution<double> ngen{5.0, 1.5};
|
||||
|
|
@ -172,18 +172,41 @@ namespace utest {
|
|||
.hugepage_z_ = 4*1024 });
|
||||
auto range = mm.alloc_range(scratch_mm);
|
||||
|
||||
#ifdef NOT_YET // to verify iteration here, need iterator support in AAllocator
|
||||
|
||||
/* verify iteration visits all the allocs, exactly once */
|
||||
/* limit iteration test to a few cases:
|
||||
* - 1st loop
|
||||
* - median loop
|
||||
* - last loop
|
||||
*/
|
||||
if (i_alloc == 0 || i_alloc == n_alloc || 2*i_alloc == n_alloc)
|
||||
{
|
||||
/* verify iteration visits all the allocs, exactly once */
|
||||
|
||||
/* temp copy; remove allocs from this map as we encounter
|
||||
* them via range iteration below
|
||||
*/
|
||||
auto alloc_map = allocs_by_lo_map;
|
||||
|
||||
for (AllocInfo info : mm) {
|
||||
if (log || true) {
|
||||
log(xtag("allocs_by_lo_map.size", allocs_by_lo_map.size()));
|
||||
|
||||
for (auto & kv : allocs_by_lo_map) {
|
||||
log(xtag("key", kv.first), xtag("value", kv.second.lo()), xtag("hi", kv.second.hi()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
for (AllocInfo info : range) {
|
||||
INFO(tostr(xtag("alloc_map.size", alloc_map.size()),
|
||||
xtag("i_alloc", i_alloc)));
|
||||
INFO(tostr(xtag("payload.first", info.payload().first)));
|
||||
|
||||
const std::byte * alloc_lo = info.payload().first;
|
||||
|
||||
REQUIRE_ORFAIL(ok_flag, catch_flag,
|
||||
alloc_map.find(alloc_lo) != alloc_map.end());
|
||||
|
||||
alloc_map.erase(alloc_lo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue