From 91be5317da05dea8f8cf9695b2059a72c4c151c4 Mon Sep 17 00:00:00 2001 From: Xuehan Xu Date: Sat, 6 Jan 2018 10:40:33 +0800 Subject: [PATCH] common: compute SimpleLRU's size with contents.size() instead of lru.size() As libstdc++ earlier than version 5 implement the list::size() as a O(n) operation, this should be needed to avoid regression of various ceph component's performance. Signed-off-by: Xuehan Xu (cherry picked from commit 7e0a27a5c8b7d12d378de4d700ed7a95af7860c3) --- src/common/simple_cache.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/simple_cache.hpp b/src/common/simple_cache.hpp index 1ff4ae911cdc..4006576d00bd 100644 --- a/src/common/simple_cache.hpp +++ b/src/common/simple_cache.hpp @@ -27,7 +27,7 @@ class SimpleLRU { map pinned; void trim_cache() { - while (lru.size() > max_size) { + while (contents.size() > max_size) { contents.erase(lru.back().first); lru.pop_back(); } -- 2.47.3