Move network transaction deserialization to a dedicated blocking and CPU-heavy thread #4787
Closed
Description
Motivation
Zebra's sync can be slow or fail, because transaction deserialization involves some CPU-heavy cryptography.
So we want to move transaction deserialization into a rayon
CPU thread pool scope
.
API Reference
Blocking threads:
https://docs.rs/tokio/latest/tokio/task/fn.spawn_blocking.html
CPU-heavy threads:
https://docs.rs/rayon/latest/rayon/fn.scope_fifo.html
Detailed Analysis
See #4583 (comment)
Designs
When zebra-network
deserializes a block or transaction, move that work to the rayon
thread pool.
Example code for rayon
in tokio
blocking threads:
zebra/zebra-consensus/src/primitives/ed25519.rs
Lines 121 to 134 in 81727d7
Related Work
State deserialization is handled in #4788