Skip to content

Commit

Permalink
Dynamic bucket threshold
Browse files Browse the repository at this point in the history
  • Loading branch information
pwojcikdev committed Nov 28, 2024
1 parent 57c0b8e commit a1d7cdc
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
1 change: 0 additions & 1 deletion nano/core_test/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3706,7 +3706,6 @@ TEST (node, bounded_backlog)

nano::node_config node_config;
node_config.backlog.max_backlog = 10;
node_config.backlog.bucket_threshold = 2;
node_config.backlog_scan.enable = false;
auto & node = *system.add_node (node_config);

Expand Down
7 changes: 6 additions & 1 deletion nano/node/bounded_backlog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,11 @@ std::deque<nano::block_hash> nano::bounded_backlog::perform_rollbacks (std::dequ
return processed;
}

size_t nano::bounded_backlog::bucket_threshold () const
{
return config.max_backlog / bucketing.size ();
}

std::deque<nano::block_hash> nano::bounded_backlog::gather_targets (size_t max_count) const
{
debug_assert (!mutex.try_lock ());
Expand All @@ -347,7 +352,7 @@ std::deque<nano::block_hash> nano::bounded_backlog::gather_targets (size_t max_c
for (auto bucket : bucketing.bucket_indices ())
{
// Only start rolling back if the bucket is over the threshold of unconfirmed blocks
if (index.size (bucket) > config.bucket_threshold)
if (index.size (bucket) > bucket_threshold ())
{
auto const count = std::min (max_count, config.batch_size);

Expand Down
2 changes: 1 addition & 1 deletion nano/node/bounded_backlog.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ class bounded_backlog_config
{
public:
size_t max_backlog{ 100000 };
size_t bucket_threshold{ 1000 };
double overfill_factor{ 1.5 };
size_t batch_size{ 32 };
size_t max_queued_notifications{ 128 };
Expand All @@ -112,6 +111,7 @@ class bounded_backlog
void stop ();

size_t index_size () const;
size_t bucket_threshold () const;

nano::container_info container_info () const;

Expand Down

0 comments on commit a1d7cdc

Please sign in to comment.