validation: add -prevoutfetchthreads configuration option

Add a configuration option for the number of worker threads used for
parallel UTXO prevout prefetching during block connection.

Default is 8 threads, max is 16, 0 disables parallel fetching.
This commit is contained in:
Andrew Toth
2026-04-14 13:45:53 -04:00
parent 633044f143
commit 5bf1c32008
6 changed files with 21 additions and 0 deletions

View File

@@ -60,6 +60,13 @@ util::Result<void> ApplyArgsManOptions(const ArgsManager& args, ChainstateManage
// Subtract 1 because the main thread counts towards the par threads.
opts.worker_threads_num = script_threads - 1;
if (auto value{args.GetArg<int32_t>("-prevoutfetchthreads")}) {
if (*value < 0) {
return util::Error{Untranslated(strprintf("-prevoutfetchthreads must be non-negative (got %d). Use 0 to disable parallel input fetching.", *value))};
}
opts.prevoutfetch_threads_num = std::min(*value, MAX_PREVOUTFETCH_THREADS);
}
if (auto max_size = args.GetIntArg("-maxsigcachesize")) {
// 1. When supplied with a max_size of 0, both the signature cache and
// script execution cache create the minimum possible cache (2