Nikita Taranov
3069db71f1
Fix wrong attribution of untracked memory to a user/query ( #56089 )
...
* impl
* add tests
* add tests
* fix typo
2023-11-02 17:14:15 +01:00
Robert Schulze
9fff447716
Re-enable clang-tidy checks
2023-09-26 09:34:12 +00:00
Alexander Tokmakov
78d8557a56
fix
2023-08-15 15:37:09 +02:00
Nikolai Kochetov
30075d3bc2
Merge branch 'master' into revert-44629-revert_flamegraph
2023-08-07 19:31:20 +02:00
Nikolai Kochetov
e507221b7c
Fixing a test.
2023-08-03 09:35:45 +00:00
Nikita Taranov
2cbe79b529
Fix memory consumption when max_block_size
is huge in Aggregator + more memory checks ( #51566 )
...
* impl
* remove checks from without_key methods
* maybe will improve smth
* add test
* Update 02797_aggregator_huge_mem_usage_bug.sql
* Update 02797_aggregator_huge_mem_usage_bug.sql
---------
Co-authored-by: Alexey Milovidov <milovidov@clickhouse.com>
2023-08-02 15:11:52 +02:00
Nikolai Kochetov
aaba48f0df
Fixing build and style.
2023-08-01 17:54:17 +00:00
Nikolai Kochetov
fa06056fa2
Merge branch 'master' into revert-44629-revert_flamegraph
2023-08-01 17:14:16 +00:00
alesapin
aba291ca68
Revert "Revert "Add an ability to specify allocations size for sampling memory profiler""
2023-07-30 14:01:34 +02:00
Alexey Milovidov
43bd6d1b83
Revert "Add an ability to specify allocations size for sampling memory profiler"
2023-07-23 19:00:49 +03:00
Alexander Sapin
abd8bfed2b
Remove comment
2023-07-21 15:44:49 +02:00
Alexander Sapin
4695ec6802
Add an ability to specify allocations size for sampling memory profiler
2023-07-21 14:56:29 +02:00
Nikolai Kochetov
05e9fc6f2d
Merge branch 'master' into revert-44629-revert_flamegraph
2023-06-27 17:26:25 +00:00
Dmitry Novik
a1f21a5fc4
Do not log peak for background memory tracker
2023-04-14 16:49:14 +02:00
Dmitry Novik
cf5d9a175a
Revert "Merge pull request #48760 from ClickHouse/revert-46089-background-memory-tracker"
...
This reverts commit a61ed33223
, reversing
changes made to 5f01b8a2b5
.
2023-04-14 16:34:19 +02:00
Alexander Tokmakov
af1bf08663
Revert "Add MemoryTracker for the background tasks"
2023-04-13 21:05:02 +03:00
Dmitry Novik
06e6794fc0
Merge remote-tracking branch 'origin/master' into background-memory-tracker
2023-04-11 15:29:35 +00:00
Azat Khuzhin
e91c8bfea3
Fix deadlock due to debug tracking of memory allocations
...
Since memory tracker should be blocked globally (by default it is blocked only
for VariableContext::User).
<details>
<summary>stacktrace</summary>
* thread 11, name = 'Collector', stop reason = trace
frame 1: 0x00007ffff7e37ea2 libc.so.6`pthread_mutex_lock + 274
frame 6: 0x000000001ee10298 clickhouse`toStringCached(pointers=0x00007fffedfef068, offset=0, size=45) + 88 at StackTrace.cpp:425
frame 7: 0x000000001ee1128e clickhouse`StackTrace::toString(this=0x00007fffedfef058) const + 46 at StackTrace.cpp:444
frame 8: 0x000000001ede58ff clickhouse`(anonymous namespace)::debugLogBigAllocationWithoutCheck(size=25187648) + 479 at MemoryTracker.cpp:98
frame 9: 0x000000001ede5481 clickhouse`MemoryTracker::allocImpl(this=0x0000000030729e68, size=25187648, throw_if_memory_exceeded=false, query_tracker=0x00007ffff3c22440) + 3937 at MemoryTracker.cpp:352
frame 10: 0x000000001ede477f clickhouse`MemoryTracker::allocImpl(this=0x00007ffff3c1e530, size=25187648, throw_if_memory_exceeded=false, query_tracker=0x00007ffff3c22440) + 607 at MemoryTracker.cpp:198
frame 11: 0x000000001ede477f clickhouse`MemoryTracker::allocImpl(this=0x00007ffff3c22440, size=25187648, throw_if_memory_exceeded=false, query_tracker=0x0000000000000000) + 607 at MemoryTracker.cpp:198
frame 12: 0x000000001ede477f clickhouse`MemoryTracker::allocImpl(this=0x00007fffedff3bf0, size=25187648, throw_if_memory_exceeded=false, query_tracker=0x0000000000000000) + 607 at MemoryTracker.cpp:198
frame 13: 0x000000001ed6c4c9 clickhouse`CurrentMemoryTracker::allocImpl(size=25165824, throw_if_memory_exceeded=false) + 265 at CurrentMemoryTracker.cpp:58
frame 14: 0x000000001ed6c6a1 clickhouse`CurrentMemoryTracker::allocNoThrow(size=25165824) + 33 at CurrentMemoryTracker.cpp:91
frame 15: 0x000000001ed63079 clickhouse`operator new(unsigned long) [inlined] void Memory::trackMemory<>(size=25165824) + 89 at memory.h:177
frame 16: 0x000000001ed63034 clickhouse`operator new(size=25165824) + 20 at new_delete.cpp:74
...
frame 27: 0x000000001ee15895 clickhouse`DB::(anonymous namespace)::collectSymbols(info=0x00007ffff7062000, (null)=<unavailable>, data_ptr=0x00007fffec2b7000) + 53 at SymbolIndex.cpp:483
frame 28: 0x000000002e1a5d57 clickhouse`::dl_iterate_phdr(callback=(clickhouse`DB::(anonymous namespace)::collectSymbols(dl_phdr_info*, unsigned long, void*) at SymbolIndex.cpp:480), data=0x00007fffec2b7000)(dl_phdr_info *, size_t, void *), void *) + 183 at phdr_cache.cpp:76
frame 29: 0x000000001ee15549 clickhouse`DB::SymbolIndex::update(this=0x00007fffec2b7000) + 41 at SymbolIndex.cpp:515
frame 30: 0x000000001ee1be35 clickhouse`DB::SymbolIndex::SymbolIndex(this=<unavailable>) + 53 at SymbolIndex.h:23
frame 31: 0x000000001ee17a6c clickhouse`DB::SymbolIndex::instanceImpl() + 108 at SymbolIndex.cpp:555
frame 32: 0x000000001ee17b4a clickhouse`DB::SymbolIndex::instance() + 10 at SymbolIndex.cpp:561
frame 33: 0x000000001ee1070f clickhouse`void toStringEveryLineImpl<toStringCached(std::__1::array<void*, 45ul> const&, unsigned long, unsigned long)::$_0>(fatal=false, stack_trace=0x00007fffedff1ef8, callback=0x00007fffedff1ee0)::$_0&&) + 207 at StackTrace.cpp:349
frame 34: 0x000000001ee1040b clickhouse`toStringCached(pointers=0x00007fffedff2928, offset=0, size=43) + 459 at StackTrace.cpp:436
frame 35: 0x000000001ee1128e clickhouse`StackTrace::toString(this=0x00007fffedff2918) const + 46 at StackTrace.cpp:444
frame 36: 0x000000001ede58ff clickhouse`(anonymous namespace)::debugLogBigAllocationWithoutCheck(size=25165824) + 479 at MemoryTracker.cpp:98
frame 37: 0x000000001ede5481 clickhouse`MemoryTracker::allocImpl(this=0x00007fffedff3bf0, size=25165824, throw_if_memory_exceeded=false, query_tracker=0x0000000000000000) + 3937 at MemoryTracker.cpp:352
frame 38: 0x000000001ed6c4c9 clickhouse`CurrentMemoryTracker::allocImpl(size=25165824, throw_if_memory_exceeded=false) + 265 at CurrentMemoryTracker.cpp:58
frame 39: 0x000000001ed6c6a1 clickhouse`CurrentMemoryTracker::allocNoThrow(size=25165824) + 33 at CurrentMemoryTracker.cpp:91
frame 40: 0x000000001ed63079 clickhouse`operator new(unsigned long) [inlined] void Memory::trackMemory<>(size=25165824) + 89 at memory.h:177
frame 41: 0x000000001ed63034 clickhouse`operator new(size=25165824) + 20 at new_delete.cpp:74
...
frame 55: 0x0000000025badace clickhouse`DB::WriteBufferFromS3::nextImpl(this=0x00007ffff3c58f00) + 366 at WriteBufferFromS3.cpp:110
</details>
Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
2023-04-06 16:03:46 +02:00
Sema Checherinda
b8729be97a
Merge pull request #47104 from CheSema/thead-group-for-merge
...
merge and mutation make thread group for setting memory trackers right
2023-04-06 15:46:56 +02:00
Alexander Tokmakov
0e0e89d596
fix
2023-04-05 15:10:09 +02:00
Alexander Tokmakov
f5574d0d74
find big allocations without limits checks
2023-04-04 20:10:22 +02:00
Sema Checherinda
a6ab33a906
no use query, but storage context
2023-03-27 16:30:32 +02:00
Sema Checherinda
da4f2bd923
do not attach empty thread group
2023-03-24 19:53:16 +01:00
Sema Checherinda
bc107c70fa
merge and mutation make thread group for setting memory trackers right
2023-03-24 19:53:16 +01:00
Alexander Tokmakov
d621b2c4ad
fix intersecting parts, better fault injections
2023-03-16 21:28:07 +01:00
Dmitry Novik
1e065b32f3
Add MemoryTracker for the background tasks
2023-02-06 17:25:58 +00:00
Dmitry Novik
ec1f6bfd37
Improve MEMERY_LIMIT_EXCEEDED exception message
2023-01-29 01:52:37 +00:00
Alexander Tokmakov
70d1adfe4b
Better formatting for exception messages ( #45449 )
...
* save format string for NetException
* format exceptions
* format exceptions 2
* format exceptions 3
* format exceptions 4
* format exceptions 5
* format exceptions 6
* fix
* format exceptions 7
* format exceptions 8
* Update MergeTreeIndexGin.cpp
* Update AggregateFunctionMap.cpp
* Update AggregateFunctionMap.cpp
* fix
2023-01-24 00:13:58 +03:00
Nikolai Kochetov
03adbfdef7
Simplify code a bit.
2023-01-18 13:28:57 +00:00
Nikolai Kochetov
692e08628c
Better inlining
2023-01-17 14:44:42 +00:00
Nikolai Kochetov
6f737f0741
Inline part of AllocationTrace.
2023-01-16 15:48:44 +00:00
Nikolai Kochetov
2081408c15
Revert "Revert "Merge pull request #38953 from ClickHouse/add-allocation-ptr-to-trace-log"
2023-01-16 15:10:31 +01:00
Raúl Marín
948ce8db93
Revert "Merge pull request #38953 from ClickHouse/add-allocation-ptr-to-trace-log"
...
This reverts commit e99849d031
, reversing
changes made to 7ad3ff8a9e
.
2022-12-27 14:28:13 +01:00
Nikolai Kochetov
9a4b3493fd
Merge branch 'master' into add-allocation-ptr-to-trace-log
2022-12-06 17:09:54 +01:00
Nikolai Kochetov
7649a3c4d7
Merge branch 'master' into add-allocation-ptr-to-trace-log
2022-12-01 12:12:23 +01:00
Anton Popov
312dd725b4
allow to send profile events to trace_log
2022-11-24 20:12:16 +00:00
Dmitry Novik
b17dc24a94
Do not reuse jemalloc memory in test
2022-11-21 16:10:47 +00:00
Azat Khuzhin
7b69a70e82
Fix frequent memory drift message and clarify things in comments
...
Somethine like:
2022.09.28 06:33:34.001433 [ 3133669 ] {} <Trace> AsynchronousMetrics: MemoryTracking: was 562.20 MiB, peak 562.21 MiB, will set to 562.20 MiB (RSS), difference: -70.46 MiB
2022.09.28 06:33:35.001639 [ 3133669 ] {} <Trace> AsynchronousMetrics: MemoryTracking: was 562.20 MiB, peak 562.21 MiB, will set to 562.20 MiB (RSS), difference: -70.45 MiB
Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
2022-10-26 17:38:37 +02:00
Azat Khuzhin
f5f6f1b593
Add profile events for jemalloc purge
...
Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
2022-10-26 17:38:36 +02:00
Robert Schulze
fd86829824
Consolidate config_core.h into config.h
...
Less duplication, less confusion ...
2022-09-28 13:31:57 +00:00
Nikolai Kochetov
9e1bb19559
Purge jemalloc arenas in case of high memory usage. ( #40277 )
...
* Purge jemalloc arenas in case of high memory usage.
* Purge jemalloc arenas in case of high memory usage.
* Get RSS before jemalloc counters. Try to avoid negative RSS.
* Try to avoid negative RSS.
* muzzy -> dirty
* Another fix.
* Update MemoryTracker.cpp
* Wait for purged memory.
* Revert "Wait for purged memory."
This reverts commit 53a2621a2d
.
2022-09-20 23:56:10 +02:00
Alexey Milovidov
fa62c7e982
Fix half of trash
2022-09-10 04:08:16 +02:00
Azat Khuzhin
28f2607d50
Fix rare race in updating peak of memory tracker
...
Previously it was possible that allocation, that had been done with
locked MEMORY_LIMIT_EXCEEDED (LockMemoryExceptionInThread), will update
the peak to the amount that will include some other allocations.
Consider the following example (T1/T2 - different threads):
Initial state:
MemoryTracker::amount = 0
Possible race:
LockMemoryExceptionInThread locker;
T1: MemoryTracker::allocImpl(1MiB) T2: MemoryTracker::allocImpl(1PiB)
will_be = 1T, amount = 1T
will_be = 1T+1MiB, amount=1T+1MiB
peak = will_be
amount = 0 // revert due to exceeding limit
throw(MEMORY_LIMIT_EXCEEDED)
So as you can see T1 includes allocations from T2 into the peak.
Note, that almost every place that has memory_usage column uses
MemoryTracker::peak (not MemoryTracker::amount), this is true for
query_log (for part_log column name is peak_memory_usage, and obviously
it uses MemoryTracker::peak).
Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
2022-08-19 20:57:12 +02:00
Azat Khuzhin
ded70fbd53
Fix memory accounting in case of MEMORY_LIMIT_EXCEEDED errors
...
In case of memory allocation had been failed, it should not be take into
account anywhere, otherwise it will report incorrect memory usage for
query and in logs.
I found this while was digging into OOM in stress tests, and saw memory
allocations that had been significantly greater the memory limit (even
with overcommit).
Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
2022-08-16 18:08:56 +02:00
Nikita Mikhaylov
2282f2f414
Merge branch 'master' into add-allocation-ptr-to-trace-log
2022-08-15 12:25:45 +02:00
Alexey Milovidov
216c1d8efa
Revert "Use separate counter for RSS in global memory tracker."
2022-08-14 09:50:12 +03:00
Nikita Mikhaylov
00d2c57a68
Merge branch 'master' into add-allocation-ptr-to-trace-log
2022-08-12 13:32:24 +02:00
Nikita Mikhaylov
8e8e845a89
Merge branch 'master' into separate-counter-for-rss-in-memory-tracker
2022-08-10 16:44:24 +02:00
Nikita Mikhaylov
f144eae388
Fix typo and extra dots in exception messages from OverCommitTracker ( #39858 )
2022-08-03 15:23:07 +02:00
Nikolai Kochetov
fa0707b4e7
Review fixes.
2022-07-26 17:51:09 +00:00