1
0
mirror of https://github.com/facebookincubator/mvfst.git synced 2025-11-07 22:46:22 +03:00
Commit Graph

26 Commits

Author SHA1 Message Date
Dan Melnic
d7fb36eab0 Remove unused code
Summary: Remove unused code

Reviewed By: meleshuk

Differential Revision: D59201997

fbshipit-source-id: da714841fbebc7b252241afca7ef1c602b9a4574
2024-07-01 20:18:15 -07:00
Joseph Beshay
71b8af4b1a Add new batch writer SinglePacketBackpressureBatchWriter to retry failed writes
Summary:
The existing batch writers do not handle failed writes to the AsyncUDPSocket. A packet that fails to be written is detected as a packet loss later when feedback is received from the peer. This negatively impacts the congestion controller because of the fake loss signal, and artificially inflates the number of retransmitted packets/bytes.

This change adds a new batch writer (SinglePacketBackpressuretBatchWriter) that retains the buffers when a write fails. For subsequent writes, the writer retries the same buffer. No new packets are scheduled until the retried buffer succeeds.

Notes:
- To make sure that retry writes are scheduled, the write callback is installed on the socket when a buffer needs to be retried.
- The retries are for an already scheduled packet. The connection state reflects the timing of the first attempt. This could still have an impact on rtt samples, etc. but it this is a milder impact compared to fake losses/retranmissions.
- Any changes outside of the batch writer only impact the new batch writer. Existing batch writers do not use the fields and are not affected by the changes in this diff.

Reviewed By: kvtsoy

Differential Revision: D57597576

fbshipit-source-id: 9476d71ce52e383c5946466f64bb5eecd4f5d549
2024-05-22 15:35:32 -07:00
Joseph Beshay
ead139adef Move all mvfst use-cases to the new Eventbase, Timer, and Socket interfaces
Summary:
This is the major transition that updates mvfst code to use the new interfaces. The new Folly implementations of the interfaces maintain all the existing behavior of folly types so this should not introduce any functional change. The core changes are:
- Update the BatchWriters to use the new interfaces.
- Update the FunctionLooper to use the new interfaces.
- Change QuicServerTransport to take the folly types and wrap them in the new types for use in the QuicTransportBase.

The rest of the diff is for updating all the existing uses of the QuicTrasnport to initialize the necessary types and pass them to the QUIC transport instead of directly passing folly types.

Reviewed By: mjoras

Differential Revision: D51413481

fbshipit-source-id: 5ed607e12b9a52b96148ad9b4f8f43899655d936
2023-12-14 00:24:12 -08:00
Brandon Schlinker
a1445434b0 Cleanup and modularize receive path, improve timestamp support [5/x]
Summary:
This diff changes `QuicAsyncUDPSocketWrapper` so that it is an abstraction layer that inherits from `QuicAsyncUDPSocketType`, instead of simply being a container with aliases.
- Key changes in `QuicAsyncUDPSocketWrapper.h`, the rest of the updates switch us from using `QuicAsyncUDPSocketType` to `QuicAsyncUDPSocketWrapper`.
- It's difficult to mock the UDP socket today given that we expose the entire `folly::AsyncUDPSocket` type to the higher layers of the QUIC stack. This complicates testing and emulation because any mock / fake has to implement low level primitives like `recvmmsg`, and because the `folly::AsyncUDPSocket` interface can change over time.
- Pure virtual functions will be defined in `QuicAsyncUDPSocketWrapper` in a follow up diff to start creating an interface between the higher layers of the mvfst QUIC stack and the UDP socket, and this interface will abstract away lower layer details such as `cmsgs` and `io_vec`, and instead focus on populating higher layer structures such as `NetworkData` and `ReceivedPacket` (D48714615). This will make it easier for us to mock or fake the UDP socket.

This diff relies on changes to `folly::MockAsyncUDPSocket` introduced in D48717389.

--

This diff is part of a larger stack focused on the following:

- **Cleaning up client and server UDP packet receive paths while improving testability.** We currently have multiple receive paths for client and server. Capabilities vary significantly and there are few tests. For instance:
  - The server receive path supports socket RX timestamps, abet incorrectly in that it does not store timestamp per packet. In comparison, the client receive path does not currently support socket RX timestamps, although the code in `QuicClientTransport::recvmsg` and `QuicClientTransport::recvmmsg` makes reference to socket RX timestamps, making it confusing to understand the capabilities available when tracing through the code. This complicates the tests in `QuicTypedTransportTests`, as we have to disable test logic that depends on socket RX timestamps for client tests.
  - The client currently has three receive paths, and none of them are well tested.

- **Modularize and abstract components in the receive path.** This will make it easier to mock/fake the UDP socket and network layers.
  - `QuicClientTransport` and `QuicServerTransport` currently contain UDP socket handling logic that operates over lower layer primitives such `cmsg` and `io_vec` (see `QuicClientTransport::recvmmsg` and `...::recvmsg` as examples).
  - Because this UDP socket handling logic is inside of the mvfst transport implementations, it is difficult to test this logic in isolation and mock/fake the underlying socket and network layers. For instance, injecting a user space network emulator that operates at the socket layer would require faking `folly::AsyncUDPSocket`, which is non-trivial given that `AsyncUDPSocket` does not abstract away intricacies arising from the aforementioned lower layer primitives.
  - By shifting this logic into an intermediate layer between the transport and the underlying UDP socket, it will be easier to mock out the UDP socket layer when testing functionality at higher layers, and inject fake components when we want to emulate the network between a mvfst client and server. It will also be easier for us to have unit tests focused on testing interactions between the UDP socket implementation and this intermediate layer.

- **Improving receive path timestamping.** We only record a single timestamp per `NetworkData` at the moment, but (1) it is possible for a `NetworkData` to have multiple packets, each with their own timestamps, and (2) we should be able to record both userspace and socket timestamps.

Reviewed By: jbeshay, hanidamlaj

Differential Revision: D48717388

fbshipit-source-id: 4f34182a69ab1e619e454da19e357a6a2ee2b9ab
2023-09-21 07:57:58 -07:00
Matt Joras
3a03962399 Add setTxTime batch writer API, and store the txtime for the GSO writers.
Summary:
Since the socket can sometimes support SO_TXTIME, support storing this in the batch writer. This is just a way to plumb it, the transport is not yet setting it.

A time of zero effectively doesn't use the socket option.

Reviewed By: kvtsoy

Differential Revision: D48532725

fbshipit-source-id: d21b7035ecb465c614688131601c309651852bbf
2023-08-21 16:13:38 -07:00
Konstantin Tsoy
94c254716d Move a func to fix mvfst mobile build
Summary: Broke in one of the previous commits.

Reviewed By: hanidamlaj

Differential Revision: D47962468

fbshipit-source-id: 532e9356cb7e1bba2e45ac0a18440a12aed1eb25
2023-08-01 19:31:34 -07:00
Konstantin Tsoy
15a619fccf Add SinglePacketInplaceBatchWriter
Summary:
The new writer will use a single IOBuf for in-place writes via a
accessor.

Reviewed By: jbeshay, mjoras

Differential Revision: D47648606

fbshipit-source-id: c6094eb3445587337f8a03e203aeadb2954f76b1
2023-07-27 17:00:41 -07:00
Konstantin Tsoy
08aba67f8b Rename a few headers
Summary:
And add comments to the new events classes.

Old naming:
```
Events.h/cpp
  -> EventsMobile.h/cpp
```

New naming:
```
QuicEventBase.h/cpp
  -> QuicLibevEventBase.h/cpp
```

Reviewed By: hanidamlaj, mjoras

Differential Revision: D47140799

fbshipit-source-id: 6a25e76c454b0f8468d830feb4dfd99c1576c8b8
2023-07-13 18:39:45 -07:00
Konstantin Tsoy
2b0d0b2f2b Separate batch writer into multiple modules
Summary: Separate batch writer into multiple modules

Reviewed By: hanidamlaj, mjoras

Differential Revision: D47112819

fbshipit-source-id: f6b4fd64ab99541f1923ae9c432e5a1fb0986fef
2023-07-13 18:39:45 -07:00
Konstantin Tsoy
c8daa9bf01 Abstract away socket fd getter/setter
Summary: This is needed for the new socket abstraction implementation later.

Reviewed By: jbeshay, lnicco

Differential Revision: D46669712

fbshipit-source-id: 5adde6679386689e7f63992ed769ff4a777f59e3
2023-07-12 17:26:15 -07:00
Konstantin Tsoy
4a0dd1e2a4 QuicAsyncUDPSocketWrapper
Reviewed By: jbeshay

Differential Revision: D46379200

fbshipit-source-id: f6a7c1cf68108872e05e6fd8adb7f00aae22b2ed
2023-07-11 15:21:15 -07:00
Konstantin Tsoy
013f19d399 Add libev QuicEventBase impl skeleton
Summary: Add libev QuicEventBase impl

Reviewed By: hanidamlaj

Differential Revision: D46398631

fbshipit-source-id: 3905d7f2cf79f3b5e2b7db91482d9b50311757e0
2023-06-30 12:30:36 -07:00
Konstantin Tsoy
dccfc706b5 QuicEventBase wrapper
Summary:
Create and use an actual wrapper around folly::EventBase.
Later an interface will be added that the wrapper will be implementing.

Reviewed By: jbeshay

Differential Revision: D45822401

fbshipit-source-id: 3b33f796c31043ec2881b753a9b60943bdf91f1d
2023-06-15 17:12:24 -07:00
Konstantin Tsoy
fdedffa855 QuicEventBase
Summary:
A wrapper for `folly::EventBase` to be used throughout mvfst library.
Right now it's simply a `using QuicEventBase = folly::EventBase` in the new `quic/common/Events.h`, so no functional changes.

The change to the wrapper usage is constrained to QuicTransportBase and the code around for now - basically excluding top level client and server code that is still using `folly::EventBase` directly.

Subsequent changes will introduce a proper wrapper implementation getting rid of `using QuicEventBase = folly::EventBase` in the new class.

Reviewed By: mjoras

Differential Revision: D44757549

fbshipit-source-id: 5a0dd120ec319a474452eaec64a27f660144acdf
2023-05-23 14:16:15 -07: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
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
Dan Melnic
37add01a38 SendmmsgGSOPacketBatchWriter - try to batch more based on dest addr (map)
Summary: SendmmsgGSOPacketBatchWriter - try to batch more based on dest addr (map)

Reviewed By: mjoras

Differential Revision: D21110682

fbshipit-source-id: 1be2eb26ec33c8256f1d4bbe7e3d6fae19eb7146
2020-05-27 16:15:04 -07:00
Yang Chi
8715ddfc44 Move ScopedBufAccessor into quic/common/BufAccessor
Summary: as title

Reviewed By: mjoras

Differential Revision: D21629491

fbshipit-source-id: 31c0b255ad5ada4186bec90d19bc381fde2c29f5
2020-05-21 13:26:07 -07:00
Yang Chi
7022459fb0 Quic Inplace batch writer checks either packet size limit or next packet size
Summary: as title

Reviewed By: mjoras

Differential Revision: D21429917

fbshipit-source-id: 5be997bfd75cfab89c3d9289a31b0efab69a80fc
2020-05-12 07:04:56 -07:00
Yang Chi
014d50aa41 Quic socket write for the inplace buffer writing
Summary: as title

Reviewed By: mjoras

Differential Revision: D21211414

fbshipit-source-id: 5c4b8a747457e3f21da77541a35da1af1b1ac6e4
2020-05-05 09:53:07 -07:00
James Donald
2ac4c48e96 Avoid more direct usage of [[nodiscard]] in C++14 mode
Summary:
In D20494128 we fixed the direct use of `[[nodiscard]]` in quic, but more cases have apparently gotten into the codebase since. The reason we don't see more errors in fbsource is that clang is lenient allowing this in `-std=c++14` mode, but it causes a mismatch when the flag is honored for MSVC.

Note: quic and other parts of xplat need to stay in `-std=c++14`  mode for the time being. See abandoned diff D20377630 for details on the last attempt to switch to `-std=c++17`.

Reviewed By: yangchi

Differential Revision: D21280601

fbshipit-source-id: 78a1956d644f5f95d892b1fd82c5e899823c8e84
2020-04-28 16:30:51 -07:00
Dan Melnic
55443f2b16 Add support for thread local batch writers
Summary: Add support for thread local batch writers

Reviewed By: mjoras

Differential Revision: D21004810

fbshipit-source-id: 907a25f95afeab78fdc7e83cbab87b4f51adc3d3
2020-04-23 18:39:09 -07:00
Dan Melnic
655fef6a95 Add SendmmsgGSOPacketBatchWriter
Summary: Add SendmmsgGSOPacketBatchWriter

Reviewed By: mjoras

Differential Revision: D19529123

fbshipit-source-id: 15d2e591f91574bae0e33fd92094c24482246ee7
2020-01-28 12:44:46 -08:00
Yang Chi
a1b86e660d Rename Quic batching num to batch size
Summary: batchingNum -> batchSize

Reviewed By: mjoras

Differential Revision: D15740004

fbshipit-source-id: 2e3ba33792248ad67e3b06da0a95dc9ff8e76892
2019-06-11 07:28:34 -07:00
udippant
50d4939e9e Initial commit of mvfst 2019-04-22 23:42:46 -07:00