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

153 Commits

Author SHA1 Message Date
Sridhar Srinivasan
ac468ad891 Use ByteEvent as a key in maps and sets
Summary:
This commit demonstrates the use of ByteEvents in maps. Intentionally didn't define the custom comparator and hash function inside the quic library because we want consumers of ByteEvents to define equality of 2 ByteEvents in their own way.
This will help recipients of ByteEventCallback keep track of pending,
received and cancelled ByteEvents easily.

In addition, the behavior of registerByteEventCallback was modified to NOT allow duplicate registrations. A pair of registrations is considered duplicate if they both have the same stream ID, stream offset, ByteEvent type and recipient callback pointer. In such cases, registerByteEventCallback returns an INVALID_OPERATION error.
This is critical to make sure that ByteEvents work well in maps, which may be used by recipients.

Reviewed By: bschlinker

Differential Revision: D27100623

fbshipit-source-id: 084a4765fa6c98fdc1b98414fbd30582cf1e5139
2021-03-30 19:52:19 -07:00
Sridhar Srinivasan
f7a08066ce Track body bytes sent and acked
Summary:
Previously, we maintained state and counters to count both, header and body
bytes together. This commit introduces additional counters and state to keep
track of just the body bytes that were sent and acked etc. Body bytes received
will be implemented later.

Reviewed By: bschlinker

Differential Revision: D27312049

fbshipit-source-id: 33f169c9168dfda625e86de45df7c00d1897ba7e
2021-03-29 16:58:04 -07:00
Matt Joras
a92a24bdd5 Back out "Send probes for all spaces."
Summary: As in title. There's a bug here somewhere with empty write loops we need to find.

Reviewed By: yangchi

Differential Revision: D27279100

fbshipit-source-id: e1d26fbf8d6df1590d464a6504a8b940b46794e0
2021-03-23 16:10:12 -07:00
Matt Joras
bceb00346b Send probes for all spaces.
Summary:
Previously we would only send probes for the first space which had one available, i.e. Initial before Handshake before AppData. Since we only have one PTO timer this can lead to situations where we perpetually probe with only Initials, which can significantly delay the handshake if we should have probed with Handshakes.

With this diff we will keep the single PTO timer but aggressively write more probes from all spaces if they are available.

Additionally this refactors some counters into EnumArrays

Reviewed By: yangchi

Differential Revision: D27235199

fbshipit-source-id: ef3614a833bf0f02f5806846a1335fa7ac2a4dc8
2021-03-23 12:51:36 -07:00
Sridhar Srinivasan
0ddb6e77b5 add onByteEventRegistered callback
Summary:
Add an onByteEventRegistered callback that will be invoked when the
registration for a ByteEvent callback is successful.
This makes it easy for recipients of the callback to track the successful
registration AND callback recipt in a single place (the recipient class). For
example, if all successfully registered ByteEvents have been received, the
recipient can destroy itself safely, knowing that no more ByteEvents will be
sent to it.

Reviewed By: bschlinker

Differential Revision: D27100624

fbshipit-source-id: dbfeff1f4cf2367587fdb73cbd334165b3b159de
2021-03-18 18:13:42 -07:00
Matt Joras
386f6a840e Add number of streams to idle timeout error.
Summary: If we idle timeout when there are non control streams open, there could be some sort of issue especially with protocols like HTTP/3.

Reviewed By: yangchi

Differential Revision: D27017861

fbshipit-source-id: 319b839a641fa417a5026adf607c7bd0070cb66c
2021-03-15 07:50:00 -07:00
Sridhar Srinivasan
d2f005dc00 Add support for detecting start and stop of app rate limited scenarios
Summary:
Previously, we only had support for notifying observers when a QUIC socket
became application rate limited.

This change adds a similar notification when a socket does not become
application rate limited, i.e when the application *starts* writing data to the
socket - either for the first time on a newly established socket or after a
previous block of writes were written and the app had no more to write.
In addition, we include the number of outstanding packets (only those that are
carrying app data in them) so that observers can use this data to timestamp the
start and end of periods where the socket performs app data writes.

Reviewed By: yangchi

Differential Revision: D26559598

fbshipit-source-id: 0a8df7082b83e2ffad9b5addceca29cc03897243
2021-03-10 13:05:10 -08:00
Yang Chi
adc1e15eff Write a buffer's meta data into QUIC
Summary:
Instead of writing real data into the transport, we want to support a
use case where only its metadata is written to the transport. Sending of the
real data is delegated to another entity in such setup.

Reviewed By: mjoras

Differential Revision: D26131772

fbshipit-source-id: 4fcfa3a1626203f63c61898e6de089a3079d043d
2021-03-03 23:50:02 -08:00
Matt Joras
382c1cdcc6 Remove partial reliability from mvfst.
Summary: As in title.

Reviewed By: yangchi

Differential Revision: D26701886

fbshipit-source-id: c7b36c616200b17fbf697eff4ba0d18695effb45
2021-03-03 15:30:21 -08:00
Yang Chi
0b42e07216 Getter API of Quic stream priority
Summary: as title

Reviewed By: afrind, avasylev

Differential Revision: D26744365

fbshipit-source-id: 5c5d104ca76c77f14371c20d6f791fca8d7cfe38
2021-03-03 07:26:28 -08:00
Duc Nguyen
a38156a83d Add knob frame event to Observer
Summary: Extend the Observer to record events for all knob frame received.

Reviewed By: bschlinker

Differential Revision: D26325312

fbshipit-source-id: 810589d08be3614c8c091cccb7bb9fbdb5c65402
2021-03-03 07:26:27 -08:00
Matt Joras
1b86b23d65 Check read callback for nullptr.
Summary: It's legit to set this to nullptr before the callback is removed.

Reviewed By: yangchi, lnicco

Differential Revision: D26582589

fbshipit-source-id: 0119e06e6e5347a9080dc5a814551e7b44d64c74
2021-02-22 12:52:24 -08:00
Andrii Vasylevskyi
10a6feed49 Reset congestion controller after setting factory
Summary:
Before the change, there's no good way to recreate Cubic CC instance with custom CC factory, because Cubic is created by default.

On client side this requires calling setCongestionControl() or setTransportSettings() after calling setCongestionControllerFactory(), which is normally the case.

Reviewed By: yangchi

Differential Revision: D26401996

fbshipit-source-id: dfda39be835c67b9db42f726b3ac64c7b3d37c2f
2021-02-19 17:55:10 -08:00
Andrii Vasylevskyi
1303281a51 Create pacer before congestion controller
Summary: Allows CongestionControllerFactor to access Pacer and update it's state if needed

Reviewed By: yangchi

Differential Revision: D26382984

fbshipit-source-id: fd73fbb6f0989c52a1a2061670fb9e6b188049d6
2021-02-19 17:55:10 -08:00
Andrii Vasylevskyi
b1a364b9dd QuicConnectionStats type change from string to the "native"
Reviewed By: lnicco

Differential Revision: D26379617

fbshipit-source-id: 308d53ca86c2a2e774e3618038eece7091482ed8
2021-02-19 10:47:02 -08:00
Andrii Vasylevskyi
ba71671bb2 QuicConnectionStats for client socket
Summary: Adding QuiConnectionStats to client transport. Moving getConnectionsStats() logic from server worker into transport base class.

Reviewed By: lnicco

Differential Revision: D26316635

fbshipit-source-id: a384eee5d1bc7b23d908e0b03fafcc4ee962b0b9
2021-02-19 10:47:02 -08:00
Matt Joras
f29e003ee4 Introduce resetNonControlStreams
Summary: This function is useful for when an application wants to explicitly reset all its non-control streams in one go.

Reviewed By: yangchi

Differential Revision: D26490209

fbshipit-source-id: 747449938e4dcd58bee028835f34776e5314cdf9
2021-02-18 14:07:20 -08:00
Matt Joras
21f190220e Implement basic ACK_FREQUENCY support.
Summary: As in title. This doesn't actually send any frames, but implements basic support for the transport parameter and responding to the frames.

Reviewed By: yangchi

Differential Revision: D26134787

fbshipit-source-id: 2c48e01084034317c8f36f89c69d172e3cb42278
2021-02-02 19:02:40 -08:00
Yang Chi
7c23fc75cc remove the unsupported cork param from QUIC writeChain interface
Summary: this param is passed to transport then ignored

Reviewed By: avasylev

Differential Revision: D26133327

fbshipit-source-id: 459dd0132185513215ba034f213d4137d7b56ba1
2021-01-29 10:50:45 -08:00
Brandon Schlinker
f206c5125b Packets inflight, packets sent in OutstandingPacketMetadata
Summary:
- Adds counter of the number of ack-eliciting packets sent; useful for understanding lost / retransmission numbers
- Adds the following to `OutstandingPacketMetadata`
  - # of packets sent and # of ack-eliciting packets sent; this enables indexing of each packet when processed by an observer on loss / RTT event, including understanding its ordering in the flow of sent packets.
  - # of packets in flight; useful during loss analysis to understand if self-induced congestion could be culprit
- Fixes the inflightBytes counter in `OutstandingPacketMetadata`; it was previously _not_ including the packets own bytes, despite saying that it was.

Right now we are passing multiple integers into the `OutstandingPacket` constructor. I've switched to passing in `LossState` to avoid passing in two more integers, although I will need to come back and clean up the existing ones.

Differential Revision: D25861702

fbshipit-source-id: e34c0edcb136bc1a2a6aeb898ecbb4cf11d0aa2c
2021-01-21 21:11:56 -08:00
Brandon Schlinker
4c5874e062 Fix spurious loss count in TransportInfo
Summary: `QuicSocket::TransportInfo::packetsSpuriouslyLost` is not currently being set (always zero). Fixed this and renamed it to more closely match the other counters.

Differential Revision: D25999285

fbshipit-source-id: 34fd380a2e56f110234987e08f3a0220669afde8
2021-01-21 18:09:54 -08:00
Sridhar Srinivasan
bd1ed4b7c0 Make the important Observer callbacks configurable
Summary:
Given the large number of callbacks that are being triggered from the Observer
this change makes it possible to enable through a simple config, just the
subset of callbacks that a consumer is interested in receiving.

Observer and Socket Lifecycle callbacks are enabled by default, they are not
configurable.

Reviewed By: bschlinker

Differential Revision: D25879382

fbshipit-source-id: abe79ed92e958ddc96475c347f8ec7204400cdfa
2021-01-13 15:35:06 -08:00
Sridhar Srinivasan
27fe474171 Migrate the QUIC and TransportMonitor libraries to use the new unified Observer callback class
Summary:
We were using the LifecycleObserver and InstrumentationObserver classes
separately, to generate and receive callbacks.

This change migrates both these to use the unified Observer callback class and
adjusts the unit tests.

Reviewed By: bschlinker

Differential Revision: D25845845

fbshipit-source-id: c489400f5d70bccadbcc1d957136c5ade36b65ff
2021-01-13 15:35:06 -08:00
Andres Suarez
05d07cbfd0 Apply clang-format update fixes
Reviewed By: igorsugak

Differential Revision: D25849213

fbshipit-source-id: a2a538230e769b2c328ae3dd0a19dfbfd693fe3b
2021-01-09 15:39:52 -08:00
Yang Chi
c1223a2f78 Remove trailing _E from QUIC variant type
Summary:
I think this should just work without the trailing `_E`. It was added
when we mixed up our own union based variant and boost::variant. Some compiler
flags didn't like that. Now we no longer have mixed up cases, this should be
fine

Reviewed By: lnicco

Differential Revision: D25589393

fbshipit-source-id: 6430dc20f8e81af0329d89e6990c16826da168b8
2020-12-16 18:03:05 -08:00
Brandon Schlinker
68d660c46d Count number of packets sent and lost by type
Summary:
We currently have a count of the number of packets retransmitted, and the number of packets marked as lost spuriously, but we do *not* have the total number of packets sent or lost, which is necessary to calculate statistics such as % of packets retransmitted % of losses that are spurious.

At the moment, we do not count loss events for D6D packets. Will likely add a separate counter for those in a subsequent diff.

Reviewed By: xttjsn

Differential Revision: D25540531

fbshipit-source-id: 80db729eb8c91f7805d342f4aab302a5b3ca4347
2020-12-14 16:32:55 -08:00
Matt Joras
143289a784 Remove DefaultPacer
Summary: It is time. Also rename resetPacingTokens -> reset since there's no tokens anymore.

Reviewed By: yangchi

Differential Revision: D25073121

fbshipit-source-id: da68134a02abd3bfea99ac6618c07504e2990fb7
2020-12-10 20:56:42 -08:00
Yang Chi
ac3eb576cb Skip QUIC stream priority update if new priority is the same as current
Summary: as title

Reviewed By: mjoras

Differential Revision: D25400594

fbshipit-source-id: 62484e0fd7173217067fed2503d7fd0c5e23d5ce
2020-12-10 11:59:35 -08:00
Matt Joras
5914576cdf Return early from PR functions if not enabled.
Summary: As in title. These actually show up in profiles.

Reviewed By: avasylev

Differential Revision: D25288369

fbshipit-source-id: b2178f3cc446248bfd7129a6b4451d7c811fb593
2020-12-03 14:57:15 -08:00
Matt Joras
bddd13a94a Erase by stream ID instead of iterator.
Summary: If the onByteEventCanceled callback changes the map then the iterator will no longer be valid.

Reviewed By: lnicco

Differential Revision: D25283060

fbshipit-source-id: e32bc8bc343d8d50785985a0bb607ab43188e464
2020-12-02 14:59:18 -08:00
Yang Chi
7c85871c3e HTTP Priority update logging in QLog
Summary: as title

Reviewed By: mjoras

Differential Revision: D24903759

fbshipit-source-id: 39127b658e6cb06025272c1c5ab0f7de2ae1a54a
2020-11-17 20:21:49 -08:00
Yang Chi
000a0e23ca Add stream prioritization
Summary: Adds a top level API to set stream priorities, mirroring what is currently proposed in httpbis.  For now, default all streams to the highest urgency, round-robin, which mirrors the current behavior in mvfst.

Reviewed By: mjoras

Differential Revision: D20318260

fbshipit-source-id: eec625e2ab641f7fa6266517776a2ca9798e8f89
2020-11-10 20:08:13 -08:00
Luca Niccolini
29b2d56cbd update Copa Transport Settings
Reviewed By: mjoras

Differential Revision: D24774606

fbshipit-source-id: d9322f1bde83da56a5f32a5b0fd784c7c64c9963
2020-11-05 19:25:16 -08:00
Sridhar Srinivasan
1d65dd0eb7 API to find out if knobs are supported on a QUIC connection
Summary:
Knob Frames are supported only by peers who are on the QUIC::MVFST version.
Expose this information to the outside, so producers of Knob frames can check,
before constructing frames to exchange with the peer.

Reviewed By: bschlinker

Differential Revision: D24608694

fbshipit-source-id: 88a8ff892efc061ca755d3eeabaed83d27d8271f
2020-11-05 11:02:54 -08:00
Sridhar Srinivasan
de8ec06a4b Invoke life cycle observer callbacks during event base attach and
Summary: Inform LifecycleObservers when an EventBase is attached or detached from a QuicSocket.

Reviewed By: bschlinker

Differential Revision: D24294254

fbshipit-source-id: a606ad5ae4d4cbe3095e6ae32d6c74713325ad08
2020-10-23 12:01:33 -07:00
Yang Chi
9ae8f66b68 Add tokenless pacer option into transport settings
Summary: To enable it without having to get a version

Reviewed By: lnicco

Differential Revision: D24220074

fbshipit-source-id: a7f4cd06580095192e13a77fb5bf79e86c2d1f14
2020-10-09 20:02:29 -07:00
vaz985
185a6730b6 Exposing quicSocket to observers (#185)
Summary:
Giving more access to the current state of the connection by exposing the socket.

Pull Request resolved: https://github.com/facebookincubator/mvfst/pull/185

Reviewed By: yangchi

Differential Revision: D23924861

Pulled By: bschlinker

fbshipit-source-id: 16866a93e58b6544e25d474a51ca17fab9ffdc55
2020-09-29 23:24:24 -07:00
Matt Joras
f16d60e922 Use initial CID as DCID in the qlogger.
Summary: Since the DCID is often empty for clients, this is otherwise not a very useful field.

Reviewed By: yangchi

Differential Revision: D23998639

fbshipit-source-id: b8949ca6913ed270e5ebd0a0c5335b224f817774
2020-09-29 16:59:13 -07:00
Xiaoting Tang
61aa04e26d Send knob frames for transport knobs
Summary: Adds routines to send transport knobs.

Reviewed By: mjoras

Differential Revision: D23825714

fbshipit-source-id: a61b5650eacf0767054e18b59c731072e364c9b2
2020-09-28 19:10:22 -07:00
Xiaoting Tang
f4ae0d7172 Always delay before sending the next probe
Summary:
After some experiments where probes are obviously causing congestion, it now
makes sense to pose some delay before sending the next probe. This is not
mentioned in the d6d spec, but in a related spec rfc4821 iirc, where consecutive
probes should have 1sec delay.

Reviewed By: mjoras

Differential Revision: D23910766

fbshipit-source-id: dcf5d05c4590489be503563c98144e12c3987cff
2020-09-25 13:36:13 -07:00
Xiaoting Tang
37cd692593 Refactor d6d pending events into a single struct
Summary: As a drive-by: fixed a bug where I didn't cancel the pending event when timeouts expire.

Reviewed By: mjoras

Differential Revision: D23910767

fbshipit-source-id: 233e590c17a6c6b7a5f4a251bd8f78f6dfae3c0b
2020-09-25 13:36:13 -07:00
Xiaoting Tang
5317134c84 Timeouts that drive d6d lifecycle
Summary:
This glues together the d6d lifecycle via probe timeout and raise timeout.
Had to put these two timeouts in the base transport because it has all the
necessary accountings (e.g. check close state, process callbacks) that should
happen before scheduling timeouts.

Other notable changes (included here because code is simple):
- Keep track of d6d probes in loss state. Upon second thought, it makes more
sense because we are reducing the available bandwidth as a result of sending
probes anyway. And not tracking them imposes a delay on congestion controller.
I think this does not violate the d6d spec's point of not penalizing congestion
window for d6d probes, because
    - 1. we don't put losses of d6d probes in loss event. Therefore from the POV of
congestion controller, d6d probes never get lost.
    - there will be at most kDefaultD6DMaxOutstandingProbes losses (i.e.  2)
that we don't tell congestion controller about. Even if those are actually
caused by congestion, it should have minimal impact because 2 is small and if there's really a congestion, the loss of normal packets should provide the signal.
- Pacing d6d probes
- Kick off d6d after a delay of 1s. This should filter out short-lived connections where probing is relatively expensive and less useful.

Reviewed By: mjoras

Differential Revision: D23736656

fbshipit-source-id: 8121fa8bcebab10a56a4e046c32c4e99ed6c3013
2020-09-22 08:44:25 -07:00
Kanthi Nagaraj
327af996e2 Adding packet loss event detection to instrumentationobserver
Summary:
`InstrumentationObserver` is owned by `QuicSocket` now. However, to capture packet loss signal, we need it in `QuicConnectionState`. So, I refactored the code a little bit to make this easy. Changes in this code:
(a)  Moved the definition of `InstrumentationObserver` and `LifeCycleObserver` to
 a separate header `Observer.h`.
(b) Moved the vector of `InstrumentationObserver`s from `QuicSocket` to `QuicConnectionState`.
(c) Added a callback in `conn->pendingCallbacks` when a packet loss is detected

Reviewed By: bschlinker

Differential Revision: D23018569

fbshipit-source-id: e70d954839bdb70679ecd52d2bd1a6a6841f6778
2020-09-11 17:54:58 -07:00
Matt Joras
80c0b3185a Introducing the KnobFrame
Summary:
This introduces a new extension frame, the KnobFrame, and an implementation.

The idea with Knobs is that they are arbitrary key-values within a namespace that can be transmitted to the peer at any time. They provide an alternative to transport settings, by eschewing the standard transport setting space entirely.

The idea is simple, each knob has a "knobspace", "id", and value. The knobspace is a namespace in which the knob has semantic meaning (e.g. 0xfaceb00). The id and value are just that, arbitrary identifiers and values.

On receiving a knob it is the application's reponsibility to deal with it.

Reviewed By: mjoras

Differential Revision: D23601468

fbshipit-source-id: 63e5e4a7bdb76e11e8c952f1234f512a629ef348
2020-09-11 14:29:29 -07:00
Luca Niccolini
ed9d1bc3e1 correctly start/stop qlog collection when setQlogger is called multiple times
Reviewed By: yangchi

Differential Revision: D23579772

fbshipit-source-id: abe8e5dac3ba46fdccba2b39055e5589179cb8a1
2020-09-09 00:20:09 -07:00
Xiaoting Tang
3fac7d21f4 Count cumulative # of egress packets for a stream
Summary:
There are situations where application needs to know how many packets were transmitted for a stream on certain byte range. This diff provides *some* level of that information, by adding the `cumulativeTxedPackets` field in `StreamLike`, which stores the number of egress packets that contain new STREAM frame(s) for a stream.

~~To prevent double-counting, I added a fast set of stream ids.~~

Application could rely on other callbacks (e.g. ByteEventCallback or DeliveryCallback) to get notified, and use `getStreamTransportInfo` to get `packetsTxed` for a stream.

Reviewed By: bschlinker, mjoras

Differential Revision: D23361789

fbshipit-source-id: 6624ddcbe9cf62c628f936eda2a39d0fc2781636
2020-09-01 15:50:20 -07:00
Nitin Garg
78a3e0c2e5 Allow over-riding COPA delta param
Reviewed By: mjoras

Differential Revision: D23122720

fbshipit-source-id: e3234532a37e43905414f74243bb653ae4b0a694
2020-08-27 04:22:48 -07:00
Xiaoting Tang
02ea1dc016 Refactor pair of offset and ByteEventCallback to a struct
Summary: ^ This might increase readability. e.g. "cbs->offset" is more readable than "cbs->first".

Reviewed By: bschlinker, yangchi

Differential Revision: D23361655

fbshipit-source-id: 811eb4439c2c717059ec5f0d15255ec5ede9a2b8
2020-08-26 19:00:53 -07:00
Matt Joras
3f4b4a668d Spurious loss detection
Summary:
It is useful to be able to account for when we detect packets as lost but actually receive an ACK for them later. This accomplishes that by retaining the packets in the outstanding packet list for a certain amount of time (1 PTO).

For all other purposes these packets are ignored.

Reviewed By: yangchi

Differential Revision: D22421662

fbshipit-source-id: 98e3a3750c79e2bcb8fcadcae5207f0c6ffc2179
2020-08-26 15:54:25 -07:00
Matt Joras
81756e3d13 Allow specifying error code in setReadCallback
Summary: We have an API behavior where setReadCalback will issue a StopSending on behalf of the app. This is useful but has confusing semantics as it always defaults to GenericApplicationError::NO_ERROR. Instead let the error be specified as part of the API.

Reviewed By: yangchi, lnicco

Differential Revision: D23055196

fbshipit-source-id: 755f4122bf445016c9b5adb23c3090fc23173eb9
2020-08-13 18:28:38 -07:00