[enhancement](memory) Add Memory GC when the available memory of the BE process is lacking (#14712)
When the system MemAvailable is less than the warning water mark, or the memory used by the BE process exceeds the mem soft limit, run minor gc and try to release cache. When the MemAvailable of the system is less than the low water mark, or the memory used by the BE process exceeds the mem limit, run fucc gc, try to release the cache, and start canceling from the query with the largest memory usage until the memory of mem_limit * 20% is released.
This commit is contained in:
@ -120,6 +120,19 @@ public:
|
||||
_chunk_lists[idx].push_back(ptr);
|
||||
}
|
||||
|
||||
void clear() {
|
||||
std::lock_guard<SpinLock> l(_lock);
|
||||
for (int i = 0; i < 64; ++i) {
|
||||
if (_chunk_lists[i].empty()) {
|
||||
continue;
|
||||
}
|
||||
for (auto ptr : _chunk_lists[i]) {
|
||||
::free(ptr);
|
||||
}
|
||||
std::vector<uint8_t*>().swap(_chunk_lists[i]);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
SpinLock _lock;
|
||||
std::vector<std::vector<uint8_t*>> _chunk_lists;
|
||||
@ -256,4 +269,11 @@ void ChunkAllocator::free(uint8_t* data, size_t size) {
|
||||
free(chunk);
|
||||
}
|
||||
|
||||
void ChunkAllocator::clear() {
|
||||
for (int i = 0; i < _arenas.size(); ++i) {
|
||||
_arenas[i]->clear();
|
||||
}
|
||||
THREAD_MEM_TRACKER_TRANSFER_FROM(_mem_tracker->consumption(), _mem_tracker.get());
|
||||
}
|
||||
|
||||
} // namespace doris
|
||||
|
||||
Reference in New Issue
Block a user