1
0
mirror of https://github.com/facebookincubator/mvfst.git synced 2025-11-09 10:00:57 +03:00
Commit Graph

236 Commits

Author SHA1 Message Date
Konstantin Tsoy
e208ceffdd Implement group streams receiver api in transport
Summary: Implement group streams receiver api in transport

Reviewed By: mjoras

Differential Revision: D36419901

fbshipit-source-id: 98bfefa1a4205fde8764f2e4300f51156667e024
2022-06-06 17:11:39 -07:00
Konstantin Tsoy
ad6a0e9cbb Implement group streams sender api in transport
Summary: Implement group streams api in transport

Reviewed By: mjoras

Differential Revision: D36417214

fbshipit-source-id: dee93807fe061f2abd9c779da9a2cd1df1865c3e
2022-06-03 15:47:17 -07:00
Konstantin Tsoy
80b9c6274e Stream groups API
Summary: Add stream groups interface

Reviewed By: mjoras

Differential Revision: D36416440

fbshipit-source-id: 4a757428c9f38f52e4c8d0feb2149d598a748904
2022-06-03 15:47:17 -07:00
Konstantin Tsoy
5656e382e5 Create a reset() util function for outstandings
Summary: Create a reset() util function for outstandings

Reviewed By: jbeshay

Differential Revision: D36148759

fbshipit-source-id: 04473b959ec9024c27afac67aca9937b12d7edd0
2022-05-06 12:59:45 -07:00
Matt Joras
b48420185e Clear lastProcessedAckEvents in same loop
Summary: Deferring it to the next read causes a bunch of data to go out of cache, which guarantees a cache miss when we try to clear it. Instead, clear it immediately after the callbacks.

Reviewed By: bschlinker

Differential Revision: D36151205

fbshipit-source-id: 467a45e2ef901b5705fb3db38d2648ba97784c8d
2022-05-05 16:22:02 -07:00
Brandon Schlinker
a9cd97dbbf Packets received event for observer
Summary: Add observer event for packets received.

Differential Revision: D35708803

fbshipit-source-id: 7a58045c4153f797170731cfe31de60aef343036
2022-04-20 03:36:44 -07:00
Brandon Schlinker
744ae1f78e Use folly::ObserverContainer for socket observer [4/x]
Summary:
This diff is part of larger change to switch to using `folly::ObserverContainer` (introduced in D27062840).

This diff:
- Changes `LegacyObserver` to inherit from the new `Observer` class by adding a compatibility layer. This compatibility layer enables existing observers to continue to be supported.
- Changes generation of observer events so that they are routed through `ObserverContainer::invokeInterfaceMethod`
- Temporarily removes some of the reentrancy protection that previously existed, as it was not being applied consistently — some events had reentrancy protection, some did not. This will be reintroduced in the next diff.
- Improves some unit tests for observers during the transition process.

Differential Revision: D35268271

fbshipit-source-id: 5731c8a9aa8da8a2da1dd23d093e5f2e1a692653
2022-04-18 04:19:31 -07:00
Brandon Schlinker
f20eb76865 Use folly::ObserverContainer for socket observer [3/x]
Summary:
This diff is part of larger change to switch to using `folly::ObserverContainer` (introduced in D27062840).

This diff:
- Adds methods to `QuicSocket` to support adding and removing `ObserverContainer` observers. By default, `QuicSocket` implementations will not support observers as `QuicSocket::getSocketObserverContainer` returns `nullptr`, and this will cause `QuicSocket::addObserver` and `QuicSocket::removeObserver` to fail gracefully.
- Adds support in `QuicClientTransport` and `QuicServerTransport` for `ObserverContainer` observers by overriding `getSocketObserverContainer`. Each implementation creates an `ObserverContainer` on construction that is destroyed on destruction.
- Adds the `close` event to the new observer interface and adds corresponding support in `QuicTransportBase`. This allows both the old and new observers to receive the close event. The next diff will do a hard cutover of the rest of the events.

Differential Revision: D35000960

fbshipit-source-id: e75807c97f4385532bf36244591a259aa0a2f4cc
2022-04-18 04:19:31 -07:00
Brandon Schlinker
ea056eb960 Use folly::ObserverContainer for socket observer [2/x]
Summary:
This diff is part of larger change to switch to using `folly::ObserverContainer` (introduced in D27062840).

This diff:
- Renames `quic::Observer` to `quic::LegacyObserver`.
- Switches to using `quic::SocketObserverInterface` instead of `quic::Observer` when referencing structures used for the observer interface. For instance, `quic::Observer::WriteEvent` changes to `quic::SocketObserverInterface::WriteEvent`.

Differential Revision: D35000152

fbshipit-source-id: f387231fd58e8e763c3d7ed0a9c6fcec3b2324e2
2022-04-18 04:19:31 -07:00
Duc Nguyen
928c015171 Ensure socket is open when determining a socket is good
Summary:
Check `CloseState` to ensure the socket open when determining a socket is good.

`QuicSocket::good` notes that a socket is good iff the transport is open and ready.

Reviewed By: bschlinker

Differential Revision: D35661700

fbshipit-source-id: 46d4cf3ae57bd79c0efbea0d03dab7a92a43f33b
2022-04-15 13:16:11 -07:00
Brandon Schlinker
feb8455dc6 Add RTT with ACK delay removed to TransportInfo
Summary: Make `min(minRTT - ACK delay)` obsered so far over the life of the connection available in `TransportInfo`. In addition, expose the last RTT and last RTT's AckDelay value as well.

Reviewed By: mjoras

Differential Revision: D28385923

fbshipit-source-id: a58000ac8bd9fdc63caa0b636bdb83905cd6b448
2022-03-28 23:26:30 -07:00
Brandon Schlinker
6a1665ba74 PacketsWrittenEvent triggered when no congestion controller
Summary: Trigger `PacketsWrittenEvent` even if no congestion controller is installed. We previously had it require a congestion controller because it was related to the app limited event.

Differential Revision: D34541746

fbshipit-source-id: 3dc0930cbbc8b190fb63c31dffb76c8274c8e9d3
2022-03-28 23:26:30 -07:00
Brandon Schlinker
da71a15307 Add CWND and writable bytes to PacketsWrittenEvent
Summary: Extend `PacketsWrittenEvent` to include the CWND and number of writable bytes from the congestion controller after the write completed. If no congestion controller is installed, these values are left blank.

Differential Revision: D32588533

fbshipit-source-id: 4b8361937fcab36daa17e5f6dc4386762987d2b4
2022-03-28 23:26:30 -07:00
Brandon Schlinker
b243d2bdd8 Number bytes written in packets written event
Summary: Report all bytes written in observer packets written events.

Reviewed By: jbeshay

Differential Revision: D33086404

fbshipit-source-id: 1456cf23a420abd025f047f190cb2b8a9868826e
2022-03-23 08:50:12 -07:00
Joseph Beshay
a105868ecc Test for presence of traffic shapers using a token bucket in BbrTesting and use that to inform bandwidth estimates
Summary:
This is an experiment to improve BBR's performance with bursty traffic when a traffic shaper is present in the path. The change is fully contained within BbrTesting.

Currently, with every new request, BBR generates a high bandwidth estimate from the shaper's burst that is not valid once's the shaper's burst has expired. This causes BBR to introduce unnecessary queuing delay until the bandwidth estimate has reacted to the shaper's rate. When the requests are small enough and are separated by an interval of inactivity, this behavior repeats with every request causing bursts of queueing delay.

This change attempts to detect the presence of certain common shaper configurations. If the presence of a shaper is detected with sufficient confidence, the shaper's rate is used to limit the bandwidth estimate of BBR.

Reviewed By: bschlinker

Differential Revision: D34483728

fbshipit-source-id: 7d27b1383b01381140aa7cae340889fb49cb5a5e
2022-03-14 11:04:38 -07:00
Joseph Beshay
ba8b190a97 Knobs are supported in MVFST_EXPERIMENTAL too
Summary: Check for MVFST_EXPERIMENTAL when deciding whether knob frames are supported

Reviewed By: mjoras

Differential Revision: D34694138

fbshipit-source-id: b3563b0a5baf2fa7b060a494bb74402f43c7c3d1
2022-03-08 11:01:38 -08:00
Luca Niccolini
8d3bdbda25 Fix connection close stats callback
Reviewed By: afrind

Differential Revision: D34489976

fbshipit-source-id: ccf2645da524b36ab0fdea2b4bc4d23136838081
2022-02-25 18:43:46 -08:00
Joseph Beshay
f829871a07 Enable initializing BBR with guesses for cwnd and minrtt
Summary:
- Enable starting BBR with an initial cwnd and minrtt guesses.
- Add minrtt to QuicConnectionStats
- Add unit test for new BBR constructor

Reviewed By: mjoras

Differential Revision: D34438518

fbshipit-source-id: 58607cd3b1424a3f1f006dee94f910a29103826b
2022-02-25 11:43:48 -08:00
Matt Joras
360c211738 Keepalive timer support
Summary:
This implements a basic keepalive timer at the transport layer.

The basic idea is to leverage the same conditions as the idle timer. The keepalive timer will fire ~15% before the idle timer and trigger a PING frame. This has the effect of keeping the connection open if the PING is acknowledged.

Reviewed By: jbeshay

Differential Revision: D34256174

fbshipit-source-id: a8cee579f5b09bdfa23bcdc7cf4c70de299de3bd
2022-02-24 12:40:01 -08:00
Konstantin Tsoy
a70ffbeb29 Rename ConnectionCallbackNew back to ConnectionCallback
Summary: Rename ConnectionCallbackNew back to ConnectionCallback

Reviewed By: mjoras

Differential Revision: D33979956

fbshipit-source-id: 6c133a406c4bf6799838ffc36701267a938cb4a3
2022-02-23 12:57:31 -08:00
Konstantin Tsoy
bd6e117a56 Add a helper function to set default error code for close() and
Summary:
Add a helper function to set default error code for close() and
closeNow()

Reviewed By: mjoras

Differential Revision: D34191863

fbshipit-source-id: 8f818f471307ea64ed046ec5e93852566247faa3
2022-02-22 14:24:23 -08:00
Konstantin Tsoy
2e468b5e5d Add new connection end cb option to client/server transport
Summary: Add new connection end cb option to client/server transport

Reviewed By: mjoras

Differential Revision: D34190871

fbshipit-source-id: 375cf95bc8dbe4ab759140cfb4b33b732869953f
2022-02-22 14:24:23 -08:00
Konstantin Tsoy
3b6f2cf2c0 Simplify callback invocation on connection end/error
Summary: Simplify callback invocation on connection end/error

Reviewed By: mjoras

Differential Revision: D34190297

fbshipit-source-id: d0a124d392a96cc7596bf7feb45ec35a7e27dbbf
2022-02-16 09:49:35 -08:00
Konstantin Tsoy
54ce32396c get rid of callbacks indirection layer
Summary: get rid of callbacks indirection layer

Reviewed By: mjoras

Differential Revision: D34189595

fbshipit-source-id: e4a0aba768b17054f06091c12ef66f1a8019885f
2022-02-15 11:45:09 -08:00
Konstantin Tsoy
3872f0dd89 Remove unused function
Summary: Remove unused function

Reviewed By: mjoras

Differential Revision: D34184684

fbshipit-source-id: cd254c64790ad8024484bf91e68db6a47e054ce2
2022-02-15 11:45:09 -08:00
Konstantin Tsoy
cecc1ba279 Introduce QuicError struct
Summary: Instead of using std::pair everywhere

Reviewed By: mjoras

Differential Revision: D34146686

fbshipit-source-id: dfe48f43775de868aba06a5b9b5a004e5793bdbb
2022-02-14 16:00:21 -08:00
Elijah Staple
b57802721e Add ReadDatagram struct and update readDatagrams callback
Summary: In order to provide more information about datagrams when we receive them, I'm adding a wrapper around the BufQueue that we currently hold so we can include receiveTimePoint and any other metadata we might want to expose for the Datagram API.

Reviewed By: mjoras

Differential Revision: D33994358

fbshipit-source-id: 805f182cd350908320639bc07eb6f3b7349bbc05
2022-02-10 16:47:06 -08:00
Luca Niccolini
878ee7318b Fix shutdown when deleting eventbase
Reviewed By: kvtsoy

Differential Revision: D33908361

fbshipit-source-id: e133d9be0a744831586a213add98c5a4ae4457a2
2022-02-09 20:12:04 -08:00
Konstantin Tsoy
dc79176a56 Deprecate old connection callback
Summary: Deprecate old connection callback

Reviewed By: jbeshay, lnicco

Differential Revision: D33695440

fbshipit-source-id: 043baa53b71453b5e2b9f60d890f1adcda7c65b5
2022-02-02 19:03:57 -08:00
Joseph Beshay
f2b7525592 Add BBR-based congestion controller to test using short-term bandwidth estimates while BBR is cruising or draining
Summary:
BBRv2 draft has two different types of bandwidth samples to be used in different situations. A long-term estimate that is used while probing, and a short-term estimate that is more sensitive to congestion signals.

This change adds a new congestion controller (bbr_testing) that attempts a simpler version of the BBRv2 suggestion on top of the existing BBR implementation. In bbr_testing, if the connection is draining or cruising (pacing_gain=1), the latest bandwidth sample will be used by BBR instead of one from the max filter.

Theoretically, this allows BBR to still achieve a good estimate when probing for available bandwidth, while avoiding unnecessary queueing if the bandwidth changes while cruising. This should reduce queueing on links that have a shaper with bursts.

This can be used in `hq` as follows:
```
./hq --mode server --host "::" -congestion=bbr_testing -pacing=1
```

Reviewed By: bschlinker

Differential Revision: D33344876

fbshipit-source-id: 32ef9ecacc7a7692cb1e4bd59284bc1adadd35b5
2022-01-27 17:33:38 -08:00
Luca Niccolini
3898b5a9d3 QUIC/HTTP3: reset idle timeout on ping
Summary:
Adds a transport callback for ping received.
Uses the callback in the HTTP3 session to reset the timeout
Also now invokes the ping callbacks synchronously to avoid issues during connection shutdown

Reviewed By: mjoras

Differential Revision: D33753068

fbshipit-source-id: 99ac14d0e4b9539f3a20c5c55bb5241351bf1c57
2022-01-26 17:29:53 -08:00
Luca Niccolini
60ad67ffff Back out "QUIC/HTTP3: reset idle timeout on ping"
Summary:
Original commit changeset: d6fcecd22cbd

Original Phabricator Diff: D33101180 (15390c732a)

Reviewed By: afrind, kvtsoy

Differential Revision: D33743341

fbshipit-source-id: 3abf82db83125659a447f1c95330c85f21eed9b6
2022-01-24 08:52:37 -08:00
Luca Niccolini
15390c732a QUIC/HTTP3: reset idle timeout on ping
Summary:
Adds a transport callback for ping received.
Uses the callback in the HTTP3 session to reset the timeout

Reviewed By: mjoras

Differential Revision: D33101180

fbshipit-source-id: d6fcecd22cbd5c311674dd9421c0c54eb04728a0
2022-01-21 16:43:27 -08:00
Hani Damlaj
00e67c1bf9 mvfst License Header Update
Reviewed By: lnicco

Differential Revision: D33587012

fbshipit-source-id: 972eb440f0156c9c04aa6e8787561b18295c1a97
2022-01-18 13:56:12 -08:00
Hani Damlaj
2660a288b3 Update Company Name
Summary: - as title

Reviewed By: lnicco

Differential Revision: D33513410

fbshipit-source-id: 282b6f512cf83b9abb7990402661135b658f7bd1
2022-01-13 12:07:48 -08:00
Joseph Beshay
a73eade468 Add more fields to Qlog Transport Summary to track spurious retransmissions
Summary:
Add three new fields to the qlog transport summary to help analyze spurious transmissions and how they are affected by using adaptive loss thresholds.

Sample transport summary with added fields:
```
          "transport_summary",
          {
            "current_conn_flow_control": 1068498609,
            "current_writable_bytes": 106330,
            "dsr_packet_count": 0,
            "final_packet_loss_reordering_threshold": 77,
            "final_packet_loss_time_reordering_threshold_dividend": 29,
            "quic_version": 4207849474,
            "sum_cur_stream_buffer_len": 0,
            "sum_cur_write_offset": 5243215,
            "sum_max_observed_offset": 67,
            "total_bytes_cloned": 0,
            "total_bytes_recvd": 38157,
            "total_bytes_retransmitted": 244982,
            "total_bytes_sent": 5605121,
            "total_crypto_data_recvd": 342,
            "total_crypto_data_written": 1548,
            "total_packets_spuriously_marked_lost": 203,
            "total_stream_bytes_cloned": 0,
            "used_zero_rtt": false
          }
```

Reviewed By: afrind, mjoras

Differential Revision: D33354583

fbshipit-source-id: 55d9880ef02f6914b74c1b6508863bea7807950b
2022-01-07 18:42:12 -08:00
Brandon Schlinker
b9419f04b9 Make minRTT an optional in TransportInfo
Summary: `mrtt` in `TransportInfo` currently defaults to max val if it has not been measured yet (start of connection, end of connection that never had any ACKs, etc.). Downstream consumers may not realize this, which leads to a mess. Changes it into an optional.

Reviewed By: mjoras

Differential Revision: D28383235

fbshipit-source-id: 0f103dd880e96ba60b08e0834c4ecbab81dc4221
2021-12-12 17:04:46 -08:00
Brandon Schlinker
c051ff1299 AcksProcessedEvent observer event
Summary:
Providers observers with insight into ACKs received. Works for both client and server transport.

Attempts to prevent wasted memory by removing any allocated memory for ACK events if no packets in flight. In tandem, reduces allocs by _not_ removing allocated memory when packets are in flight (as this means more ACK events will occur soon...).

Reviewed By: jbeshay

Differential Revision: D31221280

fbshipit-source-id: 64b73aa74c757ebbfc27bb9c2a047d08dc7a77ca
2021-12-08 08:16:28 -08:00
Brandon Schlinker
20c17a882b PacketsWrittenEvent observer event
Summary:
Currently the `packetsWritten` observer event is only triggered when ACK-eliciting packets are written to the network. This change makes it so that the event is triggered even when non ACK-eliciting packets are written. In addition, this change increases the information provided in the observer event to reduce the processing that must be performed by observers.

More specifically, this diff makes the following changes:
- It creates two new structs — `WriteEvent` and `PacketsWrittenEvent` — and makes `PacketsWrittenEvent` and `AppLimitedEvent` inherit from `WriteEvent`, which contains the base set of fields that appear in both derived events. The base set of fields includes `writeCount` and the reference to the list of `OutstandingPackets`.
- A `PacketsWrittenEvent` is generated after each write loop during which packets are written.
  - The `PacketsWrittenEvent` records the total number of packets written (the sum of ACK-eliciting and non ACK-eliciting packets written) and the total number of ACK-eliciting packets written during the last loop. By exposing this information, observers can determine whether there is value in inspecting the list of `OutstandingPackets` before doing so.
  - In the future, I'll extend this event to also report the number of stream bytes written.
- It adopts a new builder pattern for observer events to make it easier to create instances of these structures:
  - We use this approach instead of aggregate initialization (specifically designated initializers via aggregate initialization), because designated initializers (C++20 feature, although supported by some compilers long before) is not yet supported on all platforms for which we need this code to compile.
  - I intend to change the other observer events to use this pattern as the number of arguments in some of their constructors makes them increasingly difficult to deal with.

Reviewed By: mjoras

Differential Revision: D31216724

fbshipit-source-id: 42ceb922d46ab0e0dc356f8726c2d0467a219587
2021-12-03 11:17:14 -08:00
Brandon Schlinker
d89e8d344e Observer stream events
Summary: Provide observers with visibility into stream events triggered by local and peer (e.g., new stream opened locally or by peer).

Reviewed By: mjoras

Differential Revision: D31886978

fbshipit-source-id: 7556fef0f336bd0f190b4474f1a7b0120aae6ef1
2021-12-03 11:17:14 -08:00
Brandon Schlinker
523d193944 Only call close() once for QuicSocket::Observers
Summary: As titled. We currently allow `QuicSocket::Observer::close` to be called multiple times. Only call it once.

Reviewed By: lnicco

Differential Revision: D31886995

fbshipit-source-id: 61d959e8575b08c34ef896b87da0cf8ada482144
2021-12-03 11:17:13 -08:00
Luca Niccolini
324d819795 add stats for quic datagram
Summary: Add stats for quic datagrams

Reviewed By: afrind

Differential Revision: D32600300

fbshipit-source-id: 79ebcec5bd090dad16f81237b6b2c0fe4c0f2af6
2021-12-01 00:13:03 -08:00
Joseph Beshay
fdd43602a4 Fix field order in VLOG message
Summary: Fix wrong order of fields in a VLOG message.

Reviewed By: lnicco

Differential Revision: D32106255

fbshipit-source-id: 50367a5000cb2033ecafaa6ef389971bc88a9a60
2021-11-02 13:37:14 -07:00
Joseph Beshay
ea2af0fe10 Control a connections bandwidth utilization factor in QuicTransportBase (background mode)
Summary:
The StreamManager monitors can now have a reference to a new observer interface QuicStreamPrioritiesObserver. If the reference is set, the observer is notified whenever streams are created, removed, or change priorities

QuicTransportBase implements this observer interface. It uses the event notifications to control a connection's background mode based upon the new background mode parameters: priority level threshold, and target utilization factor. When these parameters are set, and all active streams have a priority lower than the threshold, the connection's congestion controller is set to use only the defined utilization factor of the available bandwidth.

Reviewed By: bschlinker

Differential Revision: D31562505

fbshipit-source-id: 9c74fa834301f745d97e851741b911795f756023
2021-10-22 14:52:29 -07:00
Nikhil Dixit Limaye
e403564b28 Add detailed quic RST_STREAM and CONNECTION_CLOSE ods counters
Summary: Add global counters for QUIC stream reset and connection close

Reviewed By: lnicco

Differential Revision: D30877776

fbshipit-source-id: 4ee7c3f7c3c1cf190f464e74d616e0b5f1539d3a
2021-10-18 17:16:26 -07:00
Alan Frindell
3d19c7a512 Add split connection callbacks to MockQuicSocket
Summary: As in title

Reviewed By: kvtsoy, lnicco

Differential Revision: D31669761

fbshipit-source-id: 412dc3b47f4ceacbb5719295a95e6d3fd8f2cff9
2021-10-18 11:57:36 -07:00
Luca Niccolini
fbae03019c make datagram read and write buf limits configurable
Summary: make datagram read/write bufs configurable via transport settings

Reviewed By: mjoras

Differential Revision: D31562545

fbshipit-source-id: c80c54f1ca412b464d08dd05c7580511f9b6fafc
2021-10-13 12:01:25 -07:00
Konstantin Tsoy
41be39b61b Introduce split callbacks
Summary:
This diff introduces split callbacks to QUIC.
Old: callback:
* `ConnectionCallback`
Two new callbacks:
* `ConnectionSetupCallback`
* `ConnectionStreamsCallback`

For now the idea is that both old and new callbacks will live side by side and mvfst will decide which callbacks scheme to use via the `useSplitConnectionCallbacks` flag supplied on both QUIC client and server creation.

Reviewed By: mjoras

Differential Revision: D30407129

fbshipit-source-id: 7b726c2652ebe00b47f44bf291cffb9d9f6c884b
2021-09-11 17:38:51 -07:00
Konstantin Tsoy
4f35477729 Do not call onAppRateLimited() before connection is ready
Summary: Do not call onAppRateLimited() before connection is ready

Reviewed By: bschlinker

Differential Revision: D30563194

fbshipit-source-id: dd8c2da656041f9219a645935b6c4c3c85b27816
2021-08-31 18:27:40 -07:00
Konstantin Tsoy
29e560813b Connection callback indirection object
Summary:
This is another diff preparing mvfst for the new split callbacks.
This change introduces a callback dispatcher. Right now, it simply calls the existing monolithic callback everywhere. In future diffs, this dispatcher will be using the `useSplitCallbacks` flag to decide which callback object to call.

Reviewed By: mjoras

Differential Revision: D30404458

fbshipit-source-id: 5bb919185b845acc3e8ce7c596c0769b541ff69d
2021-08-31 18:27:40 -07:00