1
0
mirror of https://github.com/facebookincubator/mvfst.git synced 2025-08-09 20:42:44 +03:00
Commit Graph

65 Commits

Author SHA1 Message Date
Xiaoting Tang
2d00d56fbd Put outstanding packets, events and associated counters in one class
Summary: ^

Reviewed By: yangchi

Differential Revision: D21956286

fbshipit-source-id: 305b879ad11df23aae8e0c3aac4645c0136b3012
2020-06-10 12:45:28 -07:00
Konstantin Tsoy
b1cb1d32af Don't use currentWriteOffset as highest ack offset
Summary: Don't use currentWriteOffset as highest ack offset

Reviewed By: yangchi

Differential Revision: D21679541

fbshipit-source-id: de8814aef4959abc2e10402c5d5e294ef03f8b19
2020-05-28 12:48:28 -07:00
Matt Joras
817dd790b7 Min of idle timeouts.
Summary: The spec suggests doing this, and it is a better semantic than only considering the local one.

Reviewed By: yangchi

Differential Revision: D21433433

fbshipit-source-id: c38abc04810eb8807597991ce8801d81f9edc462
2020-05-06 16:24:55 -07:00
Matt Joras
524bf84c44 Implement an explicit inplace encrypt in Aead.
Summary: This is useful when you want to ensure that the IOBuf you pass in is encrypted inplace, as opposed to potentially creating a new one.

Reviewed By: yangchi

Differential Revision: D21135253

fbshipit-source-id: 89b6e718fc8da1324685c390c721a564bb77d01d
2020-04-21 21:43:59 -07:00
Yang Chi
8db6fc263f Do not accept very small cwnd in Quic
Summary: it's a crime

Reviewed By: mjoras

Differential Revision: D21104571

fbshipit-source-id: 122460f4f29c6abe30dd279fb050d1a263eb67a0
2020-04-18 10:45:50 -07:00
Matt Joras
49d552c3f4 Store unique_ptr<StreamBuffer> in retransmissionBuffer.
Summary:
As it turns out, the extra indirection from storing a unique_ptr is not worse than the gain from using an `F14ValueMap` versus an `F14VectorMap`.

This reduces the `find` cost measurably in profiles, and doesn't appear to have any real negative effects otherwise.

Reviewed By: yangchi

Differential Revision: D20923854

fbshipit-source-id: a75c4649ea3dbf0e6c89ebfe0d31d082bbdc31fd
2020-04-08 14:35:16 -07:00
Yang Chi
df865c4e34 Round up Quic congestion control writable bytes to nearest multiple of packet
Summary:
Currently we return the exact writable bytes number from a real
congestion controller or Path Challenger. This diff round the number up to the
nearest multiple of packet length. Doing so can greatly reduce weird bytes
counting/checking bugs we have around packet writing.

Reviewed By: mjoras

Differential Revision: D20265678

fbshipit-source-id: 2973dde3acc4b2008337127482185f34e16efb43
2020-03-05 12:42:52 -08:00
Yang Chi
5bbbd964c8 DebugState -> WriteDebugState
Summary: prepare for read support

Reviewed By: lnicco

Differential Revision: D20120444

fbshipit-source-id: 2a78448750ea1ba13ddb285fa55df98713a90d41
2020-03-03 18:52:17 -08:00
Yang Chi
0fe2030305 Rename onSuspiciousLoops -> onSuspiciousWriteLoops
Summary: will add read side support

Reviewed By: lnicco

Differential Revision: D20120320

fbshipit-source-id: 83a515eff0cdd01142a78f21fbca4adbf96b4e62
2020-03-03 18:52:17 -08:00
TJ Yin
a396f62335 Replace folly::Optional::hasValue() by has_value()
Differential Revision: D19882830

fbshipit-source-id: 031217f9890351022bc8d171f0ccd7e045dd6972
2020-02-26 08:40:44 -08:00
Matt Joras
6827637d45 Use NiceMock in more tests
Summary: When we don't use NiceMock we end up with a ton of spam in failing tests for every callback that we didn't EXPECT. This makes failed test output extremely noisy.

Reviewed By: sharmafb

Differential Revision: D19977113

fbshipit-source-id: 1a083fba13308cd3f2859da364c8106e349775bb
2020-02-19 21:46:46 -08:00
TJ Yin
73a6de2488 Replace folly::Optional::clear() by reset()
Reviewed By: yfeldblum

Differential Revision: D19953637

fbshipit-source-id: c2135fc24084b7bba0c9d6fc978c8b6c8f9943d4
2020-02-19 12:11:47 -08:00
Andrejs Krasilnikovs
8114c3e3d0 Changed last packet sent times to bet per-packet-number-space andthe PTO timer calculation from them
Summary:
This diff:
1) introduces `EnumArray` - effectively an `std::array` indexed by an enum
2) changes loss times and `lastRetransmittablePacketSentTime` inside `LossState`  to be an `EnumArray` indexed by `PacketNumberSpace`
3) makes the method `isHandshakeDone()` available for both client and server handshakes.
4) uses all those inputs to determine PTO timers in `earliestTimeAndSpace()`

Reviewed By: yangchi

Differential Revision: D19650864

fbshipit-source-id: d72e4a0cf61d2dcb76f0a7f4037c36a7c8156942
2020-02-10 12:28:43 -08:00
Amaury Séchet
e6e6196c86 Move the delayed destruction from Handshake to QuicConnectionStateBase
Summary: Pull Request resolved: https://github.com/facebookincubator/mvfst/pull/88

Test Plan:
Imported from GitHub, without a `Test Plan:` line.

 ---
## Proxygen Canary
Traffic Canary: https://our.intern.facebook.com/intern/traffic/canary?fbid=224323975233396
* elb.prod.ham3c01 - binary_asan - 2020-02-05 02:00 - https://fburl.com/dyndash/u2q12hwq
* elb.prod.mia3c02 - binary - 2020-01-31 09:40 - https://fburl.com/dyndash/vmv34rpa
* elb.prod.otp1c01 - binary - 2020-02-05 02:26 - https://fburl.com/dyndash/0zttm61b
* flb.prod.fath4c02 - binary - 2020-02-05 02:26 - https://fburl.com/dyndash/6o1nqsti
* flb.prod.fgye3c01 - binary - 2020-01-31 09:40 - https://fburl.com/dyndash/nu3i5ahw
* olb.prod.rfrc0c01.p2 - binary - 2020-01-31 09:40 - https://fburl.com/dyndash/c1o6hpqw
* olb.prod.rftw0c01.p2 - binary - 2020-02-05 02:26 - https://fburl.com/dyndash/xg6qbyru
* slb.prod_regional.rcln0c00 - binary - 2020-02-05 02:26 - https://fburl.com/dyndash/e4qkbzcz
* slb.prod_regional.rfrc0c00 - binary - 2020-01-31 09:40 - https://fburl.com/dyndash/j0yxofty
* slb.prod_regional.rrva0c00 - binary_asan - 2020-02-05 02:00 - https://fburl.com/dyndash/4hsg02uj
* slb.regional.rfrc0c01.p2 - binary - 2020-01-31 09:40 - https://fburl.com/dyndash/1njxzbgf
* slb.regional.rvll0c01.p2 - binary - 2020-02-05 02:26 - https://fburl.com/dyndash/056xdmzn
 ---

Reviewed By: lnicco

Differential Revision: D19551142

Pulled By: mjoras

fbshipit-source-id: b0d14146d14384b8c37887b3e9d8fed7d6181d88
2020-02-05 06:13:33 -08:00
Yang Chi
d5b454a9c0 Back out "Quic pacing refactor"
Summary: Original commit changeset: b83e4a01fc81

Reviewed By: mjoras

Differential Revision: D19644828

fbshipit-source-id: 83d5a3454c6f9a8364e970d236cba008aef85fbd
2020-01-30 18:32:03 -08:00
Yang Chi
edb5104858 Quic pacing refactor
Summary:
(1) The first change is the pacing rate calculation is simplified. It
removes the interval calculation and just uses the timer tick as the interval.
Then it calculates the burst size from there.  For most cases these two
calculation should land at the same result, except when the
`cwnd < minBurstSize * tick / RTT`. In that case, the current calculation would
spread writes evenly across one RTT, assuming no new Ack arrives during the RTT;
while the new calculation uses the first a few ticks to finish the cwnd amount
of data.

(2) Then this diff changes how we compensate late timer. Now the pacer will
maintain a nextWriteTime_ and lastWriteTime_, which makes it easier to
calculate time elapsed since last write. Then each time writer tries to write,
it will be allowed to write timeElapsed * pacingRate. This is much more
intuitive than the current logic.

(3) The diff also adds pacing limited tracking into the pacer. An expected
pacing rate is cached when pacing rate is refreshed by congestion controller.
Then with packets sent out, Pacer keeps calculating the current send rate. When
the send rate is lower, Pacer sets pacingLimited_ to true. Otherwise false.

Only when the connection is not pacing limited, the lastWriteTime_ will be
packet sent time, otherwise it will be set to the last nextWriteTime_. In other
words: if the send rate is lower than expected, we use the expected send time
instead of real send time to calculate time elapsed, to allow higher late
timer compenstation, to give pacer a chance to catch up.

(4) Finally this diff removes the token collecting behavior in the pacer. I
think having tokens increaed, instead of reset, when an ack refreshes the pacing
rate or when we compensate late time, is quite confusing to some people. After
all the above changes, I found tperf can still sustain good throughput without
always increase tokens, and rally actualy gives even better results. So i think
we can remove this part of the pacer that's potentially very confusing to
people who don't know how we got there.

Reviewed By: mjoras

Differential Revision: D19252744

fbshipit-source-id: b83e4a01fc812fc52117f3ec0f5c3be1badf211f
2020-01-17 10:11:35 -08:00
Sergii Druzkin
5edf9ea815 Use MockQLogger instead of FileQLogger in unit tests
Summary: Some test cases used FileQLogger to verify that correct events have been logged. MockQLogger allows to check what events are logged without using an in-memory store like in FileQLogger. Migrated QuicLossFunctionsTest and QuicTransportTest from FileQLogger to MockQLOgger to simplify logic and cut dependencies.

Reviewed By: yangchi

Differential Revision: D19426423

fbshipit-source-id: eb1ae16a81656efd7c491eae790484c73dede8f3
2020-01-16 12:17:40 -08:00
Mirko Andjic
3f419b2eb2 Add vantage point to qlog.
Summary: Landing an outstanding diff

Reviewed By: yangchi

Differential Revision: D19261395

fbshipit-source-id: 437461222ff04f5c3271567d3bb064bceaf80029
2020-01-07 11:19:13 -08:00
Yang Chi
d7d19c74b5 Stop tracking pure ack packets in Quic
Summary:
Previously we track them since we thought we can get some additional
RTT samples. But these are bad RTT samples since peer can delays the acking of
pure acks. Now we no longer trust such RTT samples, there is no reason to keep
tracking pure ack packets.

Reviewed By: mjoras

Differential Revision: D18946081

fbshipit-source-id: 0a92d88e709edf8475d67791ba064c3e8b7f627a
2019-12-12 13:20:09 -08:00
Subodh Iyengar
54c5920397 dont append padding frames to write frames
Summary:
If the packet is too small we might automatically add padding frames
to make it large enough. However we used to add padding frames to the
frame list as well.

We dont need this, lets just add the regular frame types.

Reviewed By: mjoras

Differential Revision: D18903074

fbshipit-source-id: f73f82f96f833347c84a38eb1035c46e35ba3b2f
2019-12-09 21:02:23 -08:00
Subodh Iyengar
e524c0c069 iobufqueue diediedie
Summary:
Don't use IOBufQueue for most operations in mvfst and use BufQueue instead. Since BufQueue did not support a splitAtMost, added it in instead.

The only place that we still use IOBufQueue is in crypto because fizz still requires it

Reviewed By: mjoras

Differential Revision: D18846960

fbshipit-source-id: 4320b7f8614f8d2c75f6de0e6b786d33650e9656
2019-12-06 12:06:44 -08:00
Subodh Iyengar
d2fa2cbcd6 process multiple packets on recvmsg
Summary:
In the current client code we read one packet, go back to epoll, and then read
another packet. This is not very efficient.

This changes it so that we can read multiple packets in one go from an epoll
callback.

This only performs changes on the client

Reviewed By: mjoras

Differential Revision: D18797962

fbshipit-source-id: 81be82111064ade4fe3a07b1d9d3d01e180f29f5
2019-12-04 12:04:10 -08:00
Matt Joras
b6e134fdee Use F14FastMap as the retranmission buffer.
Summary:
The retransmission buffer tracks stream frame data we have sent that is currently unacked. We keep this as a sorted `deque`. This isn't so bad for performance, but we can do better if we break ourselves of the requirement that it be sorted (removing a binary search on ACK).

To do this we make the buffer a map of offset -> `StreamBuffer`.

There were two places that were dependent on the sorted nature of the list.

1. For partial reliablity we call `shrinkBuffers` to remove all unacked buffers less than an offset. For this we now have to do it with a full traversal of the retransmission buffer instead of only having to do an O(offset) search. In the future we could make this better by only lazily deleting from the retransmission buffer on ACK or packet loss.

2. We used the start of the retransmission buffer to determine if a delivery callback could be fired for a given offset. We need some new state to track this. Instead of tracking unacked buffers, we now track acked ranges using the existing `IntervalSet`. This set should be small for the typical case, as we think most ACKs will come in order and just cause existing ranges to merge.

Reviewed By: yangchi

Differential Revision: D18609467

fbshipit-source-id: 13cd2164352f1183362be9f675c1bdc686426698
2019-11-27 00:25:25 -08:00
Aman Sharma
69ac8aeb62 De-templatize stream state machine logic
Summary: The state machine logic is quite abstruse, this modifies it to make it more readable.

Reviewed By: siyengar

Differential Revision: D18488301

fbshipit-source-id: c6fd52973880931e34904713e8b147f56d0c4629
2019-11-19 20:18:11 -08:00
Viktor Chynarov
7504453972 Use Path Rate Limiter for conn migration
Summary:
Use the Path rate limiter introduced in the previous diff.

When we initialize path validation of an unvalidated peer address,
enable pathValidationRateLimit.

When we receive a proper PATH_RESPONSE frame, disable this limit.

If this limit is enabled, we will check the pathValidationLimiter for
the amount of bytes we are allowed to write.

Change the migration tests in QuicServerTransportTest to use this new limiter
instead of writableByteLimits.

Update shouldWriteData to directly use the new congestionControlWritableBytes
function.

Reviewed By: yangchi

Differential Revision: D18145774

fbshipit-source-id: 1fe4fd5be7486077c58b0d1285dfb03f6c62831c
2019-11-14 13:48:17 -08:00
Matt Joras
027fedad5b Search loss buffer before retransmission buffer when determining if a write is a clone.
Summary:
We maintain the invariant that a buffer cannot be in the loss buffer and retransmission buffers at the same time. As the retransmission buffer holds all unacknowledged data that isn't marked lost, it is very likely to be larger than the loss buffer. This makes the existing case to check for cloning very expensive.

Instead search the loss buffer first, change the search of the loss buffer to a binary search, and elide the double search.

Reviewed By: yangchi

Differential Revision: D18203444

fbshipit-source-id: 66a4e424d61c4b0e3cad12c7eca009ad3d6c5a0d
2019-10-29 12:33:34 -07:00
Yang Chi
9247b8f49b Change Quic qlogger vantage point to enum
Summary: To prevent adhoc string passed in

Reviewed By: sharma95

Differential Revision: D18013615

fbshipit-source-id: 6f5512468755c2b1ecbba3ba42188fa22f4e94b9
2019-10-23 10:16:58 -07:00
Matt Joras
c0a0919113 Fix stream scheduling round robin.
Summary:
The intention here was always to write to streams in a round robin fashion. However, this functionality has been effectively broken since introduction as `lastScheduledStream` was never set. We can fix this by having the `StreamFrameScheduler` set `nextScheduledStream` after it has written to the streams. Additionally we need to remove a check that kept us from moving past a stream if it still had data left to write.

In extreme cases this would cause streams to be completely starved, and ruin concurrency.

Reviewed By: siyengar

Differential Revision: D17748652

fbshipit-source-id: a3d05c54ee7eaed4d858df9d89035fe8f252c727
2019-10-08 12:30:55 -07:00
Subodh Iyengar
cbbc6b0c77 Custom variant for simple frames
Summary: Use a custom variant for simple frames

Reviewed By: mjoras

Differential Revision: D17781068

fbshipit-source-id: e059d33df4651c7e0a1c989cc8651c9cd661b14b
2019-10-07 22:43:32 -07:00
Subodh Iyengar
68c332acb1 Use custom variant type for write frames
Summary:
Use the custom variant type for write frames as well, now that
we use them for read frames.

Reviewed By: mjoras

Differential Revision: D17776862

fbshipit-source-id: 47093146d0f1565c22e5393ed012c70e2e23d279
2019-10-07 22:43:31 -07:00
Viktor Chynarov
56c18e96ef Back out "Revert D17636918: [quic] Create findFrameInPacketFunc helper function for unit tests"
Summary: Original commit changeset: dcc2b618c2a7

Reviewed By: lnicco

Differential Revision: D17688819

fbshipit-source-id: 9dd3dbcfd78549f5858a41b67db7fc4bc0647469
2019-10-01 11:11:06 -07:00
Viktor Chynarov
7ca3482f1d Back out "Revert D15268028: [quic] Process lost RetireConnectionIdFrame"
Summary: Original commit changeset: 0447c8666a58

Reviewed By: lnicco

Differential Revision: D17688744

fbshipit-source-id: 8fc2180f65b9a9c03f40f3d242ee020ee319765c
2019-10-01 11:11:06 -07:00
Viktor Chynarov
8af79b3436 Back out "Revert D15267963: [quic] Clone RetireConnectionIdFrame"
Summary: Original commit changeset: c9fb0a514788

Reviewed By: lnicco

Differential Revision: D17688756

fbshipit-source-id: fc098fa9804bf0076cb8f2ff0c6d6b8550021a34
2019-10-01 11:11:05 -07:00
Viktor Chynarov
7682c12bf5 Back out "Revert D15267820: [quic] Add unit test for sending RetireConnectionIdFrame"
Summary: Original commit changeset: 899b6773521a

Reviewed By: lnicco

Differential Revision: D17688590

fbshipit-source-id: fd96f34c97e0c9253cd576447cb8efb6564c3ed5
2019-10-01 11:11:05 -07:00
Shawn Shihang Wei
2bdb9b0dcc Revert D15267820: [quic] Add unit test for sending RetireConnectionIdFrame
Differential Revision:
D15267820

Original commit changeset: b885ca6b5dfa

fbshipit-source-id: 899b6773521a347f06972d69e6be8456dc4e9e7d
2019-09-30 18:49:59 -07:00
Shawn Shihang Wei
52a79997d8 Revert D15267963: [quic] Clone RetireConnectionIdFrame
Differential Revision:
D15267963

Original commit changeset: a2e9059900c0

fbshipit-source-id: c9fb0a514788dd32d5f1956dbea4dcefe34468c8
2019-09-30 18:49:59 -07:00
Shawn Shihang Wei
59f20c91c7 Revert D15268028: [quic] Process lost RetireConnectionIdFrame
Differential Revision:
D15268028

Original commit changeset: 238dcf524251

fbshipit-source-id: 0447c8666a5814e9f88e9f6decd61db54d5c0a34
2019-09-30 18:49:58 -07:00
Shawn Shihang Wei
3ca024e3b8 Revert D17636918: [quic] Create findFrameInPacketFunc helper function for unit tests
Differential Revision:
D17636918

Original commit changeset: 927b3a880ee0

fbshipit-source-id: dcc2b618c2a7accde254d01b5d549a08041dd589
2019-09-30 18:49:58 -07:00
Viktor Chynarov
5199ae5b8d Create findFrameInPacketFunc helper function for unit tests
Summary: Removes a lot of unnecessary code in UT.

Reviewed By: sharma95

Differential Revision: D17636918

fbshipit-source-id: 927b3a880ee0db23b18c81875254fd8b86317bd3
2019-09-30 17:40:14 -07:00
Viktor Chynarov
edb8104fe7 Process lost RetireConnectionIdFrame
Reviewed By: sharma95

Differential Revision: D15268028

fbshipit-source-id: 238dcf524251e6134d2685d5ad821658982c953e
2019-09-30 17:40:14 -07:00
Viktor Chynarov
fbd80f3428 Clone RetireConnectionIdFrame
Reviewed By: sharma95

Differential Revision: D15267963

fbshipit-source-id: a2e9059900c0c231e53d672a4d9495173ed546cc
2019-09-30 17:40:14 -07:00
Viktor Chynarov
d0c61cd8c7 Add unit test for sending RetireConnectionIdFrame
Reviewed By: sharma95

Differential Revision: D15267820

fbshipit-source-id: b885ca6b5dfa7262338168a796caedf391189d85
2019-09-30 17:40:14 -07:00
Subodh Iyengar
04baa15a04 Custom variant type for packetheader
Summary:
Make a custom variant type for PacketHeader. By not relying on boost::variant
this reduces the code size of the implementation.

This uses a combination of a union type as well as a enum type to emulate a variant

Reviewed By: yangchi

Differential Revision: D17187589

fbshipit-source-id: 00c2b9b8dd3f3e73af766d84888b13b9d867165a
2019-09-19 17:31:47 -07:00
Yang Chi
c0a659a30a Replace pacing related callsites with new Pacer interface
Summary:
Use the new Pacer interface in the transport where we currently
directly use CongestinoController interrace for paciner related APIs.

Reviewed By: mjoras

Differential Revision: D16918672

fbshipit-source-id: 410f72d567e71bdd3279e344f6e9abf5e132518e
2019-08-30 19:30:44 -07:00
Yang Chi
62cfa01091 Remove canBePaced API from CongestionController
Summary: Centralize this logic into the pacer interface. But instead of having an explicit canBePaced() function (and we already have a dozen other canBePaced functions or boolean flags in other layers), the pacer just use 0us and default write batch size per loop to answer pacing rate queries when it doesn't meet the condition to properly pace the transport writes.

Reviewed By: mjoras

Differential Revision: D16912631

fbshipit-source-id: 0343b126ca5de315af6823067316526b1004cc6c
2019-08-30 15:10:55 -07:00
Junqi Wang
346a51f63f Update NewConnectionIdFrame to D-22
Summary: ^

Reviewed By: sharma95

Differential Revision: D16466184

fbshipit-source-id: f5a9b8e65e92048393b78305b0d176ab2f4fe338
2019-07-25 11:52:20 -07:00
Bonnie Xu
0929100b18 Add transportStateUpdate event
Summary: Add transportStateUpdate event so it can be part of qlog.

Reviewed By: mjoras

Differential Revision: D16342467

fbshipit-source-id: 109189275d44996850b82646bab4a733a3a4c7a1
2019-07-25 11:52:19 -07:00
Matt Joras
ece3cbe387 Draft-22 varint error codes
Summary: These were changed to varints. To support this we need to do some extra horrible version plumbing. I don't want to keep this long term but it works for now.

Reviewed By: yangchi

Differential Revision: D16293568

fbshipit-source-id: a9ea9083be160aa3e6b338a7d70d7f00e44ec5ab
2019-07-18 12:07:57 -07:00
Yang Chi
2a97d4533c Quic busy write loop detector
Summary:
This diff adds a DebugState in the QuicConnectionState to track the
reason we schedule transport WriteLooper to run, the reason we end up not
writing and the number of times such write happens consecutively. And when it
reaches a predefined limit, we trigger a callback on a loop detector interface.

Reviewed By: kvtsoy

Differential Revision: D15433881

fbshipit-source-id: d903342c00bc4dccf8d7320726368d23295bec66
2019-07-17 15:18:57 -07:00
Junqi Wang
0cc3eabc56 Do not retransmit PATH_RESPONSE
Summary: https://github.com/quicwg/base-drafts/issues/2724

Reviewed By: mjoras

Differential Revision: D15719978

fbshipit-source-id: 1c57f3e2b497f1abfcd5fa3b5643d76aa51d11d9
2019-06-26 22:30:38 -07:00