From 7b192945eb8378d6e3e245f76a15dc21a123736a Mon Sep 17 00:00:00 2001 From: seelabs Date: Wed, 16 Dec 2020 18:08:04 -0500 Subject: [PATCH] Replace std::pmr with boost::pmr: gcc's implementation of `prm::synchronized_pool_resource` showed extremely poor performance compared with `boost::synchronized_pool_resouece`. Boost's implementation of pmr is now used in all cases (previously it was only used when a standard lib, like clang's, lacked an implementation of pmr). This patch also makes a minor change where inner nodes are constructed with sparse arrays, unless "dense" is explicitly requested. --- src/ripple/shamap/SHAMapInnerNode.h | 2 +- src/ripple/shamap/impl/TaggedPointer.ipp | 45 ------------------------ 2 files changed, 1 insertion(+), 46 deletions(-) diff --git a/src/ripple/shamap/SHAMapInnerNode.h b/src/ripple/shamap/SHAMapInnerNode.h index 43328eb6b..db7244e70 100644 --- a/src/ripple/shamap/SHAMapInnerNode.h +++ b/src/ripple/shamap/SHAMapInnerNode.h @@ -103,7 +103,7 @@ private: public: explicit SHAMapInnerNode( std::uint32_t cowid, - std::uint8_t numAllocatedChildren = branchFactor); + std::uint8_t numAllocatedChildren = 2); SHAMapInnerNode(SHAMapInnerNode const&) = delete; SHAMapInnerNode& diff --git a/src/ripple/shamap/impl/TaggedPointer.ipp b/src/ripple/shamap/impl/TaggedPointer.ipp index c97b7433e..62e43cfe0 100644 --- a/src/ripple/shamap/impl/TaggedPointer.ipp +++ b/src/ripple/shamap/impl/TaggedPointer.ipp @@ -23,18 +23,7 @@ #include -// #define FORCE_BOOST_POOL 1 -#if FORCE_BOOST_POOL || !__has_include() -#define USE_BOOST_POOL 1 -#else -#define USE_BOOST_POOL 0 -#endif - -#if USE_BOOST_POOL #include -#else -#include -#endif namespace ripple { @@ -102,8 +91,6 @@ boundariesIndex(std::uint8_t numChildren) std::lower_bound(boundaries.begin(), boundaries.end(), numChildren)); } -#if USE_BOOST_POOL - template std::array, boundaries.size()> initAllocateArrayFuns( std::index_sequence) @@ -171,38 +158,6 @@ deallocateArrays(std::uint8_t boundaryIndex, void* p) assert(isFromArrayFuns[boundaryIndex](p)); freeArrayFuns[boundaryIndex](p); } -#else - -template -std::array - initPmrArrayFuns(std::index_sequence) -{ - return std::array{ - std::pmr::synchronized_pool_resource{std::pmr::pool_options{ - /* max_blocks_per_chunk */ chunksPerBlock[I], - /* largest_required_pool_block */ chunksPerBlock[I]}}..., - }; -} -std::array - pmrArrayFuns = - initPmrArrayFuns(std::make_index_sequence{}); - -// This function returns an untagged pointer -[[nodiscard]] inline std::pair -allocateArrays(std::uint8_t numChildren) -{ - auto const i = boundariesIndex(numChildren); - return {i, pmrArrayFuns[i].allocate(arrayChunkSizeBytes[i])}; -} - -// This function takes an untagged pointer -inline void -deallocateArrays(std::uint8_t boundaryIndex, void* p) -{ - return pmrArrayFuns[boundaryIndex].deallocate( - p, arrayChunkSizeBytes[boundaryIndex]); -} -#endif [[nodiscard]] inline int popcnt16(std::uint16_t a)