diff --git a/console/executor_test_reader.cpp b/console/executor_test_reader.cpp index 58ecd8f9..c062f81e 100644 --- a/console/executor_test_reader.cpp +++ b/console/executor_test_reader.cpp @@ -26,6 +26,43 @@ using namespace network; using namespace system; using format = boost_format; +// address index conflict walk (const). + +void executor::read_test(const hash_digest& key) const +{ + if (!query_.address_enabled()) + { + logger("Address index is disabled."); + return; + } + + logger("Address conflict walk."); + const auto start = fine_clock::now(); + + // Candidates are all rows on the key's chain, matches are verified. + size_t candidates{}; + for (auto it = store_.outs.it({ key }); it; ++it) + ++candidates; + + const auto walk = duration_cast(fine_clock::now() - start); + + database::output_links out{}; + if (const auto ec = query_.to_address_outputs(out, key)) + { + logger(format("Address (%1%) failed with (%2%).") % + encode_hash(key) % ec.message()); + return; + } + + const auto span = duration_cast(fine_clock::now() - start); + logger(format("Address (%1%) candidates (%2%) matches (%3%) conflicts " + "(%4%) walk (%5%) ms total (%6%) ms.") % encode_hash(key) % + candidates % out.size() % (candidates - out.size()) % + walk.count() % span.count()); +} + +#if defined(UNDEFINED) + // arbitrary testing (const). void executor::read_test(const hash_digest&) const @@ -66,8 +103,6 @@ void executor::read_test(const hash_digest&) const size % top % span.count()); } -#if defined(UNDEFINED) - void executor::read_test(const hash_digest&) const { logger(format("Ins table body searches: %1% / (%2% + %1%)") % diff --git a/include/bitcoin/server/protocols/protocol_native.hpp b/include/bitcoin/server/protocols/protocol_native.hpp index 8b45339a..60c0e566 100644 --- a/include/bitcoin/server/protocols/protocol_native.hpp +++ b/include/bitcoin/server/protocols/protocol_native.hpp @@ -43,6 +43,7 @@ class BCS_API protocol_native const network::channel::ptr& channel, const options_t& options) NOEXCEPT : protocol_html(session, channel, options), + turbo_(session->database_settings().turbo), notification_strand_(channel->service().get_executor()), network::tracker(session->log) { @@ -250,8 +251,9 @@ class BCS_API protocol_native database::header_link to_header(const std::optional& height, const std::optional& hash) NOEXCEPT; - // This is thread safe, uses network threadpool. + // These are thread safe, strand uses network threadpool. network::asio::strand notification_strand_; + const bool turbo_; // These are thread safe. std::atomic_bool stopping_{}; diff --git a/src/parser.cpp b/src/parser.cpp index 62d6b488..992554ae 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -89,7 +89,11 @@ parser::parser(system::chain::selection context, ////configured.server.stratum_v2.binds.emplace_back(asio::address{}, 8580_u16); // database - // load factors are set to 2.5 @ 950K. + + configured.database.turbo = true; + + // load factors are set to 2.5 @ 950K (except duplicate). + // sizes are set to 1% of measured pruned body @ 950K (tiny tables 100%). // Only used for electrum queries (255 is optimal otherwise). configured.database.interval_depth = 11; @@ -97,62 +101,83 @@ parser::parser(system::chain::selection context, // archive configured.database.header.buckets = 385'181; - configured.database.header.size = 21'000'000; + configured.database.header.size = 93'406'247; + configured.database.header.rate = 1; configured.database.txs.buckets = 950'001; - configured.database.txs.size = 1'050'000'000; + configured.database.txs.size = 54'471'017; + configured.database.txs.rate = 1; configured.database.tx.buckets = 543'948'678; - configured.database.tx.size = 17'000'000'000; + configured.database.tx.size = 870'317'885; + configured.database.tx.rate = 1; // ins (required) configured.database.ins.buckets = 1'345'386'901; - configured.database.ins.size = 34'250'000'000; + configured.database.ins.size = 1'749'002'971; + configured.database.ins.rate = 1; // outs (optional) - configured.database.outs.buckets = 1'496'771'635; - configured.database.outs.size = 6'750'000'000; + ////configured.database.outs.buckets = 1'496'771'635; + configured.database.outs.buckets = 0; + configured.database.outs.size = 336'773'618; + configured.database.outs.rate = 1; - configured.database.input.size = 92'500'000'000; - configured.database.output.size = 25'300'000'000; + configured.database.input.size = 67'269'346; + configured.database.input.rate = 1; + configured.database.output.size = 1'278'023'220; + configured.database.output.rate = 1; // indexes - configured.database.candidate.size = 2'575'500; - configured.database.confirmed.size = 2'575'500; + configured.database.candidate.size = 2'888'853; + configured.database.candidate.rate = 1; + configured.database.confirmed.size = 2'850'003; + configured.database.confirmed.rate = 1; configured.database.strong_tx.buckets = 543'948'678; - configured.database.strong_tx.size = 2'900'000'000; + configured.database.strong_tx.size = 149'585'887; + configured.database.strong_tx.rate = 1; // caches - configured.database.ecdsa.size = 1; - configured.database.schnorr.size = 1; - configured.database.silent.size = 1; - configured.database.prevalid.size = 1; + configured.database.ecdsa.size = 0; + configured.database.ecdsa.rate = 1; + configured.database.schnorr.size = 0; + configured.database.schnorr.rate = 1; + configured.database.silent.size = 0; + configured.database.silent.rate = 1; + configured.database.prevalid.size = 0; + configured.database.prevalid.rate = 1; configured.database.prevout.buckets = 0; - configured.database.prevout.size = 1; + configured.database.prevout.size = 0; + configured.database.prevout.rate = 1; configured.database.duplicate.buckets = 1024; - configured.database.duplicate.size = 44; + configured.database.duplicate.size = 0; + configured.database.duplicate.rate = 1; configured.database.validated_bk.buckets = 950'001; - configured.database.validated_bk.size = 1'700'000; + configured.database.validated_bk.size = 0; + configured.database.validated_bk.rate = 1; // unused in v4 configured.database.validated_tx.buckets = 0; - configured.database.validated_tx.size = 1; + configured.database.validated_tx.size = 0; + configured.database.validated_tx.rate = 1; // optional // also disabled by filter_tx configured.database.filter_bk.buckets = 0; - configured.database.filter_bk.size = 1; + configured.database.filter_bk.size = 0; + configured.database.filter_bk.rate = 1; // also disabled by filter_bk configured.database.filter_tx.buckets = 0; - configured.database.filter_tx.size = 1; + configured.database.filter_tx.size = 0; + configured.database.filter_tx.rate = 1; } options_metadata parser::load_options() THROWS @@ -1605,7 +1630,7 @@ options_metadata parser::load_settings() THROWS ( "database.turbo", value(&configured.database.turbo), - "Allow indiviudal non-validation queries to use all CPUs, defaults to false." + "Allow individual non-validation queries to use all CPUs, defaults to true." ) ( "database.mark_unconfirmable", @@ -1629,36 +1654,36 @@ options_metadata parser::load_settings() THROWS ( "table.header.size", value(&configured.database.header.size), - "The minimum allocation of the archive_header table body, defaults to '21000000'." + "The minimum allocation of the archive_header table body, defaults to '93406247'." ) ( "table.header.rate", value(&configured.database.header.rate), - "The percentage expansion of the archive_header table body, defaults to '5'." + "The percentage expansion of the archive_header table body, defaults to '1'." ) /* table.input */ ( "table.input.size", value(&configured.database.input.size), - "The minimum allocation of the archive_input table body, defaults to '92500000000'." + "The minimum allocation of the archive_input table body, defaults to '67269346'." ) ( "table.input.rate", value(&configured.database.input.rate), - "The percentage expansion of the archive_input table body, defaults to '5'." + "The percentage expansion of the archive_input table body, defaults to '1'." ) /* table.output */ ( "table.output.size", value(&configured.database.output.size), - "The minimum allocation of the archive_output table body, defaults to '25300000000'." + "The minimum allocation of the archive_output table body, defaults to '1278023220'." ) ( "table.output.rate", value(&configured.database.output.rate), - "The percentage expansion of the archive_output table body, defaults to '5'." + "The percentage expansion of the archive_output table body, defaults to '1'." ) /* table.ins */ @@ -1670,29 +1695,29 @@ options_metadata parser::load_settings() THROWS ( "table.ins.size", value(&configured.database.ins.size), - "The minimum allocation of the archive_ins table body, defaults to '34250000000'." + "The minimum allocation of the archive_ins table body, defaults to '1749002971'." ) ( "table.ins.rate", value(&configured.database.ins.rate), - "The percentage expansion of the archive_ins table body, defaults to '5'." + "The percentage expansion of the archive_ins table body, defaults to '1'." ) /* table.outs */ ( "table.outs.buckets", value(&configured.database.outs.buckets), - "The number of buckets in the archive_outs table head, defaults to '1496771635' (0 disables address index)." + "The number of buckets in the archive_outs table head, defaults to '0' (0 disables address index)." ) ( "table.outs.size", value(&configured.database.outs.size), - "The minimum allocation of the archive_outs table body, defaults to '3700000000'." + "The minimum allocation of the archive_outs table body, defaults to '336773618'." ) ( "table.outs.rate", value(&configured.database.outs.rate), - "The percentage expansion of the archive_outs table body, defaults to '5'." + "The percentage expansion of the archive_outs table body, defaults to '1'." ) /* table.tx */ @@ -1704,12 +1729,12 @@ options_metadata parser::load_settings() THROWS ( "table.tx.size", value(&configured.database.tx.size), - "The minimum allocation of the archive_tx table body, defaults to '17000000000'." + "The minimum allocation of the archive_tx table body, defaults to '870317885'." ) ( "table.tx.rate", value(&configured.database.tx.rate), - "The percentage expansion of the archive_tx table body, defaults to '5'." + "The percentage expansion of the archive_tx table body, defaults to '1'." ) /* table.txs */ @@ -1721,36 +1746,36 @@ options_metadata parser::load_settings() THROWS ( "table.txs.size", value(&configured.database.txs.size), - "The minimum allocation of the archive_txs table body, defaults to '1050000000'." + "The minimum allocation of the archive_txs table body, defaults to '54471017'." ) ( "table.txs.rate", value(&configured.database.txs.rate), - "The percentage expansion of the archive_txs table body, defaults to '5'." + "The percentage expansion of the archive_txs table body, defaults to '1'." ) /* table.candidate */ ( "table.candidate.size", value(&configured.database.candidate.size), - "The minimum allocation of the index_candidate table body, defaults to '2575500'." + "The minimum allocation of the index_candidate table body, defaults to '2888853'." ) ( "table.candidate.rate", value(&configured.database.candidate.rate), - "The percentage expansion of the index_candidate table body, defaults to '5'." + "The percentage expansion of the index_candidate table body, defaults to '1'." ) /* table.confirmed */ ( "table.confirmed.size", value(&configured.database.confirmed.size), - "The minimum allocation of the index_confirmed table body, defaults to '2575500'." + "The minimum allocation of the index_confirmed table body, defaults to '2850003'." ) ( "table.confirmed.rate", value(&configured.database.confirmed.rate), - "The percentage expansion of the index_confirmed table body, defaults to '5'." + "The percentage expansion of the index_confirmed table body, defaults to '1'." ) /* table.strong */ @@ -1762,60 +1787,60 @@ options_metadata parser::load_settings() THROWS ( "table.strong.size", value(&configured.database.strong_tx.size), - "The minimum allocation of the index_strong table body, defaults to '2900000000'." + "The minimum allocation of the index_strong table body, defaults to '149585887'." ) ( "table.strong.rate", value(&configured.database.strong_tx.rate), - "The percentage expansion of the index_strong table body, defaults to '5'." + "The percentage expansion of the index_strong table body, defaults to '1'." ) /* table.ecdsa */ ( "table.ecdsa.size", value(&configured.database.ecdsa.size), - "The minimum allocation of the batch_ecdsa table body, defaults to '1'." + "The minimum allocation of the batch_ecdsa table body, defaults to '0'." ) ( "table.ecdsa.rate", value(&configured.database.ecdsa.rate), - "The percentage expansion of the batch_ecdsa table body, defaults to '5'." + "The percentage expansion of the batch_ecdsa table body, defaults to '1'." ) /* table.schnorr */ ( "table.schnorr.size", value(&configured.database.schnorr.size), - "The minimum allocation of the batch_schnorr table body, defaults to '1'." + "The minimum allocation of the batch_schnorr table body, defaults to '0'." ) ( "table.schnorr.rate", value(&configured.database.schnorr.rate), - "The percentage expansion of the batch_schnorr table body, defaults to '5'." + "The percentage expansion of the batch_schnorr table body, defaults to '1'." ) /* table.silent */ ( "table.silent.size", value(&configured.database.silent.size), - "The minimum allocation of the batch_silent table body, defaults to '1'." + "The minimum allocation of the batch_silent table body, defaults to '0'." ) ( "table.silent.rate", value(&configured.database.silent.rate), - "The percentage expansion of the batch_silent table body, defaults to '5'." + "The percentage expansion of the batch_silent table body, defaults to '1'." ) /* table.prevalid */ ( "table.prevalid.size", value(&configured.database.prevalid.size), - "The minimum allocation of the batch_prevalid table body, defaults to '1'." + "The minimum allocation of the batch_prevalid table body, defaults to '0'." ) ( "table.prevalid.rate", value(&configured.database.prevalid.rate), - "The percentage expansion of the batch_prevalid table, defaults to '5'." + "The percentage expansion of the batch_prevalid table, defaults to '1'." ) /* table.prevout */ @@ -1827,12 +1852,12 @@ options_metadata parser::load_settings() THROWS ( "table.prevout.size", value(&configured.database.prevout.size), - "The minimum allocation of the cache_prevout table body, defaults to '1'." + "The minimum allocation of the cache_prevout table body, defaults to '0'." ) ( "table.prevout.rate", value(&configured.database.prevout.rate), - "The percentage expansion of the cache_prevout table, defaults to '5'." + "The percentage expansion of the cache_prevout table, defaults to '1'." ) /* table.duplicate */ @@ -1844,12 +1869,12 @@ options_metadata parser::load_settings() THROWS ( "table.duplicate.size", value(&configured.database.duplicate.size), - "The minimum allocation of the cache_duplicate table body, defaults to '44'." + "The minimum allocation of the cache_duplicate table body, defaults to '0'." ) ( "table.duplicate.rate", value(&configured.database.duplicate.rate), - "The percentage expansion of the cache_duplicate table, defaults to '5'." + "The percentage expansion of the cache_duplicate table, defaults to '1'." ) /* table.validated_bk */ @@ -1861,12 +1886,12 @@ options_metadata parser::load_settings() THROWS ( "table.validated_bk.size", value(&configured.database.validated_bk.size), - "The minimum allocation of the validated_bk table body, defaults to '1700000'." + "The minimum allocation of the validated_bk table body, defaults to '0'." ) ( "table.validated_bk.rate", value(&configured.database.validated_bk.rate), - "The percentage expansion of the validated_bk table body, defaults to '5'." + "The percentage expansion of the validated_bk table body, defaults to '1'." ) /* table.validated_tx */ @@ -1878,12 +1903,12 @@ options_metadata parser::load_settings() THROWS ( "table.validated_tx.size", value(&configured.database.validated_tx.size), - "The minimum allocation of the validated_tx table body, defaults to '1'." + "The minimum allocation of the validated_tx table body, defaults to '0'." ) ( "table.validated_tx.rate", value(&configured.database.validated_tx.rate), - "The percentage expansion of the validated_tx table body, defaults to '5'." + "The percentage expansion of the validated_tx table body, defaults to '1'." ) /* table.filter_bk */ @@ -1895,12 +1920,12 @@ options_metadata parser::load_settings() THROWS ( "table.filter_bk.size", value(&configured.database.filter_bk.size), - "The minimum allocation of the option_filter_bk table body, defaults to '1'." + "The minimum allocation of the option_filter_bk table body, defaults to '0'." ) ( "table.filter_bk.rate", value(&configured.database.filter_bk.rate), - "The percentage expansion of the option_filter_bk table body, defaults to '5'." + "The percentage expansion of the option_filter_bk table body, defaults to '1'." ) /* table.filter_tx */ @@ -1912,12 +1937,12 @@ options_metadata parser::load_settings() THROWS ( "table.filter_tx.size", value(&configured.database.filter_tx.size), - "The minimum allocation of the option_filter_tx table body, defaults to '1'." + "The minimum allocation of the option_filter_tx table body, defaults to '0'." ) ( "table.filter_tx.rate", value(&configured.database.filter_tx.rate), - "The percentage expansion of the option_filter_tx table body, defaults to '5'." + "The percentage expansion of the option_filter_tx table body, defaults to '1'." ) /* [log] */ diff --git a/src/protocols/native/protocol_native_address.cpp b/src/protocols/native/protocol_native_address.cpp index 789f22c5..262ce729 100644 --- a/src/protocols/native/protocol_native_address.cpp +++ b/src/protocols/native/protocol_native_address.cpp @@ -51,7 +51,7 @@ bool protocol_native::handle_get_address(const code& ec, interface::address, // Monitor socket for close. monitor(true); - PARALLEL(do_get_address, media, turbo, hash); + PARALLEL(do_get_address, media, turbo && turbo_, hash); return true; } @@ -129,7 +129,7 @@ bool protocol_native::handle_get_address_confirmed(const code& ec, // Monitor socket for close. monitor(true); - PARALLEL(do_get_address_confirmed, media, turbo, hash); + PARALLEL(do_get_address_confirmed, media, turbo && turbo_, hash); return true; } @@ -185,7 +185,7 @@ bool protocol_native::handle_get_address_balance(const code& ec, // Monitor socket for close. monitor(true); - PARALLEL(do_get_address_balance, media, turbo, hash); + PARALLEL(do_get_address_balance, media, turbo && turbo_, hash); return true; }