Skip to content

Commit 83647a6

Browse files
committed
packet: Use Bytes instead of an array in Packet
The reason behind the switch is that `Packet` gets cloned in multiple places. `Bytes` provides a zero-copy abstraction, where calling `clone()` doesn't make an actual copy of the underlying data and all instances point to the same memory. However, the old layout containing a sized array is convenient for CUDA. To not break CUDA support, this change introduces a new struct called `PacketArray`, which a `Packet` can be converted into just before calling GPU-based sigverify. That requires a copy, ideally just one. At the same time, CPU-based sigverify and all the other components are going to benefit from zero-copy properties of `Bytes`.
1 parent 9919546 commit 83647a6

File tree

4 files changed

+416
-120
lines changed

4 files changed

+416
-120
lines changed

Cargo.lock

Lines changed: 4 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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ bs58 = { version = "0.5.1", default-features = false }
140140
bv = "0.11.1"
141141
bytemuck = "1.21.0"
142142
bytemuck_derive = "1.8.1"
143+
bytes = { version = "1.10", features = ["serde"] }
143144
cfg_eval = "0.1.2"
144145
chrono = { version = "0.4.39", default-features = false }
145146
console = "0.15.10"

packet/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ edition = { workspace = true }
1212
[dependencies]
1313
bincode = { workspace = true, optional = true }
1414
bitflags = { workspace = true }
15+
bytes = { workspace = true }
1516
cfg_eval = { workspace = true, optional = true }
1617
serde = { workspace = true, optional = true }
1718
serde_derive = { workspace = true, optional = true }

0 commit comments

Comments
 (0)