Skip to content

Commit

Permalink
Removed the underbuffered check
Browse files Browse the repository at this point in the history
  • Loading branch information
ahardewig committed Nov 17, 2020
1 parent 50a6b35 commit fb433d1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,8 @@ class Uploader(
}

private fun sendToWebSocket(data: ByteString, ws: WebSocket) {
val underBuffered = data.size * 7

while (ws.queueSize() < underBuffered && ws.queueSize() + data.size < MAX_QUEUE_SIZE) {
while (ws.queueSize() + data.size < MAX_QUEUE_SIZE) {
ws.send(data)
totalBytesSent += data.size
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ internal object PayloadTransformer {

// this is gonna let higher speed clients saturate their pipes better
// it will gradually increase the size of data if the websocket queue isn't filling up
fun performDynamicTuning(data: ByteString, queueSize: Long, totalBytesSent: Double): ByteString {
fun performDynamicTuning(data: ByteString, queueSize: Long, bytesEnqueued: Double): ByteString {
val totalBytesTransmitted = bytesEnqueued - queueSize

return if (data.size < NDT7Constants.MAX_MESSAGE_SIZE && data.size < (totalBytesSent - queueSize) / 16) {
return if (data.size * 2 < NDT7Constants.MAX_MESSAGE_SIZE && data.size < totalBytesTransmitted / 16) {
ByteString.of(*ByteArray(data.size * 2)) // double the size of data
} else {
data
Expand Down

0 comments on commit fb433d1

Please sign in to comment.