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

168 Commits

Author SHA1 Message Date
Matt Joras
e3d67efb5a Track a sequence number for non-DSR packets.
Summary:
This is essentially a further extension of the previous idead of having a sequence number per-DSR stream.

The rationale is the same -- to reduce spurious loss declared from the reordering threshold.

The primary case this works around is the following

```
<!DSR><!DSR><!DSR><DSR><DSR><DSR><!DSR>
```

Suppose we get an ACK for [0-1,3-5] leaving only packet number 2 remaining.

The naive reordering threshold will declare packet number 2 as lost. However, in principle this is arguably wrong since when considered on the timeline of !DSR packets, the gap does not exceed the reordering threshold.

To accomodate this we need to track a monotonically increasing sequence number for each non-DSR packet written, and store that in the packet metadata. This way we can use that for the reordering comparison rather than the packet number itself.

When there is no DSR packets ever written to a connection this should devolve to an identical result to using the packet number, as they will increment together.

Reviewed By: kvtsoy

Differential Revision: D46742386

fbshipit-source-id: 2983746081c7b6282358416e2bb1bcc80861be58
2023-06-27 16:56:11 -07:00
Matt Joras
3c5a34ee11 Put opportunistic ACKing behind TransportSetting
Summary:
This has been a default behavior for us for a long time. Basically, we will always include ACK frames in a burst if there's new packets to ACK.

This is overall probably fine and is flexible to peer behavior such that the peer can get away with basically never sending anything ACK-eliciting.

However it is not without its issues. In particular, for DSR it means that we write an excessive amount of pure ACK packets since they cannot be coalesced with a DSR burst.

Make this behavior optional, such that we only include ACK frames in non-probing schedulers when we are only writing stream data.

Reviewed By: kvtsoy

Differential Revision: D39479149

fbshipit-source-id: 6e92d45311a3fb23750c93483b94e97dd3fdce26
2023-06-15 13:15:08 -07:00
Crystal Jin
0fd6ba7f78 Use finalWriteOffset for stream bytes sent
Reviewed By: JunqiWang

Differential Revision: D46663584

fbshipit-source-id: 1b22eb90501a9b904c17818991d01e5a0fbf2734
2023-06-13 08:16:16 -07:00
Matt Joras
d31f2f7f16 Fix bytesWritten return
Summary: Turns out these functions have been returning 0 for bytes written for a while. Nothing was using them (yet), so there wasn't any functional breakage.

Reviewed By: kvtsoy

Differential Revision: D46653336

fbshipit-source-id: 765b3363c1fc0729e8239d1293ddcc4ae4bb9c79
2023-06-12 17:02:16 -07:00
Matt Joras
c8fcb30130 Remove DSR UNLIKELY
Summary:
As in title. I don't think this was affecting anything but remove it since we are using DSR.

(Note: this ignores all push blocking failures!)

Reviewed By: hanidamlaj

Differential Revision: D46522584

fbshipit-source-id: 34e0ff1f208d00be51963d2081decde5e7acccf7
2023-06-08 10:41:44 -07:00
Matt Joras
35a2d34843 Use a single queue for scheduling DSR and non-DSR streams.
Summary:
The write loop functions for DSR or non-DSR are segmented today. As such, so are the schedulers. Mirroring this, we also currently store the DSR and non-DSR streams in separate write queues. This makes it impossible to effectively balance between the two without potential priority inversions or starvation.

Combining them into a single queue eliminates this possibility, but is not entirely straightforward.

The main difficulty comes from the schedulers. The `StreamFrameScheduler` for non-DSR data essentially loops over the control stream queue and the normal write queue looking for the next stream to write to a given packet. When the queues are segmented things are nice and easy. When they are combined, we have to deal with the potential that the non-DSR scheduler will hit a stream with only DSR data. Simply bailing isn't quite correct, since it will just cause an empty write loop. To fix that we need check, after we are finished writing a packet, if the next scheduled stream only has DSR data. If it does, we need to ensure `hasPendingData()` returns false.

The same needs to be done in reverse for the DSR stream scheduler.

The last major compication is that we need another loop which wraps the two individual write loop functions, and calls both functions until the packet limit is exhausted or there's no more data to write. This is to handle the case where there are, for example, two active streams with the same incremental priority, and one is DSR and the other is not. In this case each write loop we want to write `packetLimit` packets, flip flopping between DSR and non DSR packets.

This kind of round robining is pathologically bad for DSR, and a future diff will experiment with changing the round robin behavior such that we write a minimum number of packets per stream before moving on to the next stream.

This change also contains some other refactors, such as eliminating `updateLossStreams` from the stream manager.

(Note: this ignores all push blocking failures!)

Reviewed By: kvtsoy

Differential Revision: D46249067

fbshipit-source-id: 56a37c02fef51908c1336266ed40ac6d99bd14d4
2023-06-01 14:11:31 -07:00
Matt Joras
96b2c1b37d Control write loop time limit from knob.
Summary:
This has been hardcoded to SRTT/25 for a long time. However, especially when using DSR this might not be the most appropriate since it can start to get close to real world SRTTs.

Control it via a knob, and also add the behavior such that setting it to 0 effectively disables the time limit.

Reviewed By: jbeshay

Differential Revision: D46084438

fbshipit-source-id: 7dc619fdff1bd5c3f8654c4936200e0340ef94f2
2023-05-22 16:15:24 -07:00
Matt Joras
372075b690 IMMEDIATE_ACK probes
Summary:
When using ACK_FREQUENCY and high reordering thresholds, the normal tricks for drawing ACKs with PTOs are slightly defeated.

Thankfully we can get around this by issuing IMMEDIATE_ACKs when probing. The strategy is basically to replace one of the usual probes with an IMMEDIATE_ACK probe.

Also, include ACKs in these probes (and the PING probes), since there's not much reason not to.

Reviewed By: jbeshay

Differential Revision: D45965703

fbshipit-source-id: 9b98473312a239e17a0b8040f45d197b1a2c8484
2023-05-22 13:14:00 -07:00
Joseph Beshay
356bcf918c Track attached cmsgs in OutstandingPacketMetadata
Summary: As title

Reviewed By: bschlinker

Differential Revision: D44233701

fbshipit-source-id: 5025d01f3080a197afd8f3fdf23872d7540a981a
2023-04-06 09:14:22 -07:00
Joseph Beshay
24f00aad4a Allow Packet Processors to specify prewrite requests that apply to each write loop
Summary:
Adds a prewrite function in packet processors that can be used to set PreWrite Reuqests that will apply apply to the next write loop in the QuicSocket.

Currently, the PrewriteRequest only contains a list of cmsgs but it can be expanded when needed.

This replaces the setAdditionalCmsgs callback that was previously passed down directly to AsyncUDPSocket, allowing multiple processors to affect the additionalCmsgs sent to the AsyncUDPSocket.

Reviewed By: bschlinker

Differential Revision: D44233700

fbshipit-source-id: 799357ee5df89b2a526611bd83d0b4a9a13b71d5
2023-03-24 16:14:59 -07:00
Ilango Purushothaman
8481bf867c Add packet destruction callback to PacketProcessor
Summary:
This diff adds a OnPacketDestroyed PacketProcessor callback function to be called from a OutstandingPacket destructor. To enable this, a few things had to be done
1. Inject a generic std::function lambda in `OutstandingPacket` as a PacketProcessor callback which is called on OutstandingPacket wrapper class destruction.
2. Explicitly null the OnPacketDestroyed callback on move construction for "moved from" objects
3. Detect if the move is a "replace" (like during `std::deque::erase`) and execute callback before move.
4. Unit-test

Reviewed By: bschlinker

Differential Revision: D43896147

fbshipit-source-id: 1b64a9d66ae628d83b6edb65d1bad54b27db7964
2023-03-21 00:49:13 -07:00
Hani Damlaj
6cd4f47735 elide malloc calls
Summary: - optimizing `setSupportedExtensionTransportParameters()` to elide invocations to malloc()

Reviewed By: mjoras

Differential Revision: D43844018

fbshipit-source-id: 38da5c62786f795a3a79e7592d06d4da1d7487ba
2023-03-15 15:58:02 -07:00
Ilango Purushothaman
e1fd9c7880 Create OutstandingPacket wrapper
Summary:
To get reliable packet destruction events, created a `OutstandingPacketWrapper` wrapper that wraps the current `OutstandingPacket` class, so callback functions can be added to the wrapper instead of the underlying object itself.

#### Why do we need this wrapper?

`std::deque::erase` does not guarantee that appropriate object destructors will be called (only that the number of destructions = number of objects erased). This is a real problem as packet destruction events are then no longer reliable (OutstandingPacket object is wrong!). The wrapper class handles this condition by detecting it in the move assignment constructor (called during erase) and calls the appropriate packet destruction callback before packets are moved. If we did the same fix in the old OutstandingPacket, we have to make sure the callback is called before all the fields of OutstandingPacket are moved - this is not scaleable. Hence a wrapper with the underlying object and a destruction callback function.
I also disabled copy construction for OutstandingPacket (otherwise we will get duplicate OnPacketDestroyed callbacks and cannot track packets reliably). Removing packet copies also improves performance. Some code changes (in tests mostly) are mostly in service of this particular change.

Reviewed By: bschlinker

Differential Revision: D43896148

fbshipit-source-id: c295d3c4dba2368aa66f06df5fc82b473a03fb4d
2023-03-15 03:10:18 -07:00
Crystal Jin
3c43db2b15 Add new stream bytes sent per stream
Reviewed By: hanidamlaj

Differential Revision: D43851342

fbshipit-source-id: 204a5d821c69928a4e9de44f461c4eb8181ef277
2023-03-08 15:39:11 -08:00
Hani Damlaj
a0e456bc03 migrate folly::none assignment operator to .reset()
Summary: - .reset() is probably fractionally less costly than the assignment operator?

Reviewed By: sharmafb

Differential Revision: D43579041

fbshipit-source-id: 4838b6c21e94197782cf56866950be1dbf65b106
2023-03-03 05:39:57 -08:00
Konstantin Tsoy
377260f704 Remove d6d code
Summary: we're not using it

Reviewed By: mjoras

Differential Revision: D43482344

fbshipit-source-id: 05ac6792848e32e7c1bcf53a2df172852b5def62
2023-02-23 20:11:24 -08:00
Joseph Beshay
001e32e888 Fix variable name typo: s/dataPlain/dataPlane
Summary: Just fixes the typo!

Reviewed By: nikhildl12

Differential Revision: D43291768

fbshipit-source-id: 970b4ffd2294ac79988c53d5904f2a8d70a59b82
2023-02-15 11:41:11 -08:00
Konstantin Tsoy
360962fd45 Bail early on empty scheduler when writing
Reviewed By: jbeshay

Differential Revision: D42645293

fbshipit-source-id: 5e73ca2ad462b8a7edae287cefe12a6260c0030d
2023-01-27 16:43:07 -08:00
Matt Joras
1275798146 Make the AckState for Initial/Handshake a unique_ptr
Summary:
We don't need to carry these states after the handshake is confirmed, so make them pointers instead. This will facilitate adding a structure to the AckState for tracking duplicate packets.

(Note: this ignores all push blocking failures!)

Reviewed By: hanidamlaj

Differential Revision: D41626895

fbshipit-source-id: d8ac960b3672b9bb9adaaececa53a1203ec801e0
2022-12-20 11:08:43 -08:00
Brandon Schlinker
eb3009484a Application limited time in packet metadata
Summary:
Track the total (cumulative) amount of time that the connection has been application limited and store this information in `OutstandingPacketMetadata`. If this value is the same for two `OutstandingPacketMetadata` then we know that the transport did not become application limited between when those two packets were sent (or, less likely, the transport was application limited for less than one microsecond given the microsecond resolution of the timestamp).

We store the amount of time spent application limited instead of a count of the number of application limited events because the implications of being application limited are time dependent.

Tests show that we need to be able to inject a mockable clock. That's been an issue for some time; will work on in a subsequent diff.

Differential Revision: D41714879

fbshipit-source-id: 9fd4fe321d85639dc9fb5c2cd51713c481cbeb22
2022-12-08 18:55:22 -08:00
Joseph Beshay
772b47adaa Do not use LOG_EVERY_N
Summary:
Fixes build error from Github actions
```
D:\a\mvfst\mvfst\quic\server\QuicServerTransport.cpp(1072): error C3861:
'__sync_add_and_fetch': identifier not found

```

Reviewed By: hanidamlaj

Differential Revision: D40327603

fbshipit-source-id: afae1b661322e80156c7d69b577f35f41b67ee73
2022-11-10 16:17:32 -08:00
Konstantin Tsoy
c6d9731247 Switch to chained memory data path if GSO is not supported
Summary:
Check for GSO support once before the first write, cache the value and use it throughout the conn lifetime.
If GSO is not supported, ensure we use chained memory write path.

Reviewed By: mjoras

Differential Revision: D40240513

fbshipit-source-id: b699b4633246f3c15d2be7b39580686e44c2aab3
2022-10-11 14:43:12 -07:00
Joseph Beshay
abee1d8387 Add IMMEDIATE_ACK frame
Summary: Add the new IMMEDIATE_ACK frame from the ack frequency draft.

Reviewed By: mjoras

Differential Revision: D38523438

fbshipit-source-id: 79f4a26160ccf4333fb79897ab4ace2ed262fa01
2022-08-24 11:11:33 -07:00
Joseph Beshay
7271907eb5 Skip LOG_EVERY_N to fix build
Summary: Upgrading glog from 0.4.0 to 0.5.0 broke the windows build for some time. This change skips calling LOG_EVERY_N for Windows to restore the build. It is a stop-gap measure until logging is migrated to folly XLOG.

Reviewed By: kvtsoy

Differential Revision: D38371427

fbshipit-source-id: 9711607a348f0473e3e922d7f627217b3948c45d
2022-08-04 11:47:04 -07:00
Ashkan Nikravesh
8419469204 Create a PacketProcessor abstract class
Summary: PacketProcessors process the packets that we send and their corresponding ack and loss events. We store a vector of packet processors inside `QuicConnectionStateBase` and we call `onPacketSent` and `onPacketAck` whenever their corresponding functions in `CongestionController` class are called. The plan is to make `CongestionController` class extend `PacketProcessor`.

Reviewed By: bschlinker

Differential Revision: D36404668

fbshipit-source-id: 52d63a6a74bfa2031131d31047da25a5e2be12aa
2022-07-05 11:09:03 -07:00
Konstantin Tsoy
003c12fb22 Move setCustomTransportParameter() to free functions
Summary: Move setCustomTransportParameter() to free functions

Reviewed By: mjoras

Differential Revision: D36204576

fbshipit-source-id: 513c11852a339d441af9f3fc948679814da98900
2022-05-19 20:01:28 -07:00
Matt Joras
e2be4562a1 Use createCombined more frequently.
Summary: This is a pretty obvious thing to do. There's not really any reason to have the data and metadata separately since we don't need to reallocate.

Reviewed By: jbeshay

Differential Revision: D36237370

fbshipit-source-id: 093ad7fb2c54b596ea5cc327ffcc24de1748d362
2022-05-09 23:47:37 -07:00
Hani Damlaj
747c41c30d Fix Probing Bytes Limit
Summary:
- PTOs should not be subject to congestion control limits
- Quickly recover from PTOs being writableBytesLimited by calling onPTOAlarm() as soon as we become unblocked

Reviewed By: mjoras

Differential Revision: D35480409

fbshipit-source-id: 51500db6fff17a7badefea8bda7f63141e97f746
2022-04-19 00:50:36 -07:00
Hani Damlaj
61deaef637 Revert To UnlimitedWritableBytes for Probes
Summary: - as title; ninja landing this because jf land doesn't work

Reviewed By: mjoras

Differential Revision: D35446781

fbshipit-source-id: 73cfbd19da3922a9b3471a95006b817ea495768b
2022-04-07 08:10:55 -07:00
Hani Damlaj
c8bf098e5d Change Implementation of WritableBytesLimit
Summary: - updating usage of WritableBytesLimit

Reviewed By: mjoras

Differential Revision: D33079816

fbshipit-source-id: 1854f40a7b00526afb2167764aeddf55edb1771f
2022-04-04 16:18:52 -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
Liang Zhou
b2c91ae10e add stats for dsr egress bytes in proxygen side
Summary: add more instrument info for the dsr egressed counts and bytes

Reviewed By: mjoras, shodoco

Differential Revision: D34192441

fbshipit-source-id: 2b3567b7bec0748ab99ad042742d7823a52da568
2022-03-03 10:58:53 -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
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
Hani Damlaj
f60c254c49 Log Server Handshake Size
Summary: - logging number of bytes the server sent during the handshake for insight.

Reviewed By: mjoras

Differential Revision: D33069800

fbshipit-source-id: e7e8f25183ee30de99e2971bae3c6b93882f6e63
2022-01-06 10:34:06 -08:00
Matt Joras
ca4705af0b If there's lost data, we have data to write, take 2.
Summary:
This is a bug that could prevent us from writing data if we ran out of connection flow control while we had lost data.

The last attempt missed a mistake in the scheduling of sequential priority streams.

Reviewed By: kvtsoy

Differential Revision: D33030784

fbshipit-source-id: e1b82234346a604875a9ffe9ab7bc5fb398450ed
2021-12-14 09:18:01 -08:00
Brandon Schlinker
bdd073a7fd Throw if start offset of written frame > stream.currentWriteOffset
Summary: As titled. Simple logic to prevent confusion when writing tests.

Reviewed By: jbeshay

Differential Revision: D31916968

fbshipit-source-id: 6f4fb84402b6fe2f5f9af9f57ff8a1d2f1838464
2021-12-11 22:40:44 -08:00
Matt Joras
5b9a9705a0 Back out "If there's lost data, we have data to write."
Summary: This is causing empty write loops for some reason.

Reviewed By: jbeshay, lnicco

Differential Revision: D32990291

fbshipit-source-id: 2a183d591de54c7fe0ca54aea828a697a4cd9af0
2021-12-09 14:35:24 -08:00
Matt Joras
d6a876f201 If there's lost data, we have data to write.
Summary: This is an edge case we weren't handling properly. This can lead to situations where we run out of conn flow control, the peer hasn't received all data, and then we never write the data to trigger a flow control update.

Reviewed By: afrind

Differential Revision: D32887140

fbshipit-source-id: df5dfad8e0775ef43e5ca6ab98b8ca6b5987ce31
2021-12-07 18:19:58 -08:00
Matt Joras
6afecccd25 Track loop limit time across functions.
Summary: Otherwise we can end up in a situation where the non-DSR scheduler was limited by the loop time while the DSR scheduler is not, leading to an inconsistency.

Reviewed By: lnicco

Differential Revision: D32570027

fbshipit-source-id: f43d2517589c22bac0f2bb76626cc55c2a21fa5d
2021-11-19 19:04:37 -08:00
Matt Joras
612a00c3f9 Move happy eyeballs state to client state.
Summary: This doesn't belong in the generic state. Untangling it is a little difficult, but I think this solution is cleaner than having it in the generic state.

Reviewed By: JunqiWang

Differential Revision: D29856391

fbshipit-source-id: 1042109ed29cd1d20d139e08548d187b469c8398
2021-07-23 14:21:16 -07:00
Matt Joras
7402dbe6c9 Move zero RTT ciphers to client state.
Summary: As in title, this doesn't need to be in the base state.

Reviewed By: JunqiWang

Differential Revision: D29855140

fbshipit-source-id: 8d3a4b12fd6b93b2277020d56862915e084f1c05
2021-07-23 14:21:16 -07:00
Matt Joras
003f012cb7 TODO comment cleanup.
Summary:
These are either no longer relevant, are unlikely to be done, or are spculative enough that they don't deserve code space.

Hope here is to make our search for TODOs higher signal.

Reviewed By: lnicco

Differential Revision: D29769792

fbshipit-source-id: 7cfa62cdc15e72d8b7b0cd5dbb5913ea3ca3dc5a
2021-07-20 10:27:32 -07:00
Luca Niccolini
5dd53e6e2c Datagram frames are not rtx-able
Summary: We are now adding them to the outstanding packet list, for not good reason.

Reviewed By: mjoras

Differential Revision: D29469128

fbshipit-source-id: b279774b6ef5bbb436b3c9d7bcdad39eea8f1079
2021-07-01 19:45:37 -07:00
Matt Joras
e848899795 Fix accounting bug in closes.
Summary:
We didn't actually ensure there was enough room for the tag here, which means we'd fail to encrypt the close.

(Note: this ignores all push blocking failures!)

Reviewed By: yangchi, lnicco

Differential Revision: D29187670

fbshipit-source-id: 97e4f60feaf6b1998ffafe3b1289df94586e9c5e
2021-06-17 19:57:43 -07:00
Luca Niccolini
dc3b4dded0 Write DATAGRAM frames when available
Summary:
Right now we are waiting for another write event to write datagrams.
Introduced a Write Reason for the case when only DATAGRAMS are pending

Reviewed By: mjoras

Differential Revision: D29091822

fbshipit-source-id: 0de6b88d93acae0ba240b9cdf9dbc8e74feaf5ac
2021-06-13 21:13:19 -07:00
Yang Chi
0e6a998e05 Fix QUIC EOF sending when DSR is used
Summary:
This is a bug fix. When a stream finished sending all it's BufMetas, it can
send EOF from frontend QUIC host. In that case, it will use
currentWriteOffset value which is wrong.

This diff changes it so that (1) frontend can only write FIN only frame if
writeBufMeta's offset is <= finalWriteOffset; (2) When it writes such frame
it will use finalWriteOffset as the offset value in the frame.

Reviewed By: lnicco

Differential Revision: D28727029

fbshipit-source-id: 8f963c2e2d66f921f8a9704ed4671ec4f7c04df7
2021-06-01 13:16:20 -07:00
Sridhar Srinivasan
7246cd5e3c Record stream details in packet metadata
Summary:
Introruced a new DetailsPerStream struct inside the outstanding packet metadata
so we can easily track all streams carrying app data within a packet and each
stream's bytes sent (both new and total).

With this, consumers can easily deduce the number of retransmitted bytes per
stream using the StreamDetails members:
newStreamBytesSent - streamBytesSent.

Reviewed By: bschlinker

Differential Revision: D28063916

fbshipit-source-id: d915514f85f24f4889cfac2f7a66bfd2d6b0a4af
2021-05-14 11:55:17 -07:00
Luca Niccolini
f778cfb945 Quic Socket: Datagram APIs
Summary: quic socket API to send and receive datagrams

Reviewed By: mjoras, yangchi

Differential Revision: D20983884

fbshipit-source-id: 70332c5fb9c37c88150fc2f623521e7b0c991eae
2021-05-11 08:24:03 -07:00