Add dynamic untracked memory limits for more precise memory tracking#64423
Conversation
…e into precise-memtracking
|
I'm not sure what's wrong with the Upgrade check. Does anyone have an idea? I've added a new setting to the history and it does not show up, but the check is still failing. Changed settings are not reflected in settings changes history (see changed_settings.txt) - FAIL New settings are not reflected in settings changes history (see new_settings.txt) - FAIL |
|
Okay, merge master and CI tests rerun fixed the problem. Tests |
|
This has broken |
…ory_limit is constant
…ed_memory_limit is constant
The current memory tracker has an error of up to `untracked_memory_limit = 4MB` per thread. Consider a ClickHouse server running with 8GB RAM and a standard `max_server_memory_usage_to_ram_ratio = 0.9` server setting. If there are 1000 threads (and every thread has 800KB on average) OOM can happen before any query is stopped with `MEMORY_LIMIT_EXCEEDED`. We need total untracked memory to be proportional to current memory usage regardless of the number of threads. To make it fit into 10% RAM we want an error to be less than e.g. 6%. To achieve it we need `untracked_memory_limit` to be updated dynamically and be proportional to current thread memory usage for threads with small memory footprint: `untracked_memory_limit = clamp(already_tracked / 16, 4KB, 4MB)` Resubmit of: ClickHouse#64423 Co-authored-by: Azat Khuzhin <a3at.mail@gmail.com>
The current memory tracker has an error of up to `untracked_memory_limit = 4MB` per thread. Consider a ClickHouse server running with 8GB RAM and a standard `max_server_memory_usage_to_ram_ratio = 0.9` server setting. If there are 1000 threads (and every thread has 800KB on average) OOM can happen before any query is stopped with `MEMORY_LIMIT_EXCEEDED`. We need total untracked memory to be proportional to current memory usage regardless of the number of threads. To make it fit into 10% RAM we want an error to be less than e.g. 6%. To achieve it we need `untracked_memory_limit` to be updated dynamically and be proportional to current thread memory usage for threads with small memory footprint: `untracked_memory_limit = clamp(already_tracked / 16, 4KB, 4MB)` Resubmit of: ClickHouse#64423 Co-authored-by: Azat Khuzhin <a3at.mail@gmail.com>
The current memory tracker has an error of up to `untracked_memory_limit = 4MB` per thread. Consider a ClickHouse server running with 8GB RAM and a standard `max_server_memory_usage_to_ram_ratio = 0.9` server setting. If there are 1000 threads (and every thread has 800KB on average) OOM can happen before any query is stopped with `MEMORY_LIMIT_EXCEEDED`. We need total untracked memory to be proportional to current memory usage regardless of the number of threads. To make it fit into 10% RAM we want an error to be less than e.g. 6%. To achieve it we need `untracked_memory_limit` to be updated dynamically and be proportional to current thread memory usage for threads with small memory footprint: `untracked_memory_limit = clamp(already_tracked / 16, 4KB, 4MB)` Resubmit of: ClickHouse#64423 Co-authored-by: Azat Khuzhin <a3at.mail@gmail.com>
The current memory tracker has an error of up to `untracked_memory_limit = 4MB` per thread. Consider a ClickHouse server running with 8GB RAM and a standard `max_server_memory_usage_to_ram_ratio = 0.9` server setting. If there are 1000 threads (and every thread has 800KB on average) OOM can happen before any query is stopped with `MEMORY_LIMIT_EXCEEDED`. We need total untracked memory to be proportional to current memory usage regardless of the number of threads. To make it fit into 10% RAM we want an error to be less than e.g. 6%. To achieve it we need `untracked_memory_limit` to be updated dynamically and be proportional to current thread memory usage for threads with small memory footprint: `untracked_memory_limit = clamp(already_tracked / 16, 4KB, 4MB)` Resubmit of: ClickHouse#64423 Co-authored-by: Azat Khuzhin <a3at.mail@gmail.com>
The current memory tracker has an error of up to `untracked_memory_limit = 4MB` per thread. Consider a ClickHouse server running with 8GB RAM and a standard `max_server_memory_usage_to_ram_ratio = 0.9` server setting. If there are 1000 threads (and every thread has 800KB on average) OOM can happen before any query is stopped with `MEMORY_LIMIT_EXCEEDED`. We need total untracked memory to be proportional to current memory usage regardless of the number of threads. To make it fit into 10% RAM we want an error to be less than e.g. 6%. To achieve it we need `untracked_memory_limit` to be updated dynamically and be proportional to current thread memory usage for threads with small memory footprint: `untracked_memory_limit = clamp(already_tracked / 16, 4KB, 4MB)` Resubmit of: ClickHouse#64423 Co-authored-by: Azat Khuzhin <a3at.mail@gmail.com>

The current memory tracker has an error of up to
untracked_memory_limit = 4MBper thread. Consider a ClickHouse server running with 8GB RAM and a standardmax_server_memory_usage_to_ram_ratio = 0.9server setting. If there are 1000 threads (and every thread has 800KB on average) OOM can happen before any query is stopped withMEMORY_LIMIT_EXCEEDED.We need total untracked memory to be proportional to current memory usage regardless of the number of threads. To make it fit into 10% RAM we want an error to be less than e.g. 6%. To achieve it we need
untracked_memory_limitto be updated dynamically and be proportional to current thread memory usage for threads with small memory footprint:untracked_memory_limit = clamp(already_tracked / 16, 4KB, 4MB).Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
This PR was reverted
Documentation entry for user-facing changes
CI Settings
NOTE: If your merge the PR with modified CI you MUST KNOW what you are doing
NOTE: Checked options will be applied if set before CI RunConfig/PrepareRunConfig step