From: Kefu Chai Date: Tue, 27 Nov 2018 04:08:28 +0000 (+0800) Subject: denc: only shallow_copy large-enough chunk for decoding X-Git-Tag: v14.1.0~772^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=8a0bf61c5a9d2c71399a6facb8d2da428abf2070;p=ceph.git denc: only shallow_copy large-enough chunk for decoding if the bl being decoded is not continous, shallow_copy() will do deep copy under the hood. this introduces internal fragmentation when decoding small objects in large non-contiguous bufferlist. to alleviate this problem, we try to copy less if the object being decoded is bounded. Signed-off-by: Kefu Chai --- diff --git a/src/include/denc.h b/src/include/denc.h index d4733f09c849..081df4b66560 100644 --- a/src/include/denc.h +++ b/src/include/denc.h @@ -1592,7 +1592,14 @@ inline std::enable_if_t decode_nohead( if constexpr (traits::need_contiguous) { bufferptr tmp; auto t = p; - t.copy_shallow(p.get_bl().length() - p.get_off(), tmp); + if constexpr (denc_traits::bounded) { + size_t element_size = 0; + typename T::value_type v; + denc_traits::bound_encode(v, element_size); + t.copy_shallow(num * element_size, tmp); + } else { + t.copy_shallow(p.get_bl().length() - p.get_off(), tmp); + } auto cp = std::cbegin(tmp); traits::decode_nohead(num, o, cp); p.advance(cp.get_offset()); diff --git a/src/include/interval_set.h b/src/include/interval_set.h index 825bcf2e4d78..4fb6be45a9e6 100644 --- a/src/include/interval_set.h +++ b/src/include/interval_set.h @@ -33,6 +33,7 @@ template> class interval_set { public: + using value_type = T; class const_iterator;