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.
This commit is contained in:
seelabs
2020-12-16 18:08:04 -05:00
committed by Nik Bougalis
parent 28ed2b9e69
commit 7b192945eb
2 changed files with 1 additions and 46 deletions

View File

@@ -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&

View File

@@ -23,18 +23,7 @@
#include <array>
// #define FORCE_BOOST_POOL 1
#if FORCE_BOOST_POOL || !__has_include(<memory_resource>)
#define USE_BOOST_POOL 1
#else
#define USE_BOOST_POOL 0
#endif
#if USE_BOOST_POOL
#include <boost/pool/pool_alloc.hpp>
#else
#include <memory_resource>
#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::size_t... I>
std::array<std::function<void*()>, boundaries.size()> initAllocateArrayFuns(
std::index_sequence<I...>)
@@ -171,38 +158,6 @@ deallocateArrays(std::uint8_t boundaryIndex, void* p)
assert(isFromArrayFuns[boundaryIndex](p));
freeArrayFuns[boundaryIndex](p);
}
#else
template <std::size_t... I>
std::array<std::pmr::synchronized_pool_resource, boundaries.size()>
initPmrArrayFuns(std::index_sequence<I...>)
{
return std::array<std::pmr::synchronized_pool_resource, boundaries.size()>{
std::pmr::synchronized_pool_resource{std::pmr::pool_options{
/* max_blocks_per_chunk */ chunksPerBlock[I],
/* largest_required_pool_block */ chunksPerBlock[I]}}...,
};
}
std::array<std::pmr::synchronized_pool_resource, boundaries.size()>
pmrArrayFuns =
initPmrArrayFuns(std::make_index_sequence<boundaries.size()>{});
// This function returns an untagged pointer
[[nodiscard]] inline std::pair<std::uint8_t, void*>
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)