Limit bulk pull processing for possible existing blocks (#3155)
* Limit bulk pull processing for possible existing blocks Check each 8k blocks if processed block exists. If true, drop connection to prevent unnessesary blocks reprocessing attempt * Move check to nano::bootstrap_attempt::process_block () * Simplify pull blocks logic
This commit is contained in:
parent
7cab5ae677
commit
a314b1ac5e
4 changed files with 20 additions and 10 deletions
|
|
@ -130,6 +130,7 @@ public:
|
|||
static constexpr unsigned requeued_pulls_limit = 256;
|
||||
static constexpr unsigned requeued_pulls_limit_dev = 1;
|
||||
static constexpr unsigned requeued_pulls_processed_blocks_factor = 4096;
|
||||
static constexpr uint64_t pull_count_per_check = 8 * 1024;
|
||||
static constexpr unsigned bulk_push_cost_limit = 200;
|
||||
static constexpr std::chrono::seconds lazy_flush_delay_sec = std::chrono::seconds (5);
|
||||
static constexpr uint64_t lazy_batch_pull_count_resize_blocks_limit = 4 * 1024 * 1024;
|
||||
|
|
|
|||
|
|
@ -129,11 +129,20 @@ bool nano::bootstrap_attempt::request_bulk_push_target (std::pair<nano::block_ha
|
|||
return true;
|
||||
}
|
||||
|
||||
bool nano::bootstrap_attempt::process_block (std::shared_ptr<nano::block> const & block_a, nano::account const & known_account_a, uint64_t pull_blocks, nano::bulk_pull::count_t max_blocks, bool block_expected, unsigned retry_limit)
|
||||
bool nano::bootstrap_attempt::process_block (std::shared_ptr<nano::block> const & block_a, nano::account const & known_account_a, uint64_t pull_blocks_processed, nano::bulk_pull::count_t max_blocks, bool block_expected, unsigned retry_limit)
|
||||
{
|
||||
nano::unchecked_info info (block_a, known_account_a, 0, nano::signature_verification::unknown);
|
||||
node->block_processor.add (info);
|
||||
return false;
|
||||
bool stop_pull (false);
|
||||
// If block already exists in the ledger, then we can avoid next part of long account chain
|
||||
if (pull_blocks_processed % nano::bootstrap_limits::pull_count_per_check == 0 && node->ledger.block_or_pruned_exists (block_a->hash ()))
|
||||
{
|
||||
stop_pull = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
nano::unchecked_info info (block_a, known_account_a, 0, nano::signature_verification::unknown);
|
||||
node->block_processor.add (info);
|
||||
}
|
||||
return stop_pull;
|
||||
}
|
||||
|
||||
void nano::bootstrap_attempt::lazy_start (nano::hash_or_account const &, bool)
|
||||
|
|
|
|||
|
|
@ -239,8 +239,8 @@ void nano::bulk_pull_client::received_block (boost::system::error_code const & e
|
|||
connection->set_start_time (std::chrono::steady_clock::now ());
|
||||
}
|
||||
attempt->total_blocks++;
|
||||
bool stop_pull (attempt->process_block (block, known_account, pull_blocks, pull.count, block_expected, pull.retry_limit));
|
||||
pull_blocks++;
|
||||
bool stop_pull (attempt->process_block (block, known_account, pull_blocks, pull.count, block_expected, pull.retry_limit));
|
||||
if (!stop_pull && !connection->hard_stop.load ())
|
||||
{
|
||||
/* Process block in lazy pull if not stopped
|
||||
|
|
|
|||
|
|
@ -216,12 +216,12 @@ void nano::bootstrap_attempt_lazy::run ()
|
|||
condition.notify_all ();
|
||||
}
|
||||
|
||||
bool nano::bootstrap_attempt_lazy::process_block (std::shared_ptr<nano::block> const & block_a, nano::account const & known_account_a, uint64_t pull_blocks, nano::bulk_pull::count_t max_blocks, bool block_expected, unsigned retry_limit)
|
||||
bool nano::bootstrap_attempt_lazy::process_block (std::shared_ptr<nano::block> const & block_a, nano::account const & known_account_a, uint64_t pull_blocks_processed, nano::bulk_pull::count_t max_blocks, bool block_expected, unsigned retry_limit)
|
||||
{
|
||||
bool stop_pull (false);
|
||||
if (block_expected)
|
||||
{
|
||||
stop_pull = process_block_lazy (block_a, known_account_a, pull_blocks, max_blocks, retry_limit);
|
||||
stop_pull = process_block_lazy (block_a, known_account_a, pull_blocks_processed, max_blocks, retry_limit);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -231,7 +231,7 @@ bool nano::bootstrap_attempt_lazy::process_block (std::shared_ptr<nano::block> c
|
|||
return stop_pull;
|
||||
}
|
||||
|
||||
bool nano::bootstrap_attempt_lazy::process_block_lazy (std::shared_ptr<nano::block> const & block_a, nano::account const & known_account_a, uint64_t pull_blocks, nano::bulk_pull::count_t max_blocks, unsigned retry_limit)
|
||||
bool nano::bootstrap_attempt_lazy::process_block_lazy (std::shared_ptr<nano::block> const & block_a, nano::account const & known_account_a, uint64_t pull_blocks_processed, nano::bulk_pull::count_t max_blocks, unsigned retry_limit)
|
||||
{
|
||||
bool stop_pull (false);
|
||||
auto hash (block_a->hash ());
|
||||
|
|
@ -250,7 +250,7 @@ bool nano::bootstrap_attempt_lazy::process_block_lazy (std::shared_ptr<nano::blo
|
|||
}
|
||||
lazy_blocks_insert (hash);
|
||||
// Adding lazy balances for first processed block in pull
|
||||
if (pull_blocks == 0 && (block_a->type () == nano::block_type::state || block_a->type () == nano::block_type::send))
|
||||
if (pull_blocks_processed == 1 && (block_a->type () == nano::block_type::state || block_a->type () == nano::block_type::send))
|
||||
{
|
||||
lazy_balances.emplace (hash, block_a->balance ().number ());
|
||||
}
|
||||
|
|
@ -265,7 +265,7 @@ bool nano::bootstrap_attempt_lazy::process_block_lazy (std::shared_ptr<nano::blo
|
|||
node->block_processor.add (info);
|
||||
}
|
||||
// Force drop lazy bootstrap connection for long bulk_pull
|
||||
if (pull_blocks > max_blocks)
|
||||
if (pull_blocks_processed > max_blocks)
|
||||
{
|
||||
stop_pull = true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue