limit the amount it can send in a single tick (speed boost :D)

This commit is contained in:
2023-12-13 17:56:56 +01:00
parent 0a53a76eb3
commit b0e2cab17a
2 changed files with 18 additions and 2 deletions

View File

@@ -41,11 +41,17 @@ int64_t FlowOnly::canSend(void) {
updateWindow();
const int64_t fspace = _fwnd - _in_flight_bytes;
int64_t fspace = _fwnd - _in_flight_bytes;
if (fspace < MAXIMUM_SEGMENT_DATA_SIZE) {
return 0u;
}
// also limit to max sendrate per tick, which is usually smaller than window
// this is mostly to prevent spikes on empty windows
// assuming at most 20ms tick interval
// TODO: pass down actual tick interval
fspace = std::min<int64_t>(fspace, max_byterate_allowed * 0.02f + 0.5f);
// limit to whole packets
return (fspace / MAXIMUM_SEGMENT_DATA_SIZE) * MAXIMUM_SEGMENT_DATA_SIZE;
}