Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
  • Loading branch information
xinyiZzz committed Jan 9, 2025
1 parent dce5b01 commit 644781f
Showing 1 changed file with 16 additions and 28 deletions.
44 changes: 16 additions & 28 deletions be/src/runtime/workload_group/workload_group.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,56 +213,44 @@ int64_t WorkloadGroup::gc_memory(int64_t need_free_mem, RuntimeProfile* profile,
if (need_free_mem <= 0) {
return 0;
}
// Disable the default WorkloadGroup `normal` memory GC, for users who have not configured WorkloadGroup,
// will not notice the existence of WorkloadGroup `normal` in memory usage.
if (_name == "normal" && _enable_memory_overcommit) {
return 0;
}
int64_t used_memory = memory_used();
int64_t freed_mem = 0;

std::string cancel_str = "";
if (is_minor_gc) {
cancel_str = fmt::format(
"MinorGC kill overcommit query, wg id:{}, name:{}, used:{}, limit:{}, "
"backend:{}.",
_id, _name, MemCounter::print_bytes(used_memory),
MemCounter::print_bytes(_memory_limit), BackendOptions::get_localhost());
} else {
if (_enable_memory_overcommit) {
cancel_str = fmt::format(
"FullGC release wg overcommit mem, wg id:{}, name:{}, "
"used:{},limit:{},backend:{}.",
_id, _name, MemCounter::print_bytes(used_memory),
MemCounter::print_bytes(_memory_limit), BackendOptions::get_localhost());
} else {
cancel_str = fmt::format(
"GC wg for hard limit, wg id:{}, name:{}, used:{}, limit:{}, "
"backend:{}.",
_id, _name, MemCounter::print_bytes(used_memory),
MemCounter::print_bytes(_memory_limit), BackendOptions::get_localhost());
}
}
std::string cancel_str = fmt::format(
"WorkloadGroup memory exceed limit, id:{}, name:{}, used:{}, limit:{}, "
"backend:{}.",
_id, _name, MemCounter::print_bytes(used_memory),
MemCounter::print_bytes(_memory_limit), BackendOptions::get_localhost());
auto cancel_top_overcommit_str = [cancel_str](int64_t mem_consumption,
const std::string& label) {
return fmt::format(
"{} cancel top memory overcommit tracker <{}> consumption {}. details:{}, "
"{} cancel top memory overcommit tracker <{}> consumption {}. {}, "
"Execute "
"again after enough memory, details see be.INFO.",
cancel_str, label, MemCounter::print_bytes(mem_consumption),
GlobalMemoryArbitrator::process_limit_exceeded_errmsg_str());
GlobalMemoryArbitrator::process_mem_log_str());
};
auto cancel_top_usage_str = [cancel_str](int64_t mem_consumption, const std::string& label) {
return fmt::format(
"{} cancel top memory used tracker <{}> consumption {}. details:{}, Execute "
"{} cancel top memory used tracker <{}> consumption {}. {}, Execute "
"again "
"after enough memory, details see be.INFO.",
cancel_str, label, MemCounter::print_bytes(mem_consumption),
GlobalMemoryArbitrator::process_soft_limit_exceeded_errmsg_str());
GlobalMemoryArbitrator::process_mem_log_str());
};

LOG(INFO) << fmt::format(
"[MemoryGC] work load group start gc, id:{} name:{}, memory limit: {}, used: {}, "
"[MemoryGC] WorkloadGroup start gc, id:{} name:{}, memory limit: {}, used: {}, "
"need_free_mem: {}.",
_id, _name, _memory_limit, used_memory, need_free_mem);
Defer defer {[&]() {
LOG(INFO) << fmt::format(
"[MemoryGC] work load group finished gc, id:{} name:{}, memory limit: {}, "
"[MemoryGC] WorkloadGroup finished gc, id:{} name:{}, memory limit: {}, "
"used: "
"{}, need_free_mem: {}, freed memory: {}.",
_id, _name, _memory_limit, used_memory, need_free_mem, freed_mem);
Expand Down

0 comments on commit 644781f

Please sign in to comment.