reduce buffer size of "unused" side of socket#9218
Conversation
04e155e to
8738b08
Compare
| let control_traffic_buffer_size = 4 * 1024 * 1024; | ||
|
|
||
| let read_write_socket_config = SocketConfig::default(); | ||
| let primarily_read_socket_config = | ||
| SocketConfig::default().send_buffer_size(control_traffic_buffer_size); | ||
| let primarily_write_socket_config = | ||
| SocketConfig::default().recv_buffer_size(control_traffic_buffer_size); |
There was a problem hiding this comment.
this is a number based off a what alessandro said a year ago: https://discord.com/channels/428295358100013066/478692221441409024/1309346044517023794. also not sure if we want to set the value even smaller for udp traffic (retransmit, broadcast, tvu, etc).
There was a problem hiding this comment.
I'll add suggested values in PR description since you have a nice list going there.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #9218 +/- ##
=========================================
- Coverage 82.9% 82.9% -0.1%
=========================================
Files 847 847
Lines 320563 320618 +55
=========================================
+ Hits 265789 265806 +17
- Misses 54774 54812 +38 🚀 New features to boost your workflow:
|
|
To consider - for something like TVU retransmit sockets, what would be the downside of setting RX buffer to zero (since it is never used)? |
|
@gregcusack @alexpyattaev a couple nuances :-) note that these buffers aren’t pre-allocated on Linux. The value simply limits how much the receive buffer can hold as data arrives. Internally, the Linux kernel also doubles this value: Incoming data is kept in e.g. here the kernel checks if more data can be enqueued for UDP: |
Yes, this is understood. Nevertheless, no point allowing bloated buffers when we clearly have no productive use for them. If we are under serious flood it is better to shed the packets rather than buffer them for seconds and then shed anyway. |
8738b08 to
a8fd1e0
Compare
|
For this PR, I'd like to focus specifically on sockets that are not bidirecational - aka read only or write only. Adjusting the buffer sizes for read/write sockets is going to take a decent amount of profiling on mnb nodes. According to agave validator docs, the max buffer sizes should be set to 128 MB. See: agave/docs/src/operations/setup-a-validator.md Lines 317 to 321 in 6133008 setsockopt on the socket and increases (limited by net.core.rmem_max and net.core.wmem_max).
EDIT: i'm not convinced we want to resize the "used side" of the sockets even in a follow up. Feels like that would fall on the operator to adjust those if needed |
Agreed. Let us narrow this one to setting unused side to zero buffers. This will also allow us to bp this easily. |
|
I want to resize the unused side of these sockets here. Below I am proposing what to set the unused side to. Read Only Sockets: <send buffer size> Write Only: <read buffer size> Note that for linux sockets we can try to set the buffer size to 0 but the kernel will set it to 2048 bytes (Send buffer) or 256 bytes (receive buffer). See: https://man7.org/linux/man-pages/man7/socket.7.html |
2673641 to
2e7844e
Compare
2e7844e to
bc9a742
Compare
alexpyattaev
left a comment
There was a problem hiding this comment.
LGTM conceptually, left a few small nits to address.
bc9a742 to
8bbe8c7
Compare
Follow Up to PR: #3929 and redo of: #4313
Problem
According to the agave validator docs, the max buffer sizes should be set to 128 MB. See:
agave/docs/src/operations/setup-a-validator.md
Lines 317 to 321 in 6133008
setsockopton the socket and increases (limited bynet.core.rmem_maxandnet.core.wmem_max).While the kernel doesn't pre allocate memory for these buffers, we want to prevent the kernel from allocating twice the memory for protocols that don't read AND write from their socket(s). For example,
retransmit_socketsare strictly write-only sockets. A peer can send to theretransmit_socketsand get the node to allocate memory that will never be used (except to hold the garbage data sent by the peer).The "unused" side of a socket is either the read or write side of the socket that is not used. So for
retransmit_socketsthe "unused" side is the read side. Fortvu, the unused side is the write side.Summary of Changes
Services/Sockets as defined in
Sockets:agave/gossip/src/cluster_info.rs
Lines 2369 to 2408 in e9052f0
Read/Write
Read Only : <send buffer size>
Write Only : <read buffer size>