]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commit
common: make CEPH_BUFFER_ALLOC_UNIT known at compile-time. 26259/head
authorRadoslaw Zarzynski <rzarzyns@redhat.com>
Tue, 23 Oct 2018 09:31:31 +0000 (11:31 +0200)
committerRadoslaw Zarzynski <rzarzyns@redhat.com>
Sun, 3 Feb 2019 21:54:10 +0000 (22:54 +0100)
commit5176ced98b172f0f13315de4df833024882db19c
tree9427299e787940bdefbae3593d5cb4cdd20afe38
parentff3386fd589c31518913691ba81d4e63ae211e8a
common: make CEPH_BUFFER_ALLOC_UNIT known at compile-time.

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 <rzarzyns@redhat.com>
src/common/buffer.cc