From: Yan, Zheng Date: Sun, 11 May 2014 01:53:44 +0000 (+0800) Subject: mds: revert EMetaBlob::{fullbit,remotebit,nullbit} encoding optimization X-Git-Tag: v0.81~15^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=59f539c105c927d405a2777451944ae149b62054;p=ceph.git mds: revert EMetaBlob::{fullbit,remotebit,nullbit} encoding optimization 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 --- diff --git a/src/mds/events/EMetaBlob.h b/src/mds/events/EMetaBlob.h index fb34697c6517..4d52b7fb73a7 100644 --- a/src/mds/events/EMetaBlob.h +++ b/src/mds/events/EMetaBlob.h @@ -74,8 +74,6 @@ public: typedef map 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 &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) {} diff --git a/src/mds/journal.cc b/src/mds/journal.cc index 72c2f4ba3541..44e51840c1e7 100644 --- a/src/mds/journal.cc +++ b/src/mds/journal.cc @@ -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(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(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& 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(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);