From 8a0bf61c5a9d2c71399a6facb8d2da428abf2070 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Tue, 27 Nov 2018 12:08:28 +0800 Subject: [PATCH] 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 --- src/include/denc.h | 9 ++++++++- src/include/interval_set.h | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/include/denc.h b/src/include/denc.h index d4733f09c8499..081df4b665606 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 825bcf2e4d787..4fb6be45a9e6b 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; -- 2.39.5