Repository navigation
Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. External sites
ReviewsSee the guideline and AI policy for information on the review process.
If your review is incorrectly listed, please copy-paste ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
9b27afc to
b0debcf
Compare
|
ACK b0debcf |
b0debcf to
483c9d0
Compare
|
Performed some measurements which ended up with an increased average run time but a decreased minimum run time. They leave me not worrying too much about unexpected pessimization. Before/649bc0a645eb127a9b1e6d078f8d129be6380c87 (PR base)After/483c9d0f448a5bcd6d24e24b00d45a8f22975fb7 (PR tip) |
45b6753 to
0977948
Compare
| } else { | ||
| // Submit can fail if a shared owner of the thread pool outside of this class calls Stop() or | ||
| // Interrupt() on a different thread after we call WorkersCount() above. In that case parallel | ||
| // fetching will not make progress, so we clear the inputs to fall back to single threaded fetching. | ||
| LogWarning("Failed to submit prevout fetch tasks (%s); falling back to single-threaded fetching for this block.", SubmitErrorString(futures.error())); | ||
| m_inputs.clear(); | ||
| StopFetching(); // Assert nothing changed if we failed to start tasks. | ||
| } |
There was a problem hiding this comment.
nit: We will now perform more work when we have blocks with only have a coinbase tx (previously we would not call ThreadPool::Submit(). In the case that bitcoin as a whole succeeds those blocks are outliers, so I agree with that part of the change.
However, the warning in the else-block becomes somewhat weird when m_tasks is empty (failing to submit 0 tasks). How about bringing the m_inputs.size() check back for that?
| } else { | |
| // Submit can fail if a shared owner of the thread pool outside of this class calls Stop() or | |
| // Interrupt() on a different thread after we call WorkersCount() above. In that case parallel | |
| // fetching will not make progress, so we clear the inputs to fall back to single threaded fetching. | |
| LogWarning("Failed to submit prevout fetch tasks (%s); falling back to single-threaded fetching for this block.", SubmitErrorString(futures.error())); | |
| m_inputs.clear(); | |
| StopFetching(); // Assert nothing changed if we failed to start tasks. | |
| } | |
| } else if (m_inputs.size()) { | |
| // Submit can fail if a shared owner of the thread pool outside of this class calls Stop() or | |
| // Interrupt() on a different thread after we call WorkersCount() above. In that case parallel | |
| // fetching will not make progress, so we clear the inputs to fall back to single threaded fetching. | |
| LogWarning("Failed to submit prevout fetch tasks (%s); falling back to single-threaded fetching for this block.", SubmitErrorString(futures.error())); | |
| m_inputs.clear(); | |
| StopFetching(); // Assert nothing changed if we failed to start tasks. | |
| } |
There was a problem hiding this comment.
Right, this will now warn everytime on regtest if we call bitcoin-cli -generate with an empty mempool.
Insert each transaction ID before scanning the following transaction's inputs, omitting the unused final ID. This reduces txid insertions from N to N-1 and replaces the separate coinbase seed and trailing insertion with one insertion at the start of the loop.
Retain the classification set across blocks to reuse its buckets and avoid reseeding its hasher. The set still allocates and frees its nodes for each block.
`ThreadPool::Submit` binds its range by reference and moves the individual callables without taking the vector's storage, so keep the vector on the overlay for reuse across blocks.
Each task drains the shared input queue, so tasks beyond the number of inputs cannot do useful work. For an empty queue, submit an empty range and skip the worker notification inside `ThreadPool::Submit` instead of guarding submission at the caller.
0977948 to
ec33918
Compare
l0rinc
left a comment
There was a problem hiding this comment.
Thanks, applied the nits & rebased.
| } else { | ||
| // Submit can fail if a shared owner of the thread pool outside of this class calls Stop() or | ||
| // Interrupt() on a different thread after we call WorkersCount() above. In that case parallel | ||
| // fetching will not make progress, so we clear the inputs to fall back to single threaded fetching. | ||
| LogWarning("Failed to submit prevout fetch tasks (%s); falling back to single-threaded fetching for this block.", SubmitErrorString(futures.error())); | ||
| m_inputs.clear(); | ||
| StopFetching(); // Assert nothing changed if we failed to start tasks. | ||
| } |

Problem: Block preparation inserts an unused final transaction ID, repeatedly constructs salted transaction-ID sets, and allocates a worker-task vector. Small input queues also submit more tasks than can do useful work.
Fix: Insert each transaction ID before scanning the following transaction's inputs. Reuse the set's buckets and hash salt and the worker-task vector across blocks. Limit submitted tasks to the smaller of the worker and queued-input counts.