github-actions[bot] commented on code in PR #28171: URL: https://github.com/apache/doris/pull/28171#discussion_r1419922008
########## be/src/olap/memtable_memory_limiter.cpp: ########## @@ -137,16 +140,40 @@ LOG(INFO) << "waited " << time_ms << " ms for memtable memory limit"; } -void MemTableMemoryLimiter::_flush_active_memtables() { - auto writer = _largest_active_writer.lock(); - if (!writer) { +void MemTableMemoryLimiter::_flush_active_memtables(int64_t need_flush) { + if (need_flush <= 0 || _active_writers.size() == 0) { return; } + int64_t mem_flushed = 0; + int64_t num_flushed = 0; + int64_t avg_mem = _active_mem_usage / _active_writers.size(); + for (auto writer : _active_writers) { + int64_t mem = _flush_memtable(writer, avg_mem); + mem_flushed += mem; + num_flushed += (mem > 0); + if (mem_flushed >= need_flush) { + break; + } + } + LOG(INFO) << "flushed " << num_flushed << " out of " << _active_writers.size() + << " active writers, flushed size: " << PrettyPrinter::print_bytes(mem_flushed); +} + +int64_t MemTableMemoryLimiter::_flush_memtable(std::weak_ptr<MemTableWriter> writer_to_flush, int64_t threshold) { Review Comment: warning: method '_flush_memtable' can be made static [readability-convert-member-functions-to-static] be/src/olap/memtable_memory_limiter.h:57: ```diff - int64_t _flush_memtable(std::weak_ptr<MemTableWriter> writer_to_flush, int64_t threshold); + static int64_t _flush_memtable(std::weak_ptr<MemTableWriter> writer_to_flush, int64_t threshold); ``` ########## be/src/olap/memtable_memory_limiter.cpp: ########## @@ -137,16 +140,40 @@ void MemTableMemoryLimiter::handle_memtable_flush() { LOG(INFO) << "waited " << time_ms << " ms for memtable memory limit"; } -void MemTableMemoryLimiter::_flush_active_memtables() { - auto writer = _largest_active_writer.lock(); - if (!writer) { +void MemTableMemoryLimiter::_flush_active_memtables(int64_t need_flush) { Review Comment: warning: method '_flush_active_memtables' can be made static [readability-convert-member-functions-to-static] be/src/olap/memtable_memory_limiter.h:56: ```diff - void _flush_active_memtables(int64_t need_flush); + static void _flush_active_memtables(int64_t need_flush); ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org