Skip to content

Commit

Permalink
GH-3 Make vote processor thread pool size configurable including disa…
Browse files Browse the repository at this point in the history
…bling vote processing
  • Loading branch information
heifner committed Apr 11, 2024
1 parent c3a9c95 commit 6b0c4c4
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 7 deletions.
10 changes: 7 additions & 3 deletions libraries/chain/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1194,11 +1194,13 @@ struct controller_impl {
my_finalizers(fc::time_point::now(), cfg.finalizers_dir / "safety.dat"),
wasmif( conf.wasm_runtime, conf.eosvmoc_tierup, db, conf.state_dir, conf.eosvmoc_config, !conf.profile_accounts.empty() )
{
thread_pool.start( cfg.thread_pool_size, [this]( const fc::exception& e ) {
thread_pool.start( cfg.chain_thread_pool_size, [this]( const fc::exception& e ) {
elog( "Exception in chain thread pool, exiting: ${e}", ("e", e.to_detail_string()) );
if( shutdown ) shutdown();
} );
vote_processor.start(4);
if (cfg.vote_thread_pool_size > 0) {
vote_processor.start(cfg.vote_thread_pool_size);
}

set_activation_handler<builtin_protocol_feature_t::preactivate_feature>();
set_activation_handler<builtin_protocol_feature_t::replace_deferred>();
Expand Down Expand Up @@ -3558,7 +3560,9 @@ struct controller_impl {

// called from net threads and controller's thread pool
void process_vote_message( uint32_t connection_id, const vote_message& vote ) {
vote_processor.process_vote_message(connection_id, vote);
if (conf.vote_thread_pool_size > 0) {
vote_processor.process_vote_message(connection_id, vote);
}
}

bool node_has_voted_if_finalizer(const block_id_type& id) const {
Expand Down
1 change: 1 addition & 0 deletions libraries/chain/include/eosio/chain/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ const static uint16_t default_max_auth_depth = 6;
const static uint32_t default_sig_cpu_bill_pct = 50 * percent_1; // billable percentage of signature recovery
const static uint32_t default_produce_block_offset_ms = 450;
const static uint16_t default_controller_thread_pool_size = 2;
const static uint16_t default_vote_thread_pool_size = 4;
const static uint32_t default_max_variable_signature_length = 16384u;
const static uint32_t default_max_action_return_value_size = 256;

Expand Down
3 changes: 2 additions & 1 deletion libraries/chain/include/eosio/chain/controller.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ namespace eosio::chain {
uint64_t state_size = chain::config::default_state_size;
uint64_t state_guard_size = chain::config::default_state_guard_size;
uint32_t sig_cpu_bill_pct = chain::config::default_sig_cpu_bill_pct;
uint16_t thread_pool_size = chain::config::default_controller_thread_pool_size;
uint16_t chain_thread_pool_size = chain::config::default_controller_thread_pool_size;
uint16_t vote_thread_pool_size = chain::config::default_vote_thread_pool_size;
bool read_only = false;
bool force_all_checks = false;
bool disable_replay_opts = false;
Expand Down
16 changes: 13 additions & 3 deletions plugins/chain_plugin/chain_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,8 @@ void chain_plugin::set_program_options(options_description& cli, options_descrip
"Percentage of actual signature recovery cpu to bill. Whole number percentages, e.g. 50 for 50%")
("chain-threads", bpo::value<uint16_t>()->default_value(config::default_controller_thread_pool_size),
"Number of worker threads in controller thread pool")
("vote-threads", bpo::value<uint16_t>()->default_value(config::default_vote_thread_pool_size),
"Number of worker threads in vote processor thread pool. Voting disabled if set to 0 (votes are not propagatged on P2P network).")
("contracts-console", bpo::bool_switch()->default_value(false),
"print contract's output to console")
("deep-mind", bpo::bool_switch()->default_value(false),
Expand Down Expand Up @@ -632,9 +634,17 @@ void chain_plugin_impl::plugin_initialize(const variables_map& options) {
}

if( options.count( "chain-threads" )) {
chain_config->thread_pool_size = options.at( "chain-threads" ).as<uint16_t>();
EOS_ASSERT( chain_config->thread_pool_size > 0, plugin_config_exception,
"chain-threads ${num} must be greater than 0", ("num", chain_config->thread_pool_size) );
chain_config->chain_thread_pool_size = options.at( "chain-threads" ).as<uint16_t>();
EOS_ASSERT( chain_config->chain_thread_pool_size > 0, plugin_config_exception,
"chain-threads ${num} must be greater than 0", ("num", chain_config->chain_thread_pool_size) );
}

if( options.count( "vote-threads" )) {
chain_config->vote_thread_pool_size = options.at( "vote-threads" ).as<uint16_t>();
EOS_ASSERT( chain_config->vote_thread_pool_size > 1 || chain_config->vote_thread_pool_size == 0, plugin_config_exception,
"vote-threads ${num} must be greater than 1 or 0. "
"Voting disabled if set to 0 (votes are not propagatged on P2P network).",
("num", chain_config->vote_thread_pool_size) );
}

chain_config->sig_cpu_bill_pct = options.at("signature-cpu-billable-pct").as<uint32_t>();
Expand Down

0 comments on commit 6b0c4c4

Please sign in to comment.