Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove retainer, add block allocation metadata. #671

Merged
merged 1 commit into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions include/bitcoin/node/block_arena.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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_;

Expand Down
3 changes: 0 additions & 3 deletions include/bitcoin/node/block_memory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
6 changes: 0 additions & 6 deletions src/block_arena.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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_;
}
Expand Down
6 changes: 0 additions & 6 deletions src/block_memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<retainer>(get_block_arena()->get_mutex(),
allocation);
}

// protected
block_arena* block_memory::get_block_arena() const THROWS
{
Expand Down
2 changes: 1 addition & 1 deletion src/protocols/protocol_block_in_31800.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}

Expand Down
Loading