]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: revert EMetaBlob::{fullbit,remotebit,nullbit} encoding optimization
authorYan, Zheng <zheng.z.yan@intel.com>
Sun, 11 May 2014 01:53:44 +0000 (09:53 +0800)
committerYan, Zheng <zheng.z.yan@intel.com>
Mon, 12 May 2014 03:26:15 +0000 (11:26 +0800)
Revert commit 40d56a97 (mds: optimize EMetaBlob::fullbit, remotebit,
nullbit encoding). This optimization creates small segments in the
result bufferlist of encoding EMetaBlob. Perf shows lots of CPU time
are used for allocating list node for bufferlist.

Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
src/mds/events/EMetaBlob.h
src/mds/journal.cc

index fb34697c65170d67534836aa7cf689fd0782409b..4d52b7fb73a70f887d64932009095f341ce7ad92 100644 (file)
@@ -74,8 +74,6 @@ public:
     typedef map<snapid_t, old_inode_t> old_inodes_t;
     old_inodes_t old_inodes;
 
-    bufferlist _enc;
-
     fullbit(const fullbit& o);
     const fullbit& operator=(const fullbit& o);
 
@@ -84,26 +82,16 @@ public:
            const map<string,bufferptr> &xa, const string& sym,
            const bufferlist &sbl, __u8 st,
            const old_inodes_t *oi = NULL) :
-      //dn(d), dnfirst(df), dnlast(dl), dnv(v), 
-      //inode(i), dirfragtree(dft), xattrs(xa), symlink(sym), snapbl(sbl), dirty(dr) 
-      _enc(1024)
+      dn(d), dnfirst(df), dnlast(dl), dnv(v), inode(i), xattrs(xa), state(st)
     {
-      ::encode(d, _enc);
-      ::encode(df, _enc);
-      ::encode(dl, _enc);
-      ::encode(v, _enc);
-      ::encode(i, _enc);
-      ::encode(xa, _enc);
       if (i.is_symlink())
-       ::encode(sym, _enc);
+       symlink = sym;
       if (i.is_dir()) {
-       ::encode(dft, _enc);
-       ::encode(sbl, _enc);
+       dirfragtree = dft;
+       snapbl = sbl;
       }
-      ::encode(st, _enc);
-      ::encode(oi ? true : false, _enc);
       if (oi)
-       ::encode(*oi, _enc);
+       old_inodes = *oi;
     }
     fullbit(bufferlist::iterator &p) {
       decode(p);
@@ -153,19 +141,8 @@ public:
     unsigned char d_type;
     bool dirty;
 
-    bufferlist _enc;
-
     remotebit(const string& d, snapid_t df, snapid_t dl, version_t v, inodeno_t i, unsigned char dt, bool dr) : 
-      //dn(d), dnfirst(df), dnlast(dl), dnv(v), ino(i), d_type(dt), dirty(dr) { }
-      _enc(256) {
-      ::encode(d, _enc);
-      ::encode(df, _enc);
-      ::encode(dl, _enc);
-      ::encode(v, _enc);
-      ::encode(i, _enc);
-      ::encode(dt, _enc);
-      ::encode(dr, _enc);
-    }
+      dn(d), dnfirst(df), dnlast(dl), dnv(v), ino(i), d_type(dt), dirty(dr) { }
     remotebit(bufferlist::iterator &p) { decode(p); }
     remotebit(): dnfirst(0), dnlast(0), dnv(0), ino(0),
        d_type('\0'), dirty(false) {}
@@ -191,17 +168,8 @@ public:
     version_t dnv;
     bool dirty;
 
-    bufferlist _enc;
-
     nullbit(const string& d, snapid_t df, snapid_t dl, version_t v, bool dr) : 
-      //dn(d), dnfirst(df), dnlast(dl), dnv(v), dirty(dr) { }
-      _enc(128) {
-      ::encode(d, _enc);
-      ::encode(df, _enc);
-      ::encode(dl, _enc);
-      ::encode(v, _enc);
-      ::encode(dr, _enc);
-    }
+      dn(d), dnfirst(df), dnlast(dl), dnv(v), dirty(dr) { }
     nullbit(bufferlist::iterator &p) { decode(p); }
     nullbit(): dnfirst(0), dnlast(0), dnv(0), dirty(false) {}
 
index 72c2f4ba3541323e967e2ab8f7765c47b893e2cf..44e51840c1e7aba603190edb719836fab1ff99e4 100644 (file)
@@ -399,12 +399,24 @@ void EMetaBlob::update_segment(LogSegment *ls)
 
 void EMetaBlob::fullbit::encode(bufferlist& bl) const {
   ENCODE_START(6, 5, bl);
-  if (!_enc.length()) {
-    fullbit copy(dn, dnfirst, dnlast, dnv, inode, dirfragtree, xattrs, symlink,
-                snapbl, state, &old_inodes);
-    bl.append(copy._enc);
+  ::encode(dn, bl);
+  ::encode(dnfirst, bl);
+  ::encode(dnlast, bl);
+  ::encode(dnv, bl);
+  ::encode(inode, bl);
+  ::encode(xattrs, bl);
+  if (inode.is_symlink())
+    ::encode(symlink, bl);
+  if (inode.is_dir()) {
+    ::encode(dirfragtree, bl);
+    ::encode(snapbl, bl);
+  }
+  ::encode(state, bl);
+  if (old_inodes.empty()) {
+    ::encode(false, bl);
   } else {
-    bl.append(_enc);
+    ::encode(true, bl);
+    ::encode(old_inodes, bl);
   }
   ENCODE_FINISH(bl);
 }
@@ -452,19 +464,6 @@ void EMetaBlob::fullbit::decode(bufferlist::iterator &bl) {
 
 void EMetaBlob::fullbit::dump(Formatter *f) const
 {
-  if (_enc.length() && !dn.length()) {
-    /* if our bufferlist has data but our name is empty, we
-     * haven't initialized ourselves; do so in order to print members!
-     * We use const_cast here because the whole point is we aren't
-     * fully set up and this isn't changing who we "are", just our
-     * representation.
-     */
-    EMetaBlob::fullbit *me = const_cast<EMetaBlob::fullbit*>(this);
-    bufferlist encoded;
-    encode(encoded);
-    bufferlist::iterator p = encoded.begin();
-    me->decode(p);
-  }
   f->dump_string("dentry", dn);
   f->dump_stream("snapid.first") << dnfirst;
   f->dump_stream("snapid.last") << dnlast;
@@ -558,12 +557,13 @@ void EMetaBlob::fullbit::update_inode(MDS *mds, CInode *in)
 void EMetaBlob::remotebit::encode(bufferlist& bl) const
 {
   ENCODE_START(2, 2, bl);
-  if (!_enc.length()) {
-    remotebit copy(dn, dnfirst, dnlast, dnv, ino, d_type, dirty);
-    bl.append(copy._enc);
-  } else {
-    bl.append(_enc);
-  }
+  ::encode(dn, bl);
+  ::encode(dnfirst, bl);
+  ::encode(dnlast, bl);
+  ::encode(dnv, bl);
+  ::encode(ino, bl);
+  ::encode(d_type, bl);
+  ::encode(dirty, bl);
   ENCODE_FINISH(bl);
 }
 
@@ -582,19 +582,6 @@ void EMetaBlob::remotebit::decode(bufferlist::iterator &bl)
 
 void EMetaBlob::remotebit::dump(Formatter *f) const
 {
-  if (_enc.length() && !dn.length()) {
-    /* if our bufferlist has data but our name is empty, we
-     * haven't initialized ourselves; do so in order to print members!
-     * We use const_cast here because the whole point is we aren't
-     * fully set up and this isn't changing who we "are", just our
-     * representation.
-     */
-    EMetaBlob::remotebit *me = const_cast<EMetaBlob::remotebit*>(this);
-    bufferlist encoded;
-    encode(encoded);
-    bufferlist::iterator p = encoded.begin();
-    me->decode(p);
-  }
   f->dump_string("dentry", dn);
   f->dump_int("snapid.first", dnfirst);
   f->dump_int("snapid.last", dnlast);
@@ -636,12 +623,11 @@ generate_test_instances(list<EMetaBlob::remotebit*>& ls)
 void EMetaBlob::nullbit::encode(bufferlist& bl) const
 {
   ENCODE_START(2, 2, bl);
-  if (!_enc.length()) {
-    nullbit copy(dn, dnfirst, dnlast, dnv, dirty);
-    bl.append(copy._enc);
-  } else {
-    bl.append(_enc);
-  }
+  ::encode(dn, bl);
+  ::encode(dnfirst, bl);
+  ::encode(dnlast, bl);
+  ::encode(dnv, bl);
+  ::encode(dirty, bl);
   ENCODE_FINISH(bl);
 }
 
@@ -658,19 +644,6 @@ void EMetaBlob::nullbit::decode(bufferlist::iterator &bl)
 
 void EMetaBlob::nullbit::dump(Formatter *f) const
 {
-  if (_enc.length() && !dn.length()) {
-    /* if our bufferlist has data but our name is empty, we
-     * haven't initialized ourselves; do so in order to print members!
-     * We use const_cast here because the whole point is we aren't
-     * fully set up and this isn't changing who we "are", just our
-     * representation.
-     */
-    EMetaBlob::nullbit *me = const_cast<EMetaBlob::nullbit*>(this);
-    bufferlist encoded;
-    encode(encoded);
-    bufferlist::iterator p = encoded.begin();
-    me->decode(p);
-  }
   f->dump_string("dentry", dn);
   f->dump_int("snapid.first", dnfirst);
   f->dump_int("snapid.last", dnlast);