[fix](memory) Independent count exec node memory profile (#22598)

Independent count exec node memory profile, after #22582
This commit is contained in:
Xinyi Zou
2023-08-06 10:56:31 +08:00
committed by GitHub
parent 1073a924c1
commit 96f42ca20a
12 changed files with 48 additions and 91 deletions

View File

@ -61,15 +61,9 @@ static RuntimeProfile::Counter* freed_memory_counter =
static RuntimeProfile::Counter* cancel_tasks_counter =
ADD_COUNTER(free_top_memory_task_profile, "CancelTasksNum", TUnit::UNIT);
MemTrackerLimiter::MemTrackerLimiter(Type type, const std::string& label, int64_t byte_limit,
RuntimeProfile* profile,
const std::string& profile_counter_name) {
MemTrackerLimiter::MemTrackerLimiter(Type type, const std::string& label, int64_t byte_limit) {
DCHECK_GE(byte_limit, -1);
_consumption = std::make_shared<MemCounter>();
if (profile != nullptr) {
_profile_counter =
profile->AddSharedHighWaterMarkCounter(profile_counter_name, TUnit::BYTES);
}
_type = type;
_label = label;
_limit = byte_limit;
@ -130,15 +124,6 @@ void MemTrackerLimiter::refresh_global_counter() {
}
}
void MemTrackerLimiter::refresh_all_tracker_profile() {
for (unsigned i = 0; i < mem_tracker_limiter_pool.size(); ++i) {
std::lock_guard<std::mutex> l(mem_tracker_limiter_pool[i].group_lock);
for (auto tracker : mem_tracker_limiter_pool[i].trackers) {
tracker->refresh_profile_counter();
}
}
}
void MemTrackerLimiter::make_process_snapshots(std::vector<MemTracker::Snapshot>* snapshots) {
MemTrackerLimiter::refresh_global_counter();
int64_t process_mem_sum = 0;
@ -148,7 +133,7 @@ void MemTrackerLimiter::make_process_snapshots(std::vector<MemTracker::Snapshot>
snapshot.label = "";
snapshot.limit = -1;
snapshot.cur_consumption = it.second->current_value();
snapshot.peak_consumption = it.second->value();
snapshot.peak_consumption = it.second->peak_value();
(*snapshots).emplace_back(snapshot);
process_mem_sum += it.second->current_value();
}