Skip to content

Commit

Permalink
Merge pull request #652 from evoskuil/master
Browse files Browse the repository at this point in the history
Use parallel set_strong/unstrong in sequential confirmation.
  • Loading branch information
evoskuil authored Jun 24, 2024
2 parents cb6cc29 + b2a1aa9 commit 9881dd0
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 14 deletions.
49 changes: 42 additions & 7 deletions console/executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -733,11 +733,48 @@ void executor::scan_collisions() const
spend.shrink_to_fit();
}

////// arbitrary testing (const).
////void executor::read_test() const
////{
//// logger("No read test implemented.");
////}
// arbitrary testing (const).
void executor::read_test() const
{
auto start = fine_clock::now();
auto count = query_.header_records();
uint32_t block{ one };

logger("Find strong blocks.");
while (!cancel_ && (block < count) && query_.is_strong_block(block))
{
++block;
}

auto span = duration_cast<milliseconds>(fine_clock::now() - start);
logger(format("Top strong block is [%1%] in [%2%] ms.") % sub1(block) % span.count());
start = fine_clock::now();
count = query_.header_records();
uint32_t milestone{ 295'001 };

logger("Find milestone blocks.");
while (!cancel_ && (milestone < count) && query_.is_milestone(milestone))
{
++milestone;
}

span = duration_cast<milliseconds>(fine_clock::now() - start);
logger(format("Top milestone block is [%1%] in [%2%] ms.") % sub1(milestone) % span.count());
start = fine_clock::now();
uint32_t tx{ one };

logger("Find strong txs.");
count = query_.tx_records();
while (!cancel_ && (tx < count) && query_.is_strong_tx(tx) )
{
++tx;
}

span = duration_cast<milliseconds>(fine_clock::now() - start);
logger(format("Top strong tx is [%1%] in [%2%] ms.") % sub1(tx) % span.count());
}

#if defined(UNDEFINED)

void executor::read_test() const
{
Expand Down Expand Up @@ -1037,8 +1074,6 @@ void executor::read_test() const
#endif // UNDEFINED
}

#if defined(UNDEFINED)

void executor::read_test() const
{
logger("Wire size computation.");
Expand Down
14 changes: 7 additions & 7 deletions src/chasers/chaser_confirm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ void chaser_confirm::do_validated(height_t height) NOEXCEPT
}

popped.push_back(link);
if (!query.set_unstrong(link))
if (!query.set_unstrong_parallel(link))
{
fault(error::node_confirm);
return;
Expand Down Expand Up @@ -205,7 +205,7 @@ void chaser_confirm::do_validated(height_t height) NOEXCEPT
query.is_milestone(link);

// Required for block_confirmable and all confirmed blocks.
if (!checked && !query.set_strong(link))
if (!checked && !query.set_strong_parallel(link))
{
fault(error::set_confirmed);
return;
Expand Down Expand Up @@ -349,7 +349,7 @@ void chaser_confirm::do_validated(height_t height) NOEXCEPT
}

popped_.push_back(link);
if (!query.set_unstrong(link))
if (!query.set_unstrong_parallel(link))
{
fault(error::node_confirm);
return;
Expand Down Expand Up @@ -404,7 +404,7 @@ void chaser_confirm::do_organize(size_t height) NOEXCEPT

// Required for block_confirmable and all confirmed blocks.
// Checkpoint and milestone guarantee set_strong is always set.
if (!checked && !query.set_strong(link))
if (!checked && !query.set_strong_parallel(link))
{
fault(error::set_confirmed);
return;
Expand Down Expand Up @@ -604,7 +604,7 @@ bool chaser_confirm::reset_organized(const header_link& link,
height_t height) NOEXCEPT
{
auto& query = archive();
if (!query.set_strong(link) || !query.push_confirmed(link))
if (!query.set_strong_parallel(link) || !query.push_confirmed(link))
return false;

notify(error::success, chase::organized, link);
Expand All @@ -616,7 +616,7 @@ bool chaser_confirm::set_reorganized(const header_link& link,
height_t height) NOEXCEPT
{
auto& query = archive();
if (!query.pop_confirmed() || !query.set_unstrong(link))
if (!query.pop_confirmed() || !query.set_unstrong_parallel(link))
return false;

notify(error::success, chase::reorganized, link);
Expand All @@ -630,7 +630,7 @@ bool chaser_confirm::roll_back(const header_links& popped,
auto& query = archive();

// The current block is set_strong but not confirmed.
if (!query.set_unstrong(link))
if (!query.set_unstrong_parallel(link))
return false;

for (auto height = top; height > fork_point; --height)
Expand Down

0 comments on commit 9881dd0

Please sign in to comment.