From 383992fdd4b5d20500c0376532518d5e61f0e229 Mon Sep 17 00:00:00 2001 From: Eric Voskuil Date: Sun, 6 Sep 2026 01:49:43 -0400 Subject: [PATCH] Default node threads to zero (hardware threads). --- src/settings.cpp | 5 +++-- test/configuration.cpp | 4 ++-- test/settings.cpp | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/settings.cpp b/src/settings.cpp index dd066108..668f13c6 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -29,7 +29,7 @@ namespace libbitcoin { namespace node { settings::settings() NOEXCEPT - : threads{ 1 }, + : threads{ 0 }, delay_inbound{ true }, headers_first{ true }, memory_priority{ true }, @@ -68,7 +68,8 @@ settings::settings(chain::selection) NOEXCEPT size_t settings::threads_() const NOEXCEPT { - return std::max(threads, one); + // Zero implies hardware threads (including hyperthreads). + return to_bool(threads) ? threads : network::cores(); } size_t settings::maximum_height_() const NOEXCEPT diff --git a/test/configuration.cpp b/test/configuration.cpp index 6c0a514a..0d31658e 100644 --- a/test/configuration.cpp +++ b/test/configuration.cpp @@ -29,8 +29,8 @@ BOOST_AUTO_TEST_CASE(configuration__construct1__none_context__expected) // Just a sample of settings. BOOST_REQUIRE(instance.node.headers_first); - BOOST_REQUIRE_EQUAL(instance.network.threads, 1_u32); - BOOST_REQUIRE_EQUAL(instance.bitcoin.first_version, 1_u32); + BOOST_REQUIRE_EQUAL(instance.network.threads, 0u); + BOOST_REQUIRE_EQUAL(instance.bitcoin.first_version, 1u); } BOOST_AUTO_TEST_SUITE_END() diff --git a/test/settings.cpp b/test/settings.cpp index af296bc1..483c01a0 100644 --- a/test/settings.cpp +++ b/test/settings.cpp @@ -30,7 +30,7 @@ BOOST_AUTO_TEST_CASE(settings__node__default_context__expected) using namespace network; const node::settings node{}; - BOOST_REQUIRE_EQUAL(node.threads, 1_u32); + BOOST_REQUIRE_EQUAL(node.threads, 0_u32); BOOST_REQUIRE_EQUAL(node.delay_inbound, true); BOOST_REQUIRE_EQUAL(node.headers_first, true); BOOST_REQUIRE_EQUAL(node.memory_priority, true); @@ -61,7 +61,7 @@ BOOST_AUTO_TEST_CASE(settings__node__default_context__expected) ////BOOST_REQUIRE_EQUAL(node.snapshot_valid, 250'000_u32); ////BOOST_REQUIRE_EQUAL(node.snapshot_confirm, 500'000_u32); - BOOST_REQUIRE_EQUAL(node.threads_(), one); + BOOST_REQUIRE_EQUAL(node.threads_(), cores()); BOOST_REQUIRE_EQUAL(node.maximum_height_(), max_size_t); BOOST_REQUIRE_EQUAL(node.maximum_concurrency_(), 50'000_size); BOOST_REQUIRE_EQUAL(node.fee_estimate_horizon_(), 0_size);