]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
denc: only shallow_copy large-enough chunk for decoding
authorKefu Chai <kchai@redhat.com>
Tue, 27 Nov 2018 04:08:28 +0000 (12:08 +0800)
committerKefu Chai <kchai@redhat.com>
Tue, 27 Nov 2018 16:33:53 +0000 (00:33 +0800)
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 <kchai@redhat.com>
src/include/denc.h
src/include/interval_set.h

index d4733f09c8499cdbabf62531cf959a0bedb1369c..081df4b665606ac1ced3dfafb8062319d1348531 100644 (file)
@@ -1592,7 +1592,14 @@ inline std::enable_if_t<traits::supported && !traits::featured> 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<typename T::value_type>::bounded) {
+      size_t element_size = 0;
+      typename T::value_type v;
+      denc_traits<typename T::value_type>::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());
index 825bcf2e4d787ccaf304a603c60fd05dab1efc25..4fb6be45a9e6be62ec2b92b8b32aeab5bf15efac 100644 (file)
@@ -33,6 +33,7 @@
 template<typename T, typename Map = std::map<T,T>>
 class interval_set {
  public:
+  using value_type = T;
 
   class const_iterator;