From ecef894525f1083366f6b9f4e714e326a5d8569b Mon Sep 17 00:00:00 2001 From: Matthew Parkinson Date: Mon, 30 Mar 2020 13:40:09 +0100 Subject: [PATCH] Increase Remote batch size (#158) * Increase Remote batch size The remote batch size has not changed since the fast path optimisations. The optimisations mean we are checking the queue considerably less often, so the batch should be larger. This has a dramatic improvement on performance on a few of the mimalloc microbenchmarks. It is set to 4096 as this should cover the worse case scenario of only remote deallocation at 16 bytes for the 2^16 slab size. * Fixes for Clang-10 Clang-10 outputs a warning for calling alignment intrinsic with an alignment of 1. At add constexpr to handle this case. --- src/ds/address.h | 18 ++++++++++++++---- src/mem/allocconfig.h | 2 +- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/ds/address.h b/src/ds/address.h index 49c9b9878..ab896ee68 100644 --- a/src/ds/address.h +++ b/src/ds/address.h @@ -65,11 +65,16 @@ namespace snmalloc { static_assert(alignment > 0); static_assert(bits::next_pow2_const(alignment) == alignment); + if constexpr (alignment == 1) + return static_cast(p); + else + { #if __has_builtin(__builtin_align_down) - return static_cast(__builtin_align_down(p, alignment)); + return static_cast(__builtin_align_down(p, alignment)); #else - return pointer_cast(bits::align_down(address_cast(p), alignment)); + return pointer_cast(bits::align_down(address_cast(p), alignment)); #endif + } } /** @@ -81,11 +86,16 @@ namespace snmalloc { static_assert(alignment > 0); static_assert(bits::next_pow2_const(alignment) == alignment); + if constexpr (alignment == 1) + return static_cast(p); + else + { #if __has_builtin(__builtin_align_up) - return static_cast(__builtin_align_up(p, alignment)); + return static_cast(__builtin_align_up(p, alignment)); #else - return pointer_cast(bits::align_up(address_cast(p), alignment)); + return pointer_cast(bits::align_up(address_cast(p), alignment)); #endif + } } /** diff --git a/src/mem/allocconfig.h b/src/mem/allocconfig.h index f9cf0e94d..2e9bb6d39 100644 --- a/src/mem/allocconfig.h +++ b/src/mem/allocconfig.h @@ -35,7 +35,7 @@ namespace snmalloc #ifdef USE_REMOTE_BATCH REMOTE_BATCH #else - 64 + 4096 #endif ;