]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
Fix read performance regression in ObjectCacher 2672/head
authorAdam Crume <adamcrume@gmail.com>
Wed, 8 Oct 2014 00:45:53 +0000 (17:45 -0700)
committerAdam Crume <adamcrume@gmail.com>
Wed, 8 Oct 2014 00:45:53 +0000 (17:45 -0700)
The regression was introduced in commit
4fc9fffc494abedac0a9b1ce44706343f18466f1.  The problem is that the cache
thinks it's full (when it's not), so it defers the read.  This change
frees up cache space if necessary and only defers the read if enough
space cannot be freed.

Fixes: 9513
Signed-off-by: Adam Crume <adamcrume@gmail.com>
src/osdc/ObjectCacher.cc
src/osdc/ObjectCacher.h

index 93cede5b7b802daf606c3a35f3a0e136fb77a883..2579cb3797dedb5d3691a7310778284e612a72f1 100644 (file)
@@ -950,14 +950,14 @@ void ObjectCacher::flush(loff_t amount)
 }
 
 
-void ObjectCacher::trim()
+void ObjectCacher::trim(uint64_t extra_space)
 {
   assert(lock.is_locked());
   ldout(cct, 10) << "trim  start: bytes: max " << max_size << "  clean " << get_stat_clean()
                 << ", objects: max " << max_objects << " current " << ob_lru.lru_get_size()
                 << dendl;
 
-  while (get_stat_clean() > 0 && (uint64_t) get_stat_clean() > max_size) {
+  while (get_stat_clean() > 0 && (uint64_t) (get_stat_clean() + get_stat_rx() + extra_space) > max_size) {
     BufferHead *bh = static_cast<BufferHead*>(bh_lru_rest.lru_expire());
     if (!bh)
       break;
@@ -1115,6 +1115,10 @@ int ObjectCacher::_readx(OSDRead *rd, ObjectSet *oset, Context *onfinish,
            ++bh_it) {
         loff_t clean = get_stat_clean() + get_stat_rx() +
                        bh_it->second->length();
+       if (get_stat_rx() > 0 && static_cast<uint64_t>(clean) > max_size) {
+         trim(bh_it->second->length());
+       }
+       clean = get_stat_clean() + get_stat_rx() + bh_it->second->length();
         if (get_stat_rx() > 0 && static_cast<uint64_t>(clean) > max_size) {
           // cache is full -- wait for rx's to complete
           ldout(cct, 10) << "readx missed, waiting on cache to free "
index 9685ee3838bedf0aa111ce426436f1927eb8b9cd..871c8eb2de1d9e62cc218af539c0bc084291228a 100644 (file)
@@ -435,7 +435,7 @@ class ObjectCacher {
   void bh_read(BufferHead *bh);
   void bh_write(BufferHead *bh);
 
-  void trim();
+  void trim(uint64_t extra_space = 0);
   void flush(loff_t amount=0);
 
   /**