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

108 Commits

Author SHA1 Message Date
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
Yang Chi
06083595e3 Do not enable pacing if transport doesn't have pacing timer
Summary:
LOG an error and fallback to no pacing. This diff also stops
supporting automaticaly set pacingEnabled to true when BBR is enabled.

Reviewed By: mjoras

Differential Revision: D22875904

fbshipit-source-id: f8c8c9ea252f6e5e86f83174309b159ce93b3919
2020-08-03 10:38:39 -07:00
Yang Chi
93c94e0ea5 Replace std::chrono::duration_cast<milliseconds> with folly::chrono::ceil in
Summary:
duration_cast round towards zero. The diff uses folly::chrono::ceil
rather than std::chrono::ceil since we still need to compile with c++14

Differential Revision: D22870632

fbshipit-source-id: 18439488e879164807b1676a0105073348800412
2020-07-31 23:05:10 -07:00
Matt Joras
27af216813 Reset pacing tokens when coming out of app-limited.
Summary:
It is possible that when becoming app-limited we will have collected some extra pacing tokens. When we finally become un-app-limited, these tokens will cause us to write a large burst all at once.

Avoid this by explicitly resetting the tokens when we have new data to write, effectively restarting pacing.

Reviewed By: yangchi

Differential Revision: D22669645

fbshipit-source-id: 9415303952c96f12136a63c0d773255e28dc151c
2020-07-29 16:54:44 -07:00
Yang Chi
8b007886df Experiment with longer timer compensation in Quic Pacer
Summary:
Our current timer compenstation works as following:

Pacer schedule write -> Pacer marks scheduled time T0-> timer fires -> Pacer uses (now - T0 + writeInterval) to calculate burst size -> transport writes burst size amount of data at time T1 -> pacer schedules again.

This diff changes to:

Pacer scheduleWrite -> timer fires -> Pacer uses (now - previous T1' + writeInteral) to calculate burst size -> transport writes burst size amount of data at T1 -> pacer schedules again

because T1' < T0 < T1, this compensates the timer more.

With higher compensation from timer interval calculation, the `tokens_ += batchSize_;` code inside refreshPacingRate is removed in this diff.

Reviewed By: yangchi

Differential Revision: D22532672

fbshipit-source-id: 6547298e933965ab412d944cfd65d5c60f4dced7
2020-07-29 16:54:44 -07:00
Matt Joras
90f2421611 Re-lookup stream after callback.
Summary: We don't know if this pointer remains valid after the callback.

Reviewed By: yangchi

Differential Revision: D22709445

fbshipit-source-id: 7802ab08052b06af0268652a44a080d9d9673122
2020-07-24 17:45:47 -07:00
Brandon Schlinker
b4df09831b Support for TX timestamping
Summary:
Adds support for timestamping on TX (TX byte events). This allows the application to determine when a byte that it previously wrote to the transport was put onto the wire.

Callbacks are processed within a new function `QuicTransportBase::processCallbacksAfterWriteData`, which is invoked by `writeSocketDataAndCatch`.

Reviewed By: mjoras

Differential Revision: D22008855

fbshipit-source-id: 99c1697cb74bb2387dbad231611be58f9392c99f
2020-07-16 22:45:34 -07:00
Brandon Schlinker
d332cc4e0c Generic ByteEvent infrastructure
Summary:
Introduces framework for handling callbacks when a `ByteEvent` occurs.

- Adds `ByteEventCallback`, a new class that can be used to notify a callback implementation about delivery (ACK) of a byte and is used in the subsequent diff for notifications about TX of a byte.
- Adds `ByteEvent` and `ByteEventCancellation`, both of which are used to communicate ancillary information when a ByteEvent happens to the callback implementation. This makes it easier to add additional fields (such as kernel timestamps, information about ACK delays, etc) in the future, without requiring the function signatures of all callback implementations to be updated.
- For the moment, `DeliveryCallback` inherits from `ByteEventCallback` so that existing implementations do not need to be adjusted; `DeliveryCallback` implements `ByteEventCallback`'s methods and transforms the received `ByteEvents` into the expected callback. I will deprecate `DeliveryCallback` in a subsequent diff.
- Refactors existing logic for handling delivery callbacks to be generic and capable of handling different types of byte events. This allows the same logic for registering and cancelling byte events to be reused for ACK and TX timestamps; custom logic is only required to decide when to trigger the callback.

Reviewed By: mjoras

Differential Revision: D21877803

fbshipit-source-id: 74f344aa9f83ddee2a3d0056c97c62da4a581580
2020-07-16 22:45:34 -07:00
Brandon Schlinker
ad8ca14760 Instrumentation callback foundation w/ app rate limited
Summary:
Adds `QuicSocket::InstrumentationObserver`, an observer that can be registered to receive various transport events.

The ultimate goal of this class is to provide an interface similar to what we have through TCP tracepoints. This means we need to be able to register multiple callbacks.

- Initially, the first event exposed through the callback is app rate limited. In the future, we will expose retransmissions (which are loss + TLP), loss events (confirmed), spurious retransmits, RTT measurements, and raw ACK / send operations to enable throughput and goodput measurements.
- Multiple callbacks can be registered, but a `folly::small_vector` is used to minimize memory overhead in the common case of between 0 and 2 callbacks registered.
- We currently have a few different callback classes to support instrumentation, including `QuicTransportStatsCallback` and `QLogger`. However, neither of these meet our needs:
  - We only support installing a single transport stats callback and QLogger callback, and they're both specialized to specific use cases. TransportStats is about understanding in aggregation how often an event (like CWND limited) is occurring, and QLogger is about logging a specific event, instead of notifying a callback about an event and allowing it to decide how to proceed.
  - Ideally, we can find a way to create a callback class that handles all three cases; we can start strategizing around that as we extend `InstrumentationObserver` and identify overlap.

Differential Revision: D21923745

fbshipit-source-id: 9fb4337d55ba3e96a89dccf035f2f6978761583e
2020-07-16 10:25:45 -07:00
Brandon Schlinker
e43eb2e8b4 Notify connection callback when app rate limited
Summary:
Notify connection callback implementation when the transport becomes app rate limited
- The callback implementation is not required to define a handler for this callback (not pure virtual).
- D21923745 will add an instrumentation callback class that can be used to allow other components to receive this signal. I'm extending to the connection callback because the overhead seems low, and we already have the connection callback registered for `HQSession`.

Reviewed By: mjoras, lnicco

Differential Revision: D21923744

fbshipit-source-id: 153696aefeab82b7fd8a6bc299c011dcce479995
2020-07-16 10:25:45 -07:00
Brandon Schlinker
98e0e4dc5d Socket lifecycle observer
Summary:
Adds `QuicSocket::LifecycleObserver`, an observer that is notified when a socket is closed and destroyed.

- Can be used by instrumentation that ties its lifetime to that of the socket.
- Multiple observer can be registered, but a `folly::small_vector` is used to minimize memory overhead in the common case of 0 - 2 being registered.
- `folly::AsyncSocket` has a matching interface being added (D21613750), so instrumentation can follow the same paradigm for both QUIC and TCP.
- In the future, will extend to also be triggered when a transport becomes connected, similar to what we have for `AsyncSocket`.

Reviewed By: mjoras

Differential Revision: D21653651

fbshipit-source-id: 0aa374cc0dd9b9c11d81b49597326bd53264531d
2020-07-16 10:25:45 -07:00
Matt Joras
c94521f511 Optionally order read callbacks.
Summary: Without this option the read callbacks come in an  somewhat random order based on stream ID. This enforces ordering by stream ID, which is useful for some applications.

Reviewed By: yangchi

Differential Revision: D22442837

fbshipit-source-id: cd97de9760deff7b19841f46e23da2004df31492
2020-07-08 18:27:15 -07:00
Andrii Vasylevskyi
311a408958 ConnectionCallback functions when local openable streams become available
Summary:
Callbacks notifying that max stream limit has been increased and new streams can be created.
This get triggered every time limit gets bumped, doesn't track if limit was previously exhausted or not.

Reviewed By: mjoras

Differential Revision: D22339814

fbshipit-source-id: 6bcd0b52adb61e1ac440d11559dc8544ad7aa1ac
2020-07-08 09:17:48 -07:00
Matt Joras
9fae556dad Back out "Don't crash if the we are closed with loss timeout."
Summary: Crashing is good.

Reviewed By: yangchi, lnicco

Differential Revision: D22210167

fbshipit-source-id: 7572a9686970d5a63c8c374949aed5a223ebe6f2
2020-06-24 17:39:05 -07:00
Matt Joras
c91f2469cc Don't crash if the we are closed with loss timeout.
Summary: As in title.

Reviewed By: lnicco

Differential Revision: D22180331

fbshipit-source-id: a0f851157af9312325924ca67a654101ec652e74
2020-06-22 21:27:57 -07:00
Yang Chi
51b917b0b3 PingFrame is not a simple frame
Summary:
The problem with Ping being a simple frame:
(1) All SimpleFrames are in the same scheduler. So sending ping means we may
also send other frames which can be problematic if we send in Initial or
Handshake space
(2) Ping isn't retranmisttable. But other Simple frames are. So we are
certainly setting this wrong when we send pure Ping packet today.

That being said, there are cases where we need to treat Ping as retransmittable.
One is when it comes to update ack state: If peer sends us Ping, we may want to
Ack early rather than late. so it makes sense to treat Ping as retransmittable.
Another place is insertion into OutstandingPackets list. When our API user sends
Ping, then also add a Ping timeout. Without adding pure Ping packets into OP list,
we won't be able to track the acks to our Pings.

Reviewed By: mjoras

Differential Revision: D21763935

fbshipit-source-id: a04e97b50cf4dd4e3974320a4d2cc16eda48eef9
2020-06-18 15:30:44 -07:00
Yang Chi
b8fef40c6d Clone Quic handshake packets
Summary:
On loss timer, currently we knock all handshake packets out of the OP
list and resend everything. This means miss RTT sampling opportunities during
handshake if loss timer fires, and given our initial loss timer is likely not a
good fit for many networks, it probably fires a lot.

This diff keeps handshake packets in the OP list, and add packet cloning
support to handshake packets so we can clone them and send as probes.

With this, the handshake alarm is finally removed. PTO will take care of all
packet number space.

The diff also fixes a bug in the CloningScheduler where we missed cipher
overhead setting. That broke a few unit tests once we started to clone
handshake packets.

The writeProbingDataToSocket API is also changed to support passing a token to
it so when we clone Initial, token is added correctly. This is because during
packet cloning, we only clone frames. Headers are fresh built.

The diff also changed the cloning behavior when there is only one outstanding
packet. Currently we clone it twice and send two packets. There is no point of
doing that. Now when loss timer fires and when there is only one outstanding
packet, we only clone once.

The PacketEvent, which was an alias of PacketNumber, is now a real type that
has both PacketNumber and PacketNumberSpace to support cloning of handshake
packets. I think in the long term we should refactor PacketNumber itself into a
real type.

Reviewed By: mjoras

Differential Revision: D19863693

fbshipit-source-id: e427bb392021445a9388c15e7ea807852ddcbd08
2020-06-18 15:30:44 -07:00
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
Andrii Vasylevskyi
7a50ca13c7 Refactor writeChain function signature not to reutrn IOBuf
Summary: Updating signature of writeChain to stop returning IOBuf, as implementation never actually returns back buffer and always writes full buffer.

Reviewed By: mjoras

Differential Revision: D21740607

fbshipit-source-id: f473ed8f3c6c6cbe2dd5db8f1247c912f3e77d0b
2020-06-02 05:16:00 -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
Yang Chi
9554a67c73 add a check for Quic inplace writer for the remaining buffer size
Summary:
as title. Instead of checking against the packet size limit, this
leaves a 10 bytes room since we have a bug that writes out packets that's
slightly larger than udpSendPacketLen. Most of such packet will be 1-2 bytes
larger than original packets.

Reviewed By: mjoras

Differential Revision: D21642386

fbshipit-source-id: 6ca68d48828cb7f8ee692e0d5f452f5389a56bfd
2020-05-26 12:47:44 -07:00
Matt Joras
87212cc872 Bail if any callback causes a close.
Summary: As in title. Also explicitly do some copying of values out of the stream manger.

Reviewed By: yangchi

Differential Revision: D21705460

fbshipit-source-id: 2399b8561a2aa3b6d2b64d154f56ceff22c40186
2020-05-24 13:01:52 -07:00
Matt Joras
34901ee92f Discard the connection immediately on failed migration.
Summary: There's no particular reason to wait for the drain period before removing state. By doing this a failed migration will immediately trigger the server to drop state, triggered a stateless reset signal to the client sooner.

Reviewed By: yangchi, lnicco

Differential Revision: D21643179

fbshipit-source-id: a60ca2c92935a3e6ba773d7936c25317733f7b97
2020-05-19 13:24:08 -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
Yang Chi
081b63ffce Give QuicServerWorker an output buffer for GSO write with continuous memory
Summary: as title

Reviewed By: mjoras

Differential Revision: D20919833

fbshipit-source-id: 8cd9674d7bccf115cbdac5b976ba70e5dcb70e14
2020-04-28 22:14:20 -07:00
Carmi Grushko
cf729dbafb Don't schedule a PING timeout if callback is nullptr or timeout is 0
Reviewed By: yangchi

Differential Revision: D21249143

fbshipit-source-id: 690abd63272aa666caa7ebc5f3d41f49376281f1
2020-04-28 19:31:48 -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
68d6d9203a Stream manager and QuicTransportBase stream API cleanups.
Summary:
Some of these are relevant to performance, others are just cleanups of the API usage.

The performance diffs are generally eschewing multiple lookups into the underlying structures, by reusing the iterator from `find`.

The cleanups are mostly getting rid of checks against `getStream`, which cannot return `nullptr`.

Reviewed By: yangchi

Differential Revision: D20987998

fbshipit-source-id: 1b95fd8b14da934fc921527aa858dcebf80ec8e9
2020-04-13 10:21:45 -07:00
Yang Chi
d2e7e16c31 Short-circuit peek looper if there is no peek callback
Summary:
We always add stuff into peekable streams set since everything with a
read buffer is peekable. This makes the this set potentially big, and the
find_if quite expensive. For apps that isn't interested in peeking,  this is a
waste of time.

Reviewed By: mjoras, lnicco

Differential Revision: D20972192

fbshipit-source-id: d696ded936140c622e019d608c72a646df405111
2020-04-11 12:49:40 -07:00
Luca Niccolini
5ca21a5278 rename infoCallback to statsCallback
Summary:
```
find ./quic | xargs -I{} sed -i "s/infoCallback/statsCallback/g" {}
find ./quic | xargs -I{} sed -i "s/InfoCallback/StatsCallback/g" {}
```

(Note: this ignores all push blocking failures!)

Reviewed By: mjoras

Differential Revision: D20860675

fbshipit-source-id: 4fe99a375b5983da51b6727d7f40788f89083ab3
2020-04-11 11:16:51 -07:00
Matt Joras
aa4229f6a6 Reuse iterator when erasing callbacks.
Summary: Doing an extra lookup here is wasteful.

Reviewed By: yangchi, lnicco

Differential Revision: D20848227

fbshipit-source-id: 8a1fee28597fae3cf1ac284a1bd781936ddff931
2020-04-06 10:15:01 -07:00
Matt Joras
c826dd592b Do not checkForClosedStream from read.
Summary:
This is a pretty confusing API behavior. This means that when reading from stream A, stream B could potentially be removed if it doesn't have a read callback set. This effectively means you cannot safely call read from onNew*Stream.

There's no real reason the check for a closed stream here, as the streams will get cleaned up from the onNetworkData or read looper calls.

Reviewed By: yangchi

Differential Revision: D20848090

fbshipit-source-id: 38eba9e5a24b6ddf5bf05ac75787dda9c001c1c6
2020-04-06 10:15:01 -07:00
Yang Chi
de9c1e137d Use unsanitized error message in Quic app callback cancelation
Summary:
Right now we use un-sanitized error message on onConnectionError only.
This also uses it in app callbacks

Reviewed By: lnicco

Differential Revision: D20843327

fbshipit-source-id: c81896d41b712a7165ac6f6b381d3687ecca2a3a
2020-04-05 09:49:42 -07:00
Matt Joras
19e1c14afd Report exception strings via onConnectionError.
Summary: It's not a great practice to leak the excpetion string via a conn close, but it is useful for the app to be able to report what the exception string was.

Reviewed By: yangchi

Differential Revision: D20628591

fbshipit-source-id: bf6eb5f33f516cec0034caed53da998643fcc120
2020-03-27 15:05:11 -07:00
Amaury Séchet
7a1b58e5e8 Move early app data params getter and validator to QuicConnectionStateBase (#117)
Summary:
This ensures they are available to the whole stack rather than the transport only. The validator needs it in the server case, and will soon need it in the client case, so that seems appropriate to make it available.
Pull Request resolved: https://github.com/facebookincubator/mvfst/pull/117

Reviewed By: yangchi

Differential Revision: D20536366

Pulled By: mjoras

fbshipit-source-id: a76d369c0a82b9be1f985aed1f33f7a6b338a2ae
2020-03-23 10:55:01 -07:00
Yang Chi
fc41c9964f New QuicSocket API to unregister stream WriteCallback
Summary:
Currnetly there isn't a way for apps to unregister a pending
WriteCallbacks for a stream. resetStream() does that if the transport isn't in
Closed state. This diff adds such support even if transport is already in
Closed state. This solves the problem where app has a class that's both stream
ReadCallback and stream WriteCallback and readError would kill the callback
object itself. The new API gives such class a chance to remove itself from the
transport.

Reviewed By: mjoras

Differential Revision: D20545067

fbshipit-source-id: 81d9f025310769aadef062711a49adc47a0639d0
2020-03-19 22:25:18 -07:00
Matt Joras
68e7f055b3 Fix onConnectionError case for NO_ERROR application errors.
Summary:
This somewhat contrains what applications using mvfst can do with their errors, as it makes the semantics of onConnectionEnd vs onConnectionError tied to the value of GenericApplicationError::NO_ERROR.

For now, we believe this is fine, and fixes a case of connection close mis classification by HQSession.

Reviewed By: yangchi

Differential Revision: D20550139

fbshipit-source-id: eec7d90c33141bfa7f1280bf5b569818890d1130
2020-03-19 18:58:58 -07:00
Matt Joras
42e49bb262 Translate API closes to Application closes on the wire.
Summary: Previously we would end up writing a non-application close when the application calls close(folly::none). This isn't correct, as those cases should be an application error with no error.

Reviewed By: afrind

Differential Revision: D20518529

fbshipit-source-id: fe069cccc32bd550fb3ec599694110955816993f
2020-03-18 19:48:23 -07:00
Matt Joras
694a9bb4cf Unset stream write callback on reset
Summary: Resetting a stream has the semantics of abandoning all writes on that stream. As such, the application resetting the stream is an implicit signal that it does not care about further writes. It is reasonable then for an application to not expect further write callbacks to trigger.

Reviewed By: lnicco

Differential Revision: D20462859

fbshipit-source-id: b6701e6a262d618c5cd93fd1531095a134f6554e
2020-03-15 18:54:55 -07:00
Yang Chi
fa1fae0d26 Introduce empty read loop detection callback in Quic
Summary:
Similar to the exiting empty write loop callback. The new API will
trigger when we read from socket but back with empty hands.

Reviewed By: lnicco

Differential Revision: D20130432

fbshipit-source-id: 9b61310b4ea4c5c7999742c5a8761a831f20f7b7
2020-03-03 18:52:17 -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
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
Anton Frolov
1482011db5 Remove UNLIKELY and LIKELY calls from mvfst
Summary:
All instancesi of LIKELY and UNLIKELY probably should be removed. We will
add them back in if we see pathologies in performance profiles.

Reviewed By: mjoras

Differential Revision: D19163441

fbshipit-source-id: c4c2494d18ecfd28f00af1e68ecaf1e85c1a2e10
2020-01-06 17:44:07 -08:00