mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-26 01:22:04 +00:00
Try to account untracked memory (per thread) more correctly.
This commit is contained in:
parent
ded70fbd53
commit
8e4c967fc9
@ -52,13 +52,16 @@ void CurrentMemoryTracker::allocImpl(Int64 size, bool throw_if_memory_exceeded)
|
|||||||
if (current_thread)
|
if (current_thread)
|
||||||
{
|
{
|
||||||
Int64 will_be = current_thread->untracked_memory + size;
|
Int64 will_be = current_thread->untracked_memory + size;
|
||||||
|
Int64 limit = current_thread->untracked_memory_limit + current_thread->untracked_memory_limit_increase;
|
||||||
|
|
||||||
if (will_be > current_thread->untracked_memory_limit)
|
if (will_be > limit)
|
||||||
{
|
{
|
||||||
/// Zero untracked before track. If tracker throws out-of-limit we would be able to alloc up to untracked_memory_limit bytes
|
/// Increase limit before track. If tracker throws out-of-limit we would be able to alloc up to untracked_memory_limit bytes
|
||||||
/// more. It could be useful to enlarge Exception message in rethrow logic.
|
/// more. It could be useful to enlarge Exception message in rethrow logic.
|
||||||
current_thread->untracked_memory = 0;
|
current_thread->untracked_memory_limit_increase += current_thread->untracked_memory_limit;
|
||||||
memory_tracker->allocImpl(will_be, throw_if_memory_exceeded);
|
memory_tracker->allocImpl(will_be, throw_if_memory_exceeded);
|
||||||
|
current_thread->untracked_memory_limit_increase = 0;
|
||||||
|
current_thread->untracked_memory = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -135,6 +135,8 @@ public:
|
|||||||
Int64 untracked_memory = 0;
|
Int64 untracked_memory = 0;
|
||||||
/// Each thread could new/delete memory in range of (-untracked_memory_limit, untracked_memory_limit) without access to common counters.
|
/// Each thread could new/delete memory in range of (-untracked_memory_limit, untracked_memory_limit) without access to common counters.
|
||||||
Int64 untracked_memory_limit = 4 * 1024 * 1024;
|
Int64 untracked_memory_limit = 4 * 1024 * 1024;
|
||||||
|
/// Increase limit in case of exception.
|
||||||
|
Int64 untracked_memory_limit_increase = 0;
|
||||||
|
|
||||||
/// Statistics of read and write rows/bytes
|
/// Statistics of read and write rows/bytes
|
||||||
Progress progress_in;
|
Progress progress_in;
|
||||||
|
Loading…
Reference in New Issue
Block a user