mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-25 00:52:02 +00:00
Use per user soft limit in GlobalOvercommitTracker
This commit is contained in:
parent
9464dc2fd3
commit
9c7e6c7814
@ -365,6 +365,12 @@ OvercommitRatio MemoryTracker::getOvercommitRatio()
|
||||
}
|
||||
|
||||
|
||||
OvercommitRatio MemoryTracker::getOvercommitRatio(Int64 limit)
|
||||
{
|
||||
return { amount.load(std::memory_order_relaxed), limit };
|
||||
}
|
||||
|
||||
|
||||
void MemoryTracker::resetCounters()
|
||||
{
|
||||
amount.store(0, std::memory_order_relaxed);
|
||||
|
@ -114,6 +114,11 @@ public:
|
||||
void setSoftLimit(Int64 value);
|
||||
void setHardLimit(Int64 value);
|
||||
|
||||
Int64 getSoftLimit() const
|
||||
{
|
||||
return soft_limit.load(std::memory_order_relaxed);
|
||||
}
|
||||
|
||||
/** Set limit if it was not set.
|
||||
* Otherwise, set limit to new value, if new value is greater than previous limit.
|
||||
*/
|
||||
@ -164,6 +169,7 @@ public:
|
||||
}
|
||||
|
||||
OvercommitRatio getOvercommitRatio();
|
||||
OvercommitRatio getOvercommitRatio(Int64 limit);
|
||||
|
||||
void setOvercommitTracker(OvercommitTracker * tracker) noexcept
|
||||
{
|
||||
|
@ -39,7 +39,7 @@ void UserOvercommitTracker::pickQueryToExcludeImpl()
|
||||
{
|
||||
MemoryTracker * current_tracker = nullptr;
|
||||
OvercommitRatio current_ratio{0, 0};
|
||||
//TODO: ensure this container is not being modified
|
||||
// At this moment query list must be read only
|
||||
for (auto const & query : user_process_list->queries)
|
||||
{
|
||||
auto * memory_tracker = query.second->getMemoryTracker();
|
||||
@ -61,7 +61,11 @@ void GlobalOvercommitTracker::pickQueryToExcludeImpl()
|
||||
process_list->processEachQueryStatus([&](DB::QueryStatus const & query)
|
||||
{
|
||||
auto * memory_tracker = query.getMemoryTracker();
|
||||
auto ratio = memory_tracker->getOvercommitRatio();
|
||||
Int64 user_soft_limit = 0;
|
||||
if (auto const * user_process_list = query.getUserProcessList())
|
||||
user_soft_limit = user_process_list->user_memory_tracker.getSoftLimit();
|
||||
|
||||
auto ratio = memory_tracker->getOvercommitRatio(user_soft_limit);
|
||||
if (current_ratio < ratio)
|
||||
{
|
||||
current_tracker = memory_tracker;
|
||||
|
@ -80,6 +80,7 @@ protected:
|
||||
friend class ThreadStatus;
|
||||
friend class CurrentThread;
|
||||
friend class ProcessListEntry;
|
||||
friend struct ::GlobalOvercommitTracker;
|
||||
|
||||
String query;
|
||||
ClientInfo client_info;
|
||||
|
Loading…
Reference in New Issue
Block a user