mirror of
https://github.com/mhx/dwarfs.git
synced 2025-09-14 14:59:52 -04:00
chore(segmenter): add debug logging with memory usage information
This commit is contained in:
parent
6240c601c7
commit
b587042215
@ -149,16 +149,28 @@ class fast_multimap {
|
||||
return false;
|
||||
}
|
||||
|
||||
void clear() {
|
||||
values_.clear();
|
||||
collisions_.clear();
|
||||
}
|
||||
|
||||
DWARFS_FORCE_INLINE blockhash_t const& values() const { return values_; };
|
||||
DWARFS_FORCE_INLINE collision_t const& collisions() const {
|
||||
return collisions_;
|
||||
};
|
||||
|
||||
size_t memory_usage() const {
|
||||
auto phmap_mem = []<typename T>(T const& m) {
|
||||
return m.capacity() * sizeof(typename T::slot_type) + m.capacity() + 1;
|
||||
};
|
||||
|
||||
auto mem = phmap_mem(values_) + phmap_mem(collisions_);
|
||||
|
||||
for (auto const& c : collisions_) {
|
||||
if (c.second.size() > MaxCollInline) {
|
||||
mem +=
|
||||
c.second.capacity() * sizeof(typename collision_vector::value_type);
|
||||
}
|
||||
}
|
||||
|
||||
return mem;
|
||||
}
|
||||
|
||||
private:
|
||||
blockhash_t values_;
|
||||
collision_t collisions_;
|
||||
@ -245,6 +257,8 @@ class alignas(64) bloom_filter {
|
||||
std::transform(cbegin(), cend(), other.cbegin(), begin(), std::bit_or<>{});
|
||||
}
|
||||
|
||||
size_t memory_usage() const { return size_ / 8; }
|
||||
|
||||
private:
|
||||
DWARFS_FORCE_INLINE bits_type const* cbegin() const { return bits_; }
|
||||
DWARFS_FORCE_INLINE bits_type const* cend() const {
|
||||
@ -592,6 +606,18 @@ class active_block : private GranularityPolicy {
|
||||
data_.reserve(this->frames_to_bytes(capacity_in_frames_));
|
||||
}
|
||||
|
||||
~active_block() {
|
||||
LOG_DEBUG << "block " << num_ << " destroyed, "
|
||||
<< size_with_unit(offsets_.memory_usage()) << " offset memory ("
|
||||
<< fmt::format("{:.1f}",
|
||||
static_cast<double>(offsets_.memory_usage()) /
|
||||
offsets_.values().size())
|
||||
<< " bytes per offset, " << offsets_.values().size()
|
||||
<< " offsets, " << offsets_.collisions().size()
|
||||
<< " collisions), " << size_with_unit(filter_.memory_usage())
|
||||
<< " bloom filter";
|
||||
}
|
||||
|
||||
DWARFS_FORCE_INLINE size_t num() const { return num_; }
|
||||
|
||||
DWARFS_FORCE_INLINE size_t size_in_frames() const {
|
||||
|
Loading…
x
Reference in New Issue
Block a user