streamer: set fixed RX window for all connections#9143
streamer: set fixed RX window for all connections#9143alexpyattaev merged 1 commit intoanza-xyz:masterfrom
Conversation
d5b96d6 to
306d3a1
Compare
| } | ||
|
|
||
| impl StakedNodes { | ||
| /// Calculate the stake stats: return the new (total_stake, min_stake and max_stake) tuple |
There was a problem hiding this comment.
This can be simplified now that min_stake and max_stake are not used anymore.
|
|
||
| let config = Arc::get_mut(&mut server_config.transport).unwrap(); | ||
|
|
||
| // QUIC_MAX_CONCURRENT_STREAMS doubled, which was found to improve reliability |
There was a problem hiding this comment.
This was doing nothing since we override these settings after handshake anyway.
| self.total_stake | ||
| } | ||
|
|
||
| #[inline] |
There was a problem hiding this comment.
min_stake and max_stake were only used in receive window calculations
| use super::*; | ||
|
|
||
| #[test] | ||
| fn test_cacluate_receive_window_ratio_for_staked_node() { |
| ); | ||
| stats.total_connections.fetch_add(1, Ordering::Relaxed); | ||
|
|
||
| connection.set_receive_window(CONNECTION_RECEIVE_WINDOW_BYTES); |
There was a problem hiding this comment.
this is the key change - we set RX window to const after connection is fully confirmed.
There was a problem hiding this comment.
minor: since we now disable streams in the default transport config in configure_server(), it should be safe to set the window value to CONNECTION_RECEIVE_WINDOW_BYTES there too. One less place that tweaks connection settings. wdyt?
alexpyattaev
left a comment
There was a problem hiding this comment.
Had to apply more changes to SimpleQos as it did not have own logic to set max_streams. Removing throttling from it completely is not possible since our throttling limits are very low (20 streams / s is normal), so just MAX_STREAMS is not granular enough to achieve enforcement we want for voting.
There was a problem hiding this comment.
For SimpleQos we either set max_streams to some constant, or compute based on RTT. Computing based on RTT seems less brittle.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #9143 +/- ##
=========================================
- Coverage 82.6% 82.6% -0.1%
=========================================
Files 890 890
Lines 320845 320773 -72
=========================================
- Hits 265285 265147 -138
- Misses 55560 55626 +66 🚀 New features to boost your workflow:
|
| /// connection to require more bandwidth. This prevents MAX_DATA from affecting | ||
| /// the bitrate achieved by a single connection. Actual throttling is achieved based | ||
| /// on the number of concurrent streams. | ||
| const CONNECTION_RECEIVE_WINDOW_BYTES: VarInt = VarInt::from_u32(8 * 1024 * 1024); |
There was a problem hiding this comment.
I'd remove the "unreasonable to expect a single connection..." part and expose this setting via config. No need to enforce strict limits.
There was a problem hiding this comment.
Then we will have to explain to users how to choose this value. Our users build from source anyway, can customize it if they really want to.
|
I agree that we should used stake parametrization for only one of these MAX_DATA or MAX_STREAMS. Reasoning in terms of streams (transactions) might be simpler for users. Although we can have many small transactions and limiting streams might be a bit more restrictive but since the idea that we don't restrict users when we have some bandwidth for them, doesn't sound like a blocking thing. Have we checked in some stress tests of isolated streamer + mock-client that this change doesn't lead to any surprises if any? |
| if let Ok(receive_window) = receive_window { | ||
| connection.set_receive_window(receive_window); | ||
| } | ||
| connection.set_max_concurrent_uni_streams(max_uni_streams); |
There was a problem hiding this comment.
Why not apply RTT-based scaling like we introduce in simple_qos? In this case, we should also ensure that senders don’t receive less than before -- at least until we have auto-tuning, and maybe even afterward unless these defaults turn out to be inadequate.
There was a problem hiding this comment.
In a separate PR. One small change at a time.
| // for very low values of max_streams_per_second, prevent connections from having zero | ||
| // streams in flight | ||
| let max_streams_in_flight = max_streams_in_flight.max(STREAMS_IN_FLIGHT_MARGIN); | ||
| connection.set_max_concurrent_uni_streams(VarInt::from_u32(max_streams_in_flight)); |
There was a problem hiding this comment.
It looks like the receive window remained to be set to PACKET_DATA_SIZE (default option in configure_server(), thus limiting votes TPS to 1 per RTT.
There was a problem hiding this comment.
No, the receive window is set for both QoS modules in the common code, see async fn handle_connection<Q, C>(...)
There was a problem hiding this comment.
Yes, I wanted to say the 1transaction/RTT problem exists in the current (before this PR) code.
There was a problem hiding this comment.
Yes, it does exist today indeed. And we're fixing it =)
fa4887e to
7abf156
Compare
Let us fix the QoS logic first to be correct, then we focus on making it performant.
Yes, this was tested against mock_clients. no TPS change compared to the case before the change. |
|
Backports to the beta branch are to be avoided unless absolutely necessary for fixing bugs, security issues, and perf regressions. Changes intended for backport should be structured such that a minimum effective diff can be committed separately from any refactoring, plumbing, cleanup, etc that are not strictly necessary to achieve the goal. Any of the latter should go only into master and ride the normal stabilization schedule. Exceptions include CI/metrics changes, CLI improvements and documentation updates on a case by case basis. |
(cherry picked from commit a155621) # Conflicts: # streamer/src/nonblocking/simple_qos.rs # streamer/src/nonblocking/swqos.rs # streamer/src/streamer.rs
(cherry picked from commit a155621) # Conflicts: # streamer/src/nonblocking/simple_qos.rs # streamer/src/nonblocking/swqos.rs # streamer/src/streamer.rs
…9143) (#9330) * streamer: set fixed RX window for all connections (#9143) (cherry picked from commit a155621) # Conflicts: # streamer/src/nonblocking/simple_qos.rs # streamer/src/nonblocking/swqos.rs # streamer/src/streamer.rs * resolve conflicts --------- Co-authored-by: Alex Pyattaev <alex.pyattaev@anza.xyz>
Problem
Summary of Changes