Skip to content

Commit

Permalink
Round the batch size to the nearest integer in experimental mode
Browse files Browse the repository at this point in the history
Summary:
The previous batch size calculation in the experimental pacer takes the floor of the batch size after scaling it up to the time since last write. Given the batchSizes can be as small as 5, taking the floor can significatly impact the pacer's ability to fully utilize the link.

This changes the batch size calculation to round the number to the nearest integer, which improves the accuracy of the pacer.

When trying to pace at 284 Mbps on a 500 Mbps link:
- Vanilla pacer achieves 128 Mbps
- Experimental pacer (without this change) achieves 273.7 Mbps
- Experimental pacer (with this change) achieves 282.5 Mbps

Reviewed By: mjoras

Differential Revision: D53549757

fbshipit-source-id: 2c81c48bd862acdf83a58c0ca1d993520adc4388
  • Loading branch information
jbeshay authored and facebook-github-bot committed Feb 9, 2024
1 parent a3bf013 commit 92f0708
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions quic/congestion_control/TokenlessPacer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,15 @@ uint64_t TokenlessPacer::updateAndGetWriteBatchSize(TimePoint currentTime) {
QUIC_STATS(conn_.statsCallback, onPacerTimerLagged);
}
if (experimental_) {
sendBatch = (timeSinceLastWrite / writeInterval_ >= maxBurstIntervals)
? batchSize_ * maxBurstIntervals
: batchSize_ * timeSinceLastWrite / writeInterval_;
if (timeSinceLastWrite / writeInterval_ >= maxBurstIntervals) {
sendBatch = batchSize_ * maxBurstIntervals;
} else {
// Scale the batch size and round it to the closest integer
auto numerator = batchSize_ * timeSinceLastWrite;
auto& denominator = writeInterval_;
sendBatch = numerator / denominator +
(numerator % denominator >= denominator / 2 ? 1 : 0);
}
}
}
lastWriteTime_ = currentTime;
Expand Down

0 comments on commit 92f0708

Please sign in to comment.