Skip to content

Commit

Permalink
Reduce the amount of noise logged in memory tracking reports.
Browse files Browse the repository at this point in the history
  • Loading branch information
teo-tsirpanis committed Mar 13, 2024
1 parent e6e1808 commit 96f97e0
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions tiledb/common/memory_tracker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,12 @@ MemoryTracker::get_counts() {
std::unordered_map<MemoryType, uint64_t> by_type;
std::vector<MemoryType> to_del;
for (auto& [mem_type, resource] : resources_) {
by_type[mem_type] = resource->get_count();
auto count = resource->get_count();
// This happens if the resource did not allocate any memory.
// Rather than log noise we just ignore it.
if (count != 0) {
by_type[mem_type] = count;
}
}

return {total, by_type};
Expand Down Expand Up @@ -274,7 +279,14 @@ std::string MemoryTrackerManager::to_json() {
trackers_.erase(trackers_.begin() + idx);
continue;
}
idx++;

auto [total, by_type] = ptr->get_counts();
if (total == 0) {
// This happens if the tracker did not allocate any memory.
// Rather than log noise we just ignore it.
continue;
}
nlohmann::json val;

// Set an distinguishing id
Expand All @@ -284,15 +296,12 @@ std::string MemoryTrackerManager::to_json() {
val["tracker_type"] = memory_tracker_type_to_str(ptr->get_type());

// Add memory stats
auto [total, by_type] = ptr->get_counts();
val["total_memory"] = total;
val["by_type"] = nlohmann::json::object();
for (auto& [type, count] : by_type) {
val["by_type"][memory_type_to_str(type)] = count;
}
rv.push_back(val);

idx++;
}

return rv.dump();
Expand Down

0 comments on commit 96f97e0

Please sign in to comment.