-
Notifications
You must be signed in to change notification settings - Fork 239
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
Switch sendmmsg wrapper to use stack allocated libc types #3569
Comments
Something similarly related but maybe best for another issue - Gossip and Repair both spawn a agave/streamer/src/streamer.rs Lines 390 to 396 in 7629a15
which calls batch_send() via recv_send() :agave/streamer/src/streamer.rs Lines 347 to 365 in 7629a15
In And on a similar vein, we may benefit from patching some of the packets on the other side of the channel: agave/gossip/src/cluster_info.rs Lines 2214 to 2219 in 7629a15
I haven't dug through this code extensively, but I see that we send to the |
Problem
On Linux based validators (ie all validators on MNB as far as we know), we use
sendmmsg
to potentially send multiple packets while incurring a single system call. In order to usesendmmsg
, we have to populate somelibc
types; we do this inbatch_send()
:agave/streamer/src/sendmmsg.rs
Lines 145 to 167 in 7629a15
Note that we allocating vectors here:
agave/streamer/src/sendmmsg.rs
Lines 152 to 154 in 7629a15
Proposed Solution
sendmmsg
has a limit of 1024 packets per call*, so we could allocate 1024-element fixed size arrays on the stack to avoid the extra allocations every time this function is called. The three types in question have following size (as reported bystd::mem::size_of
):libc::iovec
==> 16 byteslibc::mmsghdr
==> 64 byteslibc::sockaddr_storage
==> 128 bytesSo, in total that would be:
This seems like a reasonable tradeoff given how often this function is getting called
*https://man7.org/linux/man-pages/man2/sendmmsg.2.html
The text was updated successfully, but these errors were encountered: