Skip to content

Commit c35cfb7

Browse files
committed
Use floats for moving average
Still using / 8 because / 32 gets pretty slow to increase for low buffer sizes.
1 parent 362a872 commit c35cfb7

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

deps/rabbit/src/rabbit_reader.erl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@
102102
proxy_socket,
103103
%% dynamic buffer
104104
dynamic_buffer_size = 128,
105-
dynamic_buffer_moving_average = 0
105+
dynamic_buffer_moving_average = 0.0
106106
}).
107107

108108
-record(throttle, {
@@ -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 * 7 + DataLen) div 8,
549+
MovingAvg = (MovingAvg0 * 7 + DataLen) / 8,
550550
if
551551
BufferSize0 < HighDynamicBuffer andalso MovingAvg > BufferSize0 * 0.9 ->
552552
BufferSize = min(BufferSize0 * 2, HighDynamicBuffer),

0 commit comments

Comments
 (0)