From 5176ced98b172f0f13315de4df833024882db19c Mon Sep 17 00:00:00 2001 From: Radoslaw Zarzynski Date: Tue, 23 Oct 2018 11:31:31 +0200 Subject: [PATCH] common: make CEPH_BUFFER_ALLOC_UNIT known at compile-time. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit It sounds extremely unlikely that any platform Ceph targets can have PAGE_SIZE lower than 4k. However, to handle these corner cases, `bufferlist` was rounding to `CEPH_PAGE_SIZE` known at run-time only. As a result, compilers were enforced to generate pretty inefficient code like in `ceph::buffer::list::refill_append_space` (self is 1,10%): ``` │ min(const _Tp& __a, const _Tp& __b) │ { │ // concept requirements │ __glibcxx_function_requires(_LessThanComparableConcept<_Tp>) │ //return __b < __a ? __b : __a; │ if (__b < __a) 5,44 │ mov _DYNAMIC+0x14a0,%rax │ _Z11round_up_toImjENSt13make_unsignedINSt11common_typeIJT_T0_EE4typeEE4typeES2_S3_(): │ mov $0x1000,%ecx │ _ZN4ceph6buffer4list19refill_append_spaceEj(): │ size_t alen = round_up_to(need, CEPH_BUFFER_ALLOC_UNIT) - │ sizeof(raw_combined); │ buffer::hangable_ptr& new_back = \ │ hangable_ptr::create(raw_combined::create(alen, 0, get_mempool())); │ mov %rbp,%rdi │ _Z11round_up_toImjENSt13make_unsignedINSt11common_typeIJT_T0_EE4typeEE4typeES2_S3_(): 6,21 │ cmpl $0x1000,(%rax) 0,78 │ cmovbe (%rax),%ecx │ mov %r12,%rax │ xor %edx,%edx 0,78 │ mov %ecx,%ecx 45,59 │ div %rcx ``` Signed-off-by: Radoslaw Zarzynski --- src/common/buffer.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/buffer.cc b/src/common/buffer.cc index 3c85f7492437..42de2b1c76cd 100644 --- a/src/common/buffer.cc +++ b/src/common/buffer.cc @@ -41,7 +41,7 @@ using namespace ceph; -#define CEPH_BUFFER_ALLOC_UNIT (std::min(CEPH_PAGE_SIZE, 4096u)) +#define CEPH_BUFFER_ALLOC_UNIT 4096u #define CEPH_BUFFER_APPEND_SIZE (CEPH_BUFFER_ALLOC_UNIT - sizeof(raw_combined)) #ifdef BUFFER_DEBUG -- 2.47.3