Skip to content

Commit

Permalink
Configurable inactive votes cache size (#2579)
Browse files Browse the repository at this point in the history
  • Loading branch information
SergiySW authored Feb 25, 2020
1 parent 53f8172 commit 73b12c3
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion nano/node/active_transactions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -997,7 +997,7 @@ void nano::active_transactions::add_inactive_votes_cache (nano::block_hash const
bool start_bootstrap (inactive_votes_bootstrap_check (representative_vector, hash_a, confirmed));
auto & inactive_by_arrival (inactive_votes_cache.get<tag_arrival> ());
inactive_by_arrival.emplace (nano::inactive_cache_information{ std::chrono::steady_clock::now (), hash_a, representative_vector, start_bootstrap, confirmed });
if (inactive_votes_cache.size () > inactive_votes_cache_max)
if (inactive_votes_cache.size () > node.flags.inactive_votes_cache_size)
{
inactive_by_arrival.erase (inactive_by_arrival.begin ());
}
Expand Down
1 change: 0 additions & 1 deletion nano/node/active_transactions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,6 @@ class active_transactions final
mi::member<nano::inactive_cache_information, nano::block_hash, &nano::inactive_cache_information::hash>>>>;
ordered_cache inactive_votes_cache;
// clang-format on
static size_t constexpr inactive_votes_cache_max{ 16 * 1024 };
bool inactive_votes_bootstrap_check (std::vector<nano::account> const &, nano::block_hash const &, bool &);
static size_t constexpr dropped_elections_cache_max{ 32 * 1024 };
boost::thread thread;
Expand Down
8 changes: 7 additions & 1 deletion nano/node/cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ void nano::add_node_flag_options (boost::program_options::options_description &
("batch_size", boost::program_options::value<std::size_t>(), "Increase sideband batch size, default 512")
("block_processor_batch_size", boost::program_options::value<std::size_t>(), "Increase block processor transaction batch write size, default 0 (limited by config block_processor_batch_max_time), 256k for fast_bootstrap")
("block_processor_full_size", boost::program_options::value<std::size_t>(), "Increase block processor allowed blocks queue size before dropping live network packets and holding bootstrap download, default 65536, 1 million for fast_bootstrap")
("block_processor_verification_size", boost::program_options::value<std::size_t>(), "Increase batch signature verification size in block processor, default 0 (limited by config signature_checker_threads), unlimited for fast_bootstrap");
("block_processor_verification_size", boost::program_options::value<std::size_t>(), "Increase batch signature verification size in block processor, default 0 (limited by config signature_checker_threads), unlimited for fast_bootstrap")
("inactive_votes_cache_size", boost::program_options::value<std::size_t>(), "Increase cached votes without active elections size, default 16384");
// clang-format on
}

Expand Down Expand Up @@ -154,6 +155,11 @@ std::error_code nano::update_flags (nano::node_flags & flags_a, boost::program_o
{
flags_a.block_processor_verification_size = block_processor_verification_size_it->second.as<size_t> ();
}
auto inactive_votes_cache_size_it = vm.find ("inactive_votes_cache_size");
if (inactive_votes_cache_size_it != vm.end ())
{
flags_a.inactive_votes_cache_size = inactive_votes_cache_size_it->second.as<size_t> ();
}
return ec;
}

Expand Down
1 change: 1 addition & 0 deletions nano/node/nodeconfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,5 +136,6 @@ class node_flags final
size_t block_processor_batch_size{ 0 };
size_t block_processor_full_size{ 65536 };
size_t block_processor_verification_size{ 0 };
size_t inactive_votes_cache_size{ 16 * 1024 };
};
}

0 comments on commit 73b12c3

Please sign in to comment.