]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: make BufferSpace smaller
authorSage Weil <sage@redhat.com>
Tue, 4 Oct 2016 22:14:16 +0000 (18:14 -0400)
committerSage Weil <sage@redhat.com>
Tue, 4 Oct 2016 22:14:16 +0000 (18:14 -0400)
Saves 24 bytes!

BufferSpace  104 -> 80 bytes
SharedBlob   216 -> 192 bytes

Signed-off-by: Sage Weil <sage@redhat.com>
src/os/bluestore/BlueStore.h

index 20e8e929fd31c8a93d7f87b476cb3c94c0767725..74a3257cbe9c5e6ef303756327dad86344bcd7e4 100644 (file)
@@ -207,7 +207,23 @@ public:
 
     map<uint64_t,std::unique_ptr<Buffer>> buffer_map;
     Cache *cache;
-    map<uint64_t, state_list_t> writing_map;
+
+    // we use a list here instead of std::map because it uses less memory and
+    // we expect this to be very small (very few IOs in flight to the same
+    // Blob at the same time).
+    list<pair<uint64_t,state_list_t>> writing_map;
+
+    list<pair<uint64_t,state_list_t>>::iterator get_writing_map(uint64_t seq) {
+      for (auto p = writing_map.begin(); p != writing_map.end(); ++p) {
+       if (p->first == seq) {
+         return p;
+       }
+      }
+      writing_map.push_back(make_pair(seq, state_list_t()));
+      auto p = writing_map.end();
+      --p;
+      return p;
+    }
 
     BufferSpace(Cache *c) : cache(c) {
       if (cache) {
@@ -226,7 +242,7 @@ public:
       cache->_audit("_add_buffer start");
       buffer_map[b->offset].reset(b);
       if (b->is_writing()) {
-        writing_map[b->seq].push_back(*b);
+        get_writing_map(b->seq)->second.push_back(*b);
       } else {
        cache->_add_buffer(b, level, near);
       }
@@ -239,11 +255,12 @@ public:
       cache->_audit("_rm_buffer start");
       if (p->second->is_writing()) {
         uint64_t seq = (*p->second.get()).seq;
-        auto it = writing_map.find(seq);
-        assert(it != writing_map.end());
+        auto it = get_writing_map(seq);
+        assert(!it->second.empty());
         it->second.erase(it->second.iterator_to(*p->second));
-        if (it->second.empty())
+        if (it->second.empty()) {
           writing_map.erase(it);
+       }
       } else {
        cache->_rm_buffer(p->second.get());
       }