From b26bd85d42a43953410c0491330b0c13a8d3da67 Mon Sep 17 00:00:00 2001 From: evoskuil Date: Mon, 12 Aug 2024 11:22:43 -0400 Subject: [PATCH] Remove retainer, add block allocation metadata. --- include/bitcoin/node/block_arena.hpp | 7 ------- include/bitcoin/node/block_memory.hpp | 3 --- src/block_arena.cpp | 6 ------ src/block_memory.cpp | 6 ------ src/protocols/protocol_block_in_31800.cpp | 2 +- 5 files changed, 1 insertion(+), 23 deletions(-) diff --git a/include/bitcoin/node/block_arena.hpp b/include/bitcoin/node/block_arena.hpp index 77d19cdf..2ac4cced 100644 --- a/include/bitcoin/node/block_arena.hpp +++ b/include/bitcoin/node/block_arena.hpp @@ -40,12 +40,6 @@ class BCN_API block_arena final block_arena& operator=(block_arena&& other) NOEXCEPT; - /// Get memory block retainer mutex. - inline std::shared_mutex& get_mutex() NOEXCEPT - { - return mutex_; - } - void* require(size_t bytes) NOEXCEPT override; private: @@ -57,7 +51,6 @@ class BCN_API block_arena final size_t capacity() const NOEXCEPT; // These are thread safe (set only construct). - std::shared_mutex mutex_{}; uint8_t* memory_map_; size_t size_; diff --git a/include/bitcoin/node/block_memory.hpp b/include/bitcoin/node/block_memory.hpp index a015246a..4d437277 100644 --- a/include/bitcoin/node/block_memory.hpp +++ b/include/bitcoin/node/block_memory.hpp @@ -40,9 +40,6 @@ class BCN_API block_memory final /// Each thread obtains an arena of the same size. arena* get_arena() NOEXCEPT override; - /// Each thread obtains its arena's retainer. - retainer::ptr get_retainer(size_t allocation=zero) NOEXCEPT override; - protected: block_arena* get_block_arena() const THROWS; diff --git a/src/block_arena.cpp b/src/block_arena.cpp index 8ceeb9b2..7671c9ae 100644 --- a/src/block_arena.cpp +++ b/src/block_arena.cpp @@ -61,10 +61,7 @@ block_arena::block_arena(block_arena&& other) NOEXCEPT block_arena::~block_arena() NOEXCEPT { if (!is_null(memory_map_)) - { - std::unique_lock lock(mutex_); free(memory_map_); - } } block_arena& block_arena::operator=(block_arena&& other) NOEXCEPT @@ -88,10 +85,7 @@ size_t block_arena::capacity() const NOEXCEPT void* block_arena::require(size_t bytes) NOEXCEPT { if (bytes > capacity()) - { - std::unique_lock lock{ mutex_ }; offset_ = zero; - } return memory_map_ + offset_; } diff --git a/src/block_memory.cpp b/src/block_memory.cpp index fc3e0588..fbf7f10a 100644 --- a/src/block_memory.cpp +++ b/src/block_memory.cpp @@ -40,12 +40,6 @@ arena* block_memory::get_arena() NOEXCEPT return get_block_arena(); } -retainer::ptr block_memory::get_retainer(size_t allocation) NOEXCEPT -{ - return std::make_shared(get_block_arena()->get_mutex(), - allocation); -} - // protected block_arena* block_memory::get_block_arena() const THROWS { diff --git a/src/protocols/protocol_block_in_31800.cpp b/src/protocols/protocol_block_in_31800.cpp index 373b5308..bec5df3a 100644 --- a/src/protocols/protocol_block_in_31800.cpp +++ b/src/protocols/protocol_block_in_31800.cpp @@ -392,7 +392,7 @@ void protocol_block_in_31800::complete(const code& ec, { notify(ec, chase::checked, height); fire(events::block_archived, height); - ////const auto bytes = block->get_retainer()->allocation(); + ////const auto bytes = block->get_allocation(); } }