From 45a7c7e822d10f67a74380198095baef28aac79e Mon Sep 17 00:00:00 2001 From: sageweil Date: Sun, 9 Sep 2007 16:10:35 +0000 Subject: [PATCH] buffer performance improvements git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@1792 29311d96-e01e-0410-9327-a35deaab8ce9 --- trunk/ceph/include/buffer.h | 16 +++++++++++++--- trunk/ceph/osdc/Objecter.cc | 7 ++----- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/trunk/ceph/include/buffer.h b/trunk/ceph/include/buffer.h index 3f3650f4162e2..0e165cec82b51 100644 --- a/trunk/ceph/include/buffer.h +++ b/trunk/ceph/include/buffer.h @@ -338,6 +338,7 @@ public: bool is_page_aligned() const { return (long)c_str() % BUFFER_PAGE_SIZE == 0; } // accessors + raw *get_raw() const { return _raw; } const char *c_str() const { assert(_raw); return _raw->data + _off; } char *c_str() { assert(_raw); return _raw->data + _off; } unsigned length() const { return _len; } @@ -729,8 +730,17 @@ public: } void append(const ptr& bp, unsigned off, unsigned len) { assert(len+off <= bp.length()); - ptr tempbp(bp, off, len); - push_back(tempbp); + if (!_buffers.empty() && + _buffers.back().get_raw() == bp.get_raw() && + _buffers.back().end() == bp.start() + off) { + // yay contiguous with tail bp! + _buffers.back().set_length(_buffers.back().length()+len); + _len += len; + } else { + // add new item to list + ptr tempbp(bp, off, len); + push_back(tempbp); + } } void append(const list& bl) { _len += bl._len; @@ -1108,7 +1118,7 @@ inline void _encode(const std::string& s, bufferlist& bl) { uint32_t len = s.length(); _encoderaw(len, bl); - bl.append(s.c_str(), len); + bl.append(s.data(), len); } inline void _decode(std::string& s, bufferlist& bl, int& off) { diff --git a/trunk/ceph/osdc/Objecter.cc b/trunk/ceph/osdc/Objecter.cc index f19676a9b21fb..9d31d023ed56e 100644 --- a/trunk/ceph/osdc/Objecter.cc +++ b/trunk/ceph/osdc/Objecter.cc @@ -773,11 +773,8 @@ tid_t Objecter::modifyx_submit(OSDModify *wr, ObjectExtent &ex, tid_t usetid) bufferlist cur; for (map::iterator bit = ex.buffer_extents.begin(); bit != ex.buffer_extents.end(); - bit++) { - bufferlist thisbit; - thisbit.substr_of(((OSDWrite*)wr)->bl, bit->first, bit->second); - cur.claim_append(thisbit); - } + bit++) + ((OSDWrite*)wr)->bl.copy(bit->first, bit->second, cur); assert(cur.length() == ex.length); m->set_data(cur);//.claim(cur); } -- 2.39.5