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

Improve vote_cache slow_tests #3954

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
12 changes: 8 additions & 4 deletions nano/node/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -640,11 +640,15 @@ void nano::node::process_active (std::shared_ptr<nano::block> const & incoming)
block_processor.add (incoming);
}

nano::process_return nano::node::process (nano::block & block_a)
[[nodiscard]] nano::process_return nano::node::process (nano::write_transaction const & transaction, nano::block & block)
{
auto const transaction (store.tx_begin_write ({ tables::accounts, tables::blocks, tables::frontiers, tables::pending }));
auto result (ledger.process (transaction, block_a));
return result;
return ledger.process (transaction, block);
}

nano::process_return nano::node::process (nano::block & block)
{
auto const transaction = store.tx_begin_write ({ tables::accounts, tables::blocks, tables::frontiers, tables::pending });
return process (transaction, block);
}

nano::process_return nano::node::process_local (std::shared_ptr<nano::block> const & block_a)
Expand Down
1 change: 1 addition & 0 deletions nano/node/node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ class node final : public std::enable_shared_from_this<nano::node>
Transaction is comitted before function return
*/
[[nodiscard]] nano::process_return process (nano::block & block);
[[nodiscard]] nano::process_return process (nano::write_transaction const &, nano::block & block);
nano::block_hash latest (nano::account const &);
nano::uint128_t balance (nano::account const &);

Expand Down
15 changes: 9 additions & 6 deletions nano/slow_test/vote_cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,19 @@ std::vector<std::shared_ptr<nano::block>> setup_blocks (nano::test::system & sys

sends.push_back (send);
receives.push_back (open);

EXPECT_TRUE (nano::test::process (node, { send, open }));
}

std::cout << "setup_blocks confirming" << std::endl;

EXPECT_TRUE (nano::test::process (node, sends));
EXPECT_TRUE (nano::test::process (node, receives));

// Confirm whole genesis chain at once
EXPECT_TRUE (nano::test::confirm (node, { sends.back () }));
EXPECT_TIMELY (5s, nano::test::confirmed (node, { sends }));

std::cout << "setup_blocks done" << std::endl;

return receives;
}

Expand All @@ -127,13 +132,12 @@ TEST (vote_cache, perf_singlethreaded)
{
nano::test::system system;
nano::node_flags flags;
flags.inactive_votes_cache_size = 5000; // Keep it below block count size so it is forced to constantly evict stale entries
nano::node_config config = system.default_config ();
config.frontiers_confirmation = nano::frontiers_confirmation_mode::disabled;
auto & node = *system.add_node (config, flags);

const int rep_count = 50;
const int block_count = 20000;
const int block_count = 1024 * 128 * 2; // 2x the inactive vote cache size
const int vote_count = 100000;
const int single_vote_size = 7;
const int single_vote_reps = 7;
Expand Down Expand Up @@ -187,14 +191,13 @@ TEST (vote_cache, perf_multithreaded)
{
nano::test::system system;
nano::node_flags flags;
flags.inactive_votes_cache_size = 5000; // Keep it below block count size so it is forced to constantly evict stale entries
nano::node_config config = system.default_config ();
config.frontiers_confirmation = nano::frontiers_confirmation_mode::disabled;
auto & node = *system.add_node (config, flags);

const int thread_count = 12;
const int rep_count = 50;
const int block_count = 20000;
const int block_count = 1024 * 128 * 2; // 2x the inactive vote cache size
const int vote_count = 200000 / thread_count;
const int single_vote_size = 7;
const int single_vote_reps = 7;
Expand Down
3 changes: 2 additions & 1 deletion nano/test_common/testutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@ void nano::test::wait_peer_connections (nano::test::system & system_a)

bool nano::test::process (nano::node & node, std::vector<std::shared_ptr<nano::block>> blocks)
{
auto const transaction = node.store.tx_begin_write ({ tables::accounts, tables::blocks, tables::frontiers, tables::pending });
for (auto & block : blocks)
{
auto result = node.process (*block);
auto result = node.process (transaction, *block);
if (result.code != nano::process_result::progress)
{
return false;
Expand Down