]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common: compute SimpleLRU's size with contents.size() instead of lru.size() 19978/head
authorXuehan Xu <xuxuehan@360.cn>
Sat, 6 Jan 2018 02:40:33 +0000 (10:40 +0800)
committerPrashant D <pdhange@redhat.com>
Wed, 17 Jan 2018 04:23:26 +0000 (23:23 -0500)
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 <xuxuehan@360.cn>
(cherry picked from commit 7e0a27a5c8b7d12d378de4d700ed7a95af7860c3)

src/common/simple_cache.hpp

index 362763253becff3bf64ea1fbc4f914a6c6867ad8..1e37887ecc2b9e6cbdf47e59ab2fee5212539b3c 100644 (file)
@@ -31,7 +31,7 @@ class SimpleLRU {
   map<K, V, C> pinned;
 
   void trim_cache() {
-    while (lru.size() > max_size) {
+    while (contents.size() > max_size) {
       contents.erase(lru.back().first);
       lru.pop_back();
     }