Skip to content

Commit 1047135

Browse files
authored
perf(l2): use rkyv instead of bincode for sp1 (#3831)
**Motivation** after #3765 running a samply shows bincode deserialization taking up more than 45% of execution time in a large l2 batch **Description** - implement rkyv Archive trait for all of `ProgramInput` fields and its containing structs - for sp1 serialize `ProgramInput` as bytes, then use write_slice to write to sp1 stdin, then deserialize the bytes in sp1 main with from_bytes **Metrics** command: ``` SP1_PROVER=cuda cargo run --release --features "sp1,l2,gpu" -- prove batch --rpc-url <RPC-URL> --network 65536300 48 ``` specs: ``` CPU: 13th Gen Intel(R) Core(TM) i5-13500 RAM: 64GB DDR4 3200MT/s GPU: NVIDIA RTX 4000 SFF Ada Generation ``` 716 blocks 0tx/b - this pr: `Successfully executed SP1 program in 83.47s` - main: `Successfully executed SP1 program in 262.82s` 716 blocks 1tx/b - this pr: `Successfully executed SP1 program in 528.02s` - main: `Successfully executed SP1 program in 784.57s` 717 blocks 2tx/b - this pr: `Successfully executed SP1 program in 1234.45s` - main: `Successfully executed SP1 program in 1676.83s`
1 parent e1da8bf commit 1047135

File tree

19 files changed

+903
-30
lines changed

19 files changed

+903
-30
lines changed

Cargo.lock

Lines changed: 114 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ reqwest = { version = "0.12.7", features = ["json"] }
9393
redb = "=2.4.0"
9494
snap = "1.1.1"
9595
secp256k1 = { version = "0.29.1", default-features = false, features = [
96-
"global-context",
97-
"recovery",
98-
"rand",
96+
"global-context",
97+
"recovery",
98+
"rand",
9999
] }
100100
keccak-hash = "0.11.0"
101101
axum = "0.8.1"
@@ -112,6 +112,7 @@ spawned-rt = "0.2.2"
112112
lambdaworks-crypto = "0.11.0"
113113
tui-logger = { version = "0.17.3", features = ["tracing-support"] }
114114
rayon = "1.10.0"
115+
rkyv = "0.8.10"
115116

116117
[patch.crates-io]
117118
secp256k1 = { git = "https://github.com/sp1-patches/rust-secp256k1", tag = "patch-0.29.1-sp1-5.0.0" }

crates/common/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ hex.workspace = true
2929
lazy_static.workspace = true
3030
rayon.workspace = true
3131
url.workspace = true
32+
rkyv.workspace = true
3233

3334
[dev-dependencies]
3435
hex-literal.workspace = true

crates/common/common.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ pub use bytes::Bytes;
66
pub mod base64;
77
pub use ethrex_trie::{TrieLogger, TrieWitness};
88
pub mod kzg;
9+
pub mod rkyv_utils;
910
pub mod tracing;
1011
pub mod utils;

0 commit comments

Comments
 (0)