Skip to content
This repository was archived by the owner on Jan 22, 2025. It is now read-only.

Multi packet size support - WIP#21756

Closed
ryleung-solana wants to merge 34 commits intosolana-labs:masterfrom
ryleung-solana:multi_packet_size
Closed

Multi packet size support - WIP#21756
ryleung-solana wants to merge 34 commits intosolana-labs:masterfrom
ryleung-solana:multi_packet_size

Conversation

@ryleung-solana
Copy link
Copy Markdown
Contributor

@ryleung-solana ryleung-solana commented Dec 9, 2021

Problem

We need to support larger transaction sizes than fit in 1 MTU. This is a first step, aiming to implement support for sending larger-than-1-MTU packets down to the OS's networking stack and letting it handle frag/defrag. Here, we want to support larger packet sizes, but don't want to incur the extra memory/memory bandwidth costs when unnecessary, so we will abstract the Packet struct to allow for different sized packet structures as needed, as well as adding the relevant code to send/receive larger packets, and do sigverify on them.

Summary of Changes

WIP - adds abstraction of the Packet struct into the PacketInterface trait, and future changes to implement a larger packet struct and add support for listening on different ports for the larger packets and doing sigverify on them.
Fixes #

@steviez steviez added the noCI Suppress CI on this Pull Request label Dec 9, 2021
@steviez steviez force-pushed the multi_packet_size branch 2 times, most recently from 19268c0 to 0aa9e73 Compare December 16, 2021 05:08
Copy link
Copy Markdown
Contributor

@jstarry jstarry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good so far, anything in particular you want feedback on? I was thinking that there may be a way around using the packet interface type you added if you have each packet just contain a slice into some larger data buffer allocated for each batch.

Comment thread streamer/src/recvmmsg.rs
Comment thread sdk/src/transaction/sanitized.rs Outdated
) -> Result<Self> {
tx.sanitize()?;

let size = bincode::serialized_size(&tx).map_err(|_| TransactionError::SanitizeFailure)?;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would be better to avoid this extra serialization if possible

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got rid of one serialization in one case, though agreed that ideally this wouldn't be here at all.

Comment thread sdk/src/program_utils.rs
// TODO verify. It seems that if one were using this with a regular packet
// the smaller data field would imply the original PACKET_DATA_SIZE bound anyway.
// Is there any reason we would not want to use EXTENDED_PACKET_DATA_SIZE here to
// be able to work with ExtendPacket as well?
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems fine to me as well

Comment thread sdk/src/packet.rs
#[derive(Clone)]
#[repr(C)]
pub struct ExtendedPacket {
pub data: [u8; EXTENDED_PACKET_DATA_SIZE],
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if packet data was just a slice into a larger chunk of data stored in a "PacketBatch"? That way we don't need multiple types for packets

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe; it's an interesting idea, and would also get rid of some of the other complexity we have with needing a separate port for the ExtendedPackets. Will take a look.

Comment thread perf/src/sigverify.rs
);
warn!("elem len: {}", elems.len() as u32);
warn!("packet sizeof: {}", size_of::<P>() as u32);
// todo: figure out what this means; the data field max size
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what are you trying to figure out? PACKET_DATA_SIZE should be the same as size_of::<Packet>() so that's what the trace log was probably for

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was mostly just wondering what this information this debug message was trying to convey, and if it had any importance now that we're modifying the max data size in the ExtendedPacket case. It was kind of confusing since the max data size doesn't actually seem to be used in figuring out any of the offsets. Not a huge deal, and will remove the TODO soon.

@ryleung-solana
Copy link
Copy Markdown
Contributor Author

Looking good so far, anything in particular you want feedback on? I was thinking that there may be a way around using the packet interface type you added if you have each packet just contain a slice into some larger data buffer allocated for each batch.

Nothing in particular, was just hoping to start getting some eyes on this.

Steven Czabaniuk and others added 19 commits January 6, 2022 16:58
This PacketInterface trait is plumbed through all the way from socket
recv() / send() code up to TPU/TVU stages. The existing Packet struct
provides an implementation of PacketInterface called StandardPacket. For
all cases where the "regular" sized packets are sufficient, we just
provide the StandardPacket struct. For cases where we may desire larger
packets, we keep the code "templated" with the PacketInterface trait and
allow caller(s) to choose which packet they desire.

Sigverify / GPU code in general will still need some work to support
multiple sized packets, as this code uses some fixed offsets into Packet
arrays to function.

As of this commit, this branch builds with several warnings.

Co-authored-by: Ryan Leung <ryan.leung@solana.com>
Also removed some stale comments
ExtendedPacket sockets bind to these new ports and know to pull larger
packets from the network. These sockets are populated in the Node
struct, and then propagated throughout Tpu and the associated Tpu
stages.
…rt and add forwarding support for ExtendedPacket
May not be necessary on a cluster, but definitely needed for testing
with solana-test-validator. Also fixed an inversion error on function to
say whether extended needed or not.
Steven Czabaniuk and others added 8 commits January 6, 2022 17:05
This is more clean in terms of less lines of code, and should be
algorithmically more efficient than previous approach as we only need to
scan each transaction once now instead of twice.
…warding, sigverify_stage and send_transaction_service. Setting the log level of these messages to warn for now to allow for less verbose logs. TODO: clean up (and possibly add configuration options/remove some of this as development progresses)
@stale
Copy link
Copy Markdown

stale Bot commented Mar 2, 2022

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@stale stale Bot added the stale [bot only] Added to stale content; results in auto-close after a week. label Mar 2, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

noCI Suppress CI on this Pull Request stale [bot only] Added to stale content; results in auto-close after a week.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants