From 9b809c9366f4190f795c57486f733bd775a5ca30 Mon Sep 17 00:00:00 2001 From: cryptocode <34946442+cryptocode@users.noreply.github.com> Date: Tue, 9 Oct 2018 17:12:33 +0200 Subject: [PATCH] Separate config option for number of network threads (#1276) --- rai/node/node.cpp | 6 +++++- rai/node/node.hpp | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/rai/node/node.cpp b/rai/node/node.cpp index 805f64ce..fcfc6ae5 100644 --- a/rai/node/node.cpp +++ b/rai/node/node.cpp @@ -43,7 +43,7 @@ resolver (node_a.service), node (node_a), on (true) { - for (size_t i = 0; i < node.config.io_threads; ++i) + for (size_t i = 0; i < node.config.network_threads; ++i) { packet_processing_threads.push_back (std::thread ([this]() { rai::thread_role::set (rai::thread_role::name::packet_processing); @@ -801,6 +801,7 @@ online_weight_minimum (60000 * rai::Gxrb_ratio), online_weight_quorum (50), password_fanout (1024), io_threads (std::max (4, std::thread::hardware_concurrency ())), +network_threads (std::max (4, std::thread::hardware_concurrency ())), work_threads (std::max (4, std::thread::hardware_concurrency ())), enable_voting (true), bootstrap_connections (4), @@ -879,6 +880,7 @@ void rai::node_config::serialize_json (boost::property_tree::ptree & tree_a) con tree_a.put ("online_weight_quorum", std::to_string (online_weight_quorum)); tree_a.put ("password_fanout", std::to_string (password_fanout)); tree_a.put ("io_threads", std::to_string (io_threads)); + tree_a.put ("network_threads", std::to_string (network_threads)); tree_a.put ("work_threads", std::to_string (work_threads)); tree_a.put ("enable_voting", enable_voting); tree_a.put ("bootstrap_connections", bootstrap_connections); @@ -995,6 +997,7 @@ bool rai::node_config::upgrade_json (unsigned version, boost::property_tree::ptr tree_a.put ("version", "14"); result = true; case 14: + tree_a.put ("network_threads", std::to_string (network_threads)); tree_a.erase ("generate_hash_votes_at"); tree_a.put ("block_processor_batch_max_time", block_processor_batch_max_time.count ()); tree_a.erase ("version"); @@ -1093,6 +1096,7 @@ bool rai::node_config::deserialize_json (bool & upgraded_a, boost::property_tree bootstrap_fraction_numerator = std::stoul (bootstrap_fraction_numerator_l); password_fanout = std::stoul (password_fanout_l); io_threads = std::stoul (io_threads_l); + network_threads = tree_a.get ("network_threads", network_threads); work_threads = std::stoul (work_threads_l); bootstrap_connections = std::stoul (bootstrap_connections_l); bootstrap_connections_max = std::stoul (bootstrap_connections_max_l); diff --git a/rai/node/node.hpp b/rai/node/node.hpp index e6124059..0d7fdd78 100644 --- a/rai/node/node.hpp +++ b/rai/node/node.hpp @@ -465,6 +465,7 @@ public: unsigned online_weight_quorum; unsigned password_fanout; unsigned io_threads; + unsigned network_threads; unsigned work_threads; bool enable_voting; unsigned bootstrap_connections;