Improve BLS multi-thread worker pool strategy #2421
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
Some weeks ago we landed a naive version of a worker thread pool to verify BLS signatures. It did the essential well, to help the node breathe and survive in Prater. But some obvious work can be done to improve the current impl.
Description
Extend usage
Use the BLS worker pool for all gossip validation, not only attestations.
Reduce latency cost
Communication between the main thread and workers has significant latency, similar to the cost of a single BLS sig verification. To reduce the impact of this latency in the throughput of validation I've update the pool to allow batching work. It will send packages of multiple groups of signature sets to be verified individually but sending the whole package once. This splits the latency cost between multiple operation. However this strategy only works if all workers are busy so the queue can accumulate work.
Add metrics
By using our own custom Thread Pool instead of
threads
implementation it's good to add some metrics to track: