Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v1.17: quic: use smallvec to aggregate chunks, save 1 alloc per packet (backport of #735) #741

Merged
merged 1 commit into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ sha2 = "0.10.7"
sha3 = "0.10.4"
signal-hook = "0.3.17"
siphasher = "0.3.11"
smallvec = "1.13.2"
smpl_jwt = "0.7.1"
socket2 = "0.5.4"
soketto = "0.7"
Expand Down
5 changes: 3 additions & 2 deletions programs/sbf/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions streamer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ quinn-proto = { workspace = true }
rand = { workspace = true }
rcgen = { workspace = true }
rustls = { workspace = true, features = ["dangerous_configuration"] }
smallvec = { workspace = true }
solana-metrics = { workspace = true }
solana-perf = { workspace = true }
solana-sdk = { workspace = true }
Expand Down
7 changes: 4 additions & 3 deletions streamer/src/nonblocking/quic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use {
quinn::{Connecting, Connection, Endpoint, EndpointConfig, TokioRuntime, VarInt},
quinn_proto::VarIntBoundsExceeded,
rand::{thread_rng, Rng},
smallvec::SmallVec,
solana_perf::packet::{PacketBatch, PACKETS_PER_BATCH},
solana_sdk::{
packet::{Meta, PACKET_DATA_SIZE},
Expand Down Expand Up @@ -95,7 +96,7 @@ struct PacketChunk {
// the Packet and then when copying the Packet into a PacketBatch)
struct PacketAccumulator {
pub meta: Meta,
pub chunks: Vec<PacketChunk>,
pub chunks: SmallVec<[PacketChunk; 2]>,
}

#[allow(clippy::too_many_arguments)]
Expand Down Expand Up @@ -878,7 +879,7 @@ async fn handle_chunk(
meta.set_socket_addr(remote_addr);
*packet_accum = Some(PacketAccumulator {
meta,
chunks: Vec::new(),
chunks: SmallVec::new(),
});
}

Expand Down Expand Up @@ -1463,7 +1464,7 @@ pub mod test {
meta.size = size;
let packet_accum = PacketAccumulator {
meta,
chunks: vec![PacketChunk {
chunks: smallvec::smallvec![PacketChunk {
bytes,
offset,
end_of_chunk: size,
Expand Down
Loading