From b0c4e2f053b0e5bf984ebc6627af09dedd6771e5 Mon Sep 17 00:00:00 2001 From: teor Date: Tue, 23 Aug 2022 12:38:13 +1000 Subject: [PATCH 1/2] Revert: deserialize stored transactions in a rayon thread --- .../finalized_state/disk_format/block.rs | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/zebra-state/src/service/finalized_state/disk_format/block.rs b/zebra-state/src/service/finalized_state/disk_format/block.rs index 939408c7857..89c91ff3311 100644 --- a/zebra-state/src/service/finalized_state/disk_format/block.rs +++ b/zebra-state/src/service/finalized_state/disk_format/block.rs @@ -231,21 +231,10 @@ impl FromDisk for Transaction { fn from_bytes(bytes: impl AsRef<[u8]>) -> Self { let bytes = bytes.as_ref(); - let mut tx = None; - - // # Performance - // - // Move CPU-intensive deserialization cryptography into the rayon thread pool. - // This avoids blocking the tokio executor. - rayon::in_place_scope_fifo(|scope| { - scope.spawn_fifo(|_scope| { - tx = Some(bytes.as_ref().zcash_deserialize_into().expect( - "deserialization format should match the serialization format used by IntoDisk", - )); - }); - }); - - tx.expect("scope has already run") + bytes + .as_ref() + .zcash_deserialize_into() + .expect("deserialization format should match the serialization format used by IntoDisk") } } From 040240ef37e696b9c55129b22500d0a260f234b6 Mon Sep 17 00:00:00 2001 From: teor Date: Wed, 24 Aug 2022 10:40:37 +1000 Subject: [PATCH 2/2] Add a TODO for the reverted bug fix --- zebra-state/src/service/finalized_state/disk_format/block.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/zebra-state/src/service/finalized_state/disk_format/block.rs b/zebra-state/src/service/finalized_state/disk_format/block.rs index 89c91ff3311..4ce8689ed3d 100644 --- a/zebra-state/src/service/finalized_state/disk_format/block.rs +++ b/zebra-state/src/service/finalized_state/disk_format/block.rs @@ -231,6 +231,8 @@ impl FromDisk for Transaction { fn from_bytes(bytes: impl AsRef<[u8]>) -> Self { let bytes = bytes.as_ref(); + // TODO: skip cryptography verification during transaction deserialization from storage, + // or do it in a rayon thread (ideally in parallel with other transactions) bytes .as_ref() .zcash_deserialize_into()