Skip to content

Commit b27c801

Browse files
committed
common/fs_types: combine several fixed-size encode() calls
The `denc` library allows appending multiple values in a single `buffer::list` call by wrapping them in a `std::tuple`. This reduces overhead because the buffer bounds checks have to be performed only once. The `file_layout_t` type turned up in the profiler, so it was an obvious choice to optimize now. Signed-off-by: Max Kellermann <[email protected]>
1 parent 99f58a5 commit b27c801

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/common/fs_types.cc

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "common/Formatter.h"
66
#include "include/ceph_features.h"
77
#include "common/ceph_json.h"
8+
#include "include/denc.h"
89

910
void dump(const ceph_file_layout& l, ceph::Formatter *f)
1011
{
@@ -86,10 +87,12 @@ void file_layout_t::encode(ceph::buffer::list& bl, uint64_t features) const
8687
}
8788

8889
ENCODE_START(2, 2, bl);
89-
encode(stripe_unit, bl);
90-
encode(stripe_count, bl);
91-
encode(object_size, bl);
92-
encode(pool_id, bl);
90+
encode(std::tuple{
91+
stripe_unit,
92+
stripe_count,
93+
object_size,
94+
pool_id,
95+
}, bl, 0);
9396
encode(pool_ns, bl);
9497
ENCODE_FINISH(bl);
9598
}

0 commit comments

Comments
 (0)