]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
buffer: Add _memcopy_count to track total count of memcopy by rebuild/rebuild_page_al...
authorJianpeng Ma <jianpeng.ma@intel.com>
Fri, 24 Oct 2014 08:11:15 +0000 (16:11 +0800)
committerSage Weil <sage@redhat.com>
Wed, 5 Nov 2014 13:12:22 +0000 (05:12 -0800)
Using thie filed, we know the payload of
rebuild/rebuild_page_aligned/c_str and tune performance accroding.

Signed-off-by: Jianpeng Ma <jianpeng.ma@intel.com>
Reviewed-by: Sage Weil <sage@redhat.com>
src/common/buffer.cc
src/include/buffer.h
src/os/FileJournal.cc

index cd434417098992f444f122b02c4ecee712550023..f50d103e479d0c4f85e1a491928fccbb283fc612 100644 (file)
@@ -955,6 +955,7 @@ static simple_spinlock_t buffer_debug_lock = SIMPLE_SPINLOCK_INITIALIZER;
   void buffer::list::swap(list& other)
   {
     std::swap(_len, other._len);
+    std::swap(_memcopy_count, other._memcopy_count);
     _buffers.swap(other._buffers);
     append_buffer.swap(other.append_buffer);
     //last_p.swap(other.last_p);
@@ -1111,6 +1112,7 @@ static simple_spinlock_t buffer_debug_lock = SIMPLE_SPINLOCK_INITIALIZER;
       nb.copy_in(pos, it->length(), it->c_str());
       pos += it->length();
     }
+    _memcopy_count += pos;
     _buffers.clear();
     _buffers.push_back(nb);
   }
@@ -1150,6 +1152,7 @@ void buffer::list::rebuild_aligned(unsigned align)
     if (!(unaligned.is_contiguous() && unaligned._buffers.front().is_aligned(align))) {
       ptr nb(buffer::create_aligned(unaligned._len, align));
       unaligned.rebuild(nb);
+      _memcopy_count += unaligned._len;
     }
     _buffers.insert(p, unaligned._buffers.front());
   }
index 7f23f8db44081c0b69094d4bb70460753ad6d721..0c917302f6b552724180a4753666f902c0ab5508 100644 (file)
@@ -241,7 +241,7 @@ public:
     // my private bits
     std::list<ptr> _buffers;
     unsigned _len;
-
+    unsigned _memcopy_count; //the total of memcopy using rebuild().
     ptr append_buffer;  // where i put small appends.
 
   public:
@@ -317,14 +317,14 @@ public:
 
   public:
     // cons/des
-    list() : _len(0), last_p(this) {}
-    list(unsigned prealloc) : _len(0), last_p(this) {
+    list() : _len(0), _memcopy_count(0), last_p(this) {}
+    list(unsigned prealloc) : _len(0), _memcopy_count(0), last_p(this) {
       append_buffer = buffer::create(prealloc);
       append_buffer.set_length(0);   // unused, so far.
     }
     ~list() {}
     
-    list(const list& other) : _buffers(other._buffers), _len(other._len), last_p(this) { }
+    list(const list& other) : _buffers(other._buffers), _len(other._len), _memcopy_count(other._memcopy_count),last_p(this) { }
     list& operator= (const list& other) {
       if (this != &other) {
         _buffers = other._buffers;
@@ -333,8 +333,8 @@ public:
       return *this;
     }
 
+    unsigned get_memcopy_count() const {return _memcopy_count; }
     const std::list<ptr>& buffers() const { return _buffers; }
-    
     void swap(list& other);
     unsigned length() const {
 #if 0
@@ -363,6 +363,7 @@ public:
     void clear() {
       _buffers.clear();
       _len = 0;
+      _memcopy_count = 0;
       last_p = begin();
     }
     void push_front(ptr& bp) {
index f8f898d5bdd6b47e5dd23fb0213d7ef2408db38d..f97b06b7a81b2e27a9ff67bc21463e07e9f346f3 100644 (file)
@@ -927,6 +927,7 @@ void FileJournal::align_bl(off64_t pos, bufferlist& bl)
   if (directio && (!bl.is_page_aligned() ||
                   !bl.is_n_page_sized())) {
     bl.rebuild_page_aligned();
+    dout(10) << __func__ << " total memcopy: " << bl.get_memcopy_count() << dendl;
     if ((bl.length() & ~CEPH_PAGE_MASK) != 0 ||
        (pos & ~CEPH_PAGE_MASK) != 0)
       dout(0) << "rebuild_page_aligned failed, " << bl << dendl;