MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / runThread

Method runThread

src/Common/CgroupsMemoryUsageObserver.cpp:60–89  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

58}
59
60void CgroupsMemoryUsageObserver::runThread()
61{
62 DB::setThreadName(DB::ThreadName::CGROUP_MEMORY_OBSERVER);
63
64 last_available_memory_amount = getMemoryAmount();
65 LOG_INFO(log, "Memory amount initially available to the process is {}", ReadableSize(last_available_memory_amount));
66
67 std::unique_lock lock(thread_mutex);
68 while (true)
69 {
70 if (cond.wait_for(lock, wait_time, [this] { return quit; }))
71 break;
72
73 try
74 {
75 uint64_t available_memory_amount = getMemoryAmount();
76 if (available_memory_amount != last_available_memory_amount)
77 {
78 LOG_INFO(log, "Memory amount available to the process changed from {} to {}", ReadableSize(last_available_memory_amount), ReadableSize(available_memory_amount));
79 last_available_memory_amount = available_memory_amount;
80 std::lock_guard<std::mutex> memory_amount_available_changed_lock(memory_amount_available_changed_mutex);
81 on_memory_amount_available_changed();
82 }
83 }
84 catch (...)
85 {
86 tryLogCurrentException(log, __PRETTY_FUNCTION__);
87 }
88 }
89}
90
91}
92

Callers

nothing calls this directly

Calls 4

getMemoryAmountFunction · 0.85
ReadableSizeClass · 0.85
setThreadNameFunction · 0.70
tryLogCurrentExceptionFunction · 0.70

Tested by

no test coverage detected