Skip to content

Commit 362a872

Browse files
committed
Formula was stalled for very low values
For 128 it would stop at 97 never increasing because the moving average being used is an integer. Perhaps I should reconsider and use floats instead. For now I have changed the formula to not block at 97, by dividing by 8 instead of 32. We now increase enough that we can increase past the threshold.
1 parent d4321e0 commit 362a872

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

deps/rabbit/src/rabbit_reader.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ maybe_resize_buffer(State=#v1{sock=Sock, dynamic_buffer_size=BufferSize0,
546546
LowDynamicBuffer = 128,
547547
HighDynamicBuffer = 131072,
548548
DataLen = byte_size(Data),
549-
MovingAvg = (MovingAvg0 * 31 + DataLen) div 32,
549+
MovingAvg = (MovingAvg0 * 7 + DataLen) div 8,
550550
if
551551
BufferSize0 < HighDynamicBuffer andalso MovingAvg > BufferSize0 * 0.9 ->
552552
BufferSize = min(BufferSize0 * 2, HighDynamicBuffer),

0 commit comments

Comments
 (0)