gavinchou commented on code in PR #64381:
URL: https://github.com/apache/doris/pull/64381#discussion_r3880601627
##########
be/src/io/cache/lru_queue_recorder.cpp:
##########
@@ -137,4 +169,34 @@ void
LRUQueueRecorder::reset_lru_queue_update_cnt_from_last_dump(FileCacheType t
_lru_queue_update_cnt_from_last_dump[type] = 0;
}
+size_t LRUQueueRecorder::lru_log_queue_size(FileCacheType type) const {
+ return
_lru_log_queue_size[file_cache_type_index(type)].load(std::memory_order_relaxed);
+}
+
+bool LRUQueueRecorder::reserve_lru_log_queue_slot(FileCacheType type) {
+ int64_t queue_limit = config::file_cache_background_lru_log_queue_max_size;
+ if (queue_limit <= 0) {
+ return false;
+ }
+ auto& queue_size = _lru_log_queue_size[file_cache_type_index(type)];
+ size_t cur_size = queue_size.load(std::memory_order_relaxed);
+ while (cur_size < static_cast<size_t>(queue_limit)) {
+ if (queue_size.compare_exchange_weak(cur_size, cur_size + 1,
std::memory_order_relaxed)) {
+ return true;
+ }
+ }
+ return false;
+}
+
+void LRUQueueRecorder::release_lru_log_queue_slot(FileCacheType type) {
+ auto& queue_size = _lru_log_queue_size[file_cache_type_index(type)];
+ size_t cur_size = queue_size.load(std::memory_order_relaxed);
+ while (true) {
+ DORIS_CHECK_GT(cur_size, 0);
+ if (queue_size.compare_exchange_weak(cur_size, cur_size - 1,
std::memory_order_relaxed)) {
+ return;
+ }
Review Comment:
queue_size.fetch_sub(1)
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]