diff --git a/cmake/module/AddBoostIfNeeded.cmake b/cmake/module/AddBoostIfNeeded.cmake index ecd0d6f2aba..5cf2f8b0c46 100644 --- a/cmake/module/AddBoostIfNeeded.cmake +++ b/cmake/module/AddBoostIfNeeded.cmake @@ -26,7 +26,7 @@ function(add_boost_if_needed) cmake_policy(SET CMP0167 OLD) endif() set(Boost_NO_BOOST_CMAKE ON) - find_package(Boost 1.73.0 REQUIRED) + find_package(Boost 1.82.0 REQUIRED) mark_as_advanced(Boost_INCLUDE_DIR) set_target_properties(Boost::headers PROPERTIES IMPORTED_GLOBAL TRUE) target_compile_definitions(Boost::headers INTERFACE diff --git a/doc/dependencies.md b/doc/dependencies.md index 7c866a433db..23fc2b5214a 100644 --- a/doc/dependencies.md +++ b/doc/dependencies.md @@ -18,7 +18,7 @@ Bitcoin Core requires one of the following compilers. | Dependency | Releases | Version used | Minimum required | Runtime | | --- | --- | --- | --- | --- | | CMake | [link](https://cmake.org/) | N/A | [3.22](https://github.com/bitcoin/bitcoin/pull/30454) | No | -| [Boost](../depends/packages/boost.mk) | [link](https://www.boost.org/users/download/) | [1.81.0](https://github.com/bitcoin/bitcoin/pull/26557) | [1.73.0](https://github.com/bitcoin/bitcoin/pull/29066) | No | +| [Boost](../depends/packages/boost.mk) | [link](https://www.boost.org/users/download/) | [1.82.0](https://github.com/bitcoin/bitcoin/pull/26557) | [1.82.0](https://github.com/bitcoin/bitcoin/pull/29066) | No | | [libevent](../depends/packages/libevent.mk) | [link](https://github.com/libevent/libevent/releases) | [2.1.12-stable](https://github.com/bitcoin/bitcoin/pull/21991) | [2.1.8](https://github.com/bitcoin/bitcoin/pull/24681) | No | | glibc | [link](https://www.gnu.org/software/libc/) | N/A | [2.31](https://github.com/bitcoin/bitcoin/pull/29987) | Yes | | Linux Kernel (if building that platform) | [link](https://www.kernel.org/) | N/A | [3.17.0](https://github.com/bitcoin/bitcoin/pull/27699) | Yes | diff --git a/src/coins.h b/src/coins.h index 61fb4af6420..704ab3d6560 100644 --- a/src/coins.h +++ b/src/coins.h @@ -15,6 +15,7 @@ #include #include #include +#include #include #include @@ -221,12 +222,12 @@ public: * Using an additional sizeof(void*)*4 for MAX_BLOCK_SIZE_BYTES should thus be sufficient so that * all implementations can allocate the nodes from the PoolAllocator. */ -using CCoinsMap = std::unordered_map, - PoolAllocator>; +using CCoinsMap = boost::unordered_node_map, + PoolAllocator>; using CCoinsMapMemoryResource = CCoinsMap::allocator_type::ResourceType; diff --git a/src/memusage.h b/src/memusage.h index 9d9e549ef22..c0945e3fce0 100644 --- a/src/memusage.h +++ b/src/memusage.h @@ -19,6 +19,7 @@ #include #include #include +#include namespace memusage @@ -215,6 +216,25 @@ static inline size_t DynamicUsage(const std::unordered_map +static inline size_t DynamicUsage(const boost::unordered_node_map, + MAX_BLOCK_SIZE_BYTES, + ALIGN_BYTES>>& m) +{ + auto* pool_resource = m.get_allocator().resource(); + + // The allocated chunks are stored in a std::list. Size per node should + // therefore be 3 pointers: next, previous, and a pointer to the chunk. + size_t estimated_list_node_size = MallocUsage(sizeof(void*) * 3); + size_t usage_resource = estimated_list_node_size * pool_resource->NumAllocatedChunks(); + size_t usage_chunks = MallocUsage(pool_resource->ChunkSizeBytes()) * pool_resource->NumAllocatedChunks(); + return usage_resource + usage_chunks + MallocUsage(sizeof(void*) * m.bucket_count()); +} + } // namespace memusage #endif // BITCOIN_MEMUSAGE_H diff --git a/src/test/pool_tests.cpp b/src/test/pool_tests.cpp index 9d15660126a..834b05c4c5a 100644 --- a/src/test/pool_tests.cpp +++ b/src/test/pool_tests.cpp @@ -158,7 +158,7 @@ BOOST_AUTO_TEST_CASE(memusage_test) { auto std_map = std::unordered_map{}; - using Map = std::unordered_map, std::equal_to, diff --git a/src/util/hasher.h b/src/util/hasher.h index 050e089300d..4b379660193 100644 --- a/src/util/hasher.h +++ b/src/util/hasher.h @@ -35,6 +35,10 @@ private: const uint64_t k0, k1; public: + // instructs Boost.Unordered to not use post-mixing. We can do this because the hash is of high quality. + // This should have a slight performance benefit. + using is_avalanching = std::true_type; + SaltedOutpointHasher(bool deterministic = false); /**