From: Xuehan Xu Date: Sat, 6 Jan 2018 02:40:33 +0000 (+0800) Subject: common: compute SimpleLRU's size with contents.size() instead of lru.size() X-Git-Tag: v13.0.2~567^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=7e0a27a5c8b7d12d378de4d700ed7a95af7860c3;p=ceph.git 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 --- diff --git a/src/common/simple_cache.hpp b/src/common/simple_cache.hpp index 1ff4ae911cd..4006576d00b 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(); }