Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion be/src/common/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ CONF_String(memory_mode, "moderate");
// defaults to bytes if no unit is given"
// must larger than 0. and if larger than physical memory size,
// it will be set to physical memory size.
CONF_String(mem_limit, "80%");
// `auto` means process mem limit is equal to max(physical_mem * 0.9, physical_mem - 6.4G).
// 6.4G is the maximum memory reserved for the system by default.
CONF_String(mem_limit, "auto");

// Soft memory limit as a fraction of hard memory limit.
CONF_Double(soft_mem_limit_frac, "0.9");
Expand Down
25 changes: 15 additions & 10 deletions be/src/util/mem_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,16 +237,21 @@ void MemInfo::init() {
}

bool is_percent = true;
_s_mem_limit = ParseUtil::parse_mem_spec(config::mem_limit, -1, _s_physical_mem, &is_percent);
if (_s_mem_limit <= 0) {
LOG(WARNING) << "Failed to parse mem limit from '" + config::mem_limit + "'.";
}
if (_s_mem_limit > _s_physical_mem) {
LOG(WARNING) << "Memory limit " << PrettyPrinter::print(_s_mem_limit, TUnit::BYTES)
<< " exceeds physical memory of "
<< PrettyPrinter::print(_s_physical_mem, TUnit::BYTES)
<< ". Using physical memory instead";
_s_mem_limit = _s_physical_mem;
if (config::mem_limit == "auto") {
_s_mem_limit = std::max<int64_t>(_s_physical_mem * 0.9, _s_physical_mem - 6871947672);
} else {
_s_mem_limit =
ParseUtil::parse_mem_spec(config::mem_limit, -1, _s_physical_mem, &is_percent);
if (_s_mem_limit <= 0) {
LOG(WARNING) << "Failed to parse mem limit from '" + config::mem_limit + "'.";
}
if (_s_mem_limit > _s_physical_mem) {
LOG(WARNING) << "Memory limit " << PrettyPrinter::print(_s_mem_limit, TUnit::BYTES)
<< " exceeds physical memory of "
<< PrettyPrinter::print(_s_physical_mem, TUnit::BYTES)
<< ". Using physical memory instead";
_s_mem_limit = _s_physical_mem;
}
}
_s_mem_limit_str = PrettyPrinter::print(_s_mem_limit, TUnit::BYTES);
_s_soft_mem_limit = _s_mem_limit * config::soft_mem_limit_frac;
Expand Down
3 changes: 2 additions & 1 deletion docs/en/docs/admin-manual/config/be-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,8 @@ There are two ways to configure BE configuration items:

* Type: string
* Description: Limit the percentage of the server's maximum memory used by the BE process. It is used to prevent BE memory from occupying to many the machine's memory. This parameter must be greater than 0. When the percentage is greater than 100%, the value will default to 100%.
* Default value: 80%
- `auto` means process mem limit is equal to max(physical_mem * 0.9, physical_mem - 6.4G), 6.4G is the maximum memory reserved for the system by default.
* Default value: auto

#### `cluster_id`

Expand Down
3 changes: 2 additions & 1 deletion docs/zh-CN/docs/admin-manual/config/be-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,8 @@ BE 重启后该配置将失效。如果想持久化修改结果,使用如下

* 类型:string
* 描述:限制BE进程使用服务器最大内存百分比。用于防止BE内存挤占太多的机器内存,该参数必须大于0,当百分大于100%之后,该值会默认为100%。
* 默认值:80%
- `auto` 等于 max(physical_mem * 0.9, physical_mem - 6.4G),6.4G是默认为系统预留的最大内存。
* 默认值:auto

#### `cluster_id`

Expand Down