]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common: compute SimpleLRU's size with contents.size() instead of lru.size() 19813/head
authorXuehan Xu <xuxuehan@360.cn>
Sat, 6 Jan 2018 02:40:33 +0000 (10:40 +0800)
committerXuehan Xu <xuxuehan@360.cn>
Sat, 6 Jan 2018 02:42:32 +0000 (10:42 +0800)
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>
src/common/simple_cache.hpp

index 1ff4ae911cdc5b48461a53e3c7f4ffc0c7697100..4006576d00bd5184fdf2f24da799b07830044091 100644 (file)
@@ -27,7 +27,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();
     }