wip: tune egress draining strategy

This commit is contained in:
Andrew Mayorov 2024-02-22 18:41:10 +01:00
parent 1895b250e9
commit 574746b190
No known key found for this signature in database
GPG Key ID: 2837C62ACFBFED5D
1 changed files with 3 additions and 2 deletions

View File

@ -48,6 +48,7 @@
%% Type declarations
%%================================================================================
-define(ACCUM_TIMEOUT, 4).
-define(DRAIN_TIMEOUT, 1).
-define(COOLDOWN_TIMEOUT_MIN, 1000).
-define(COOLDOWN_TIMEOUT_MAX, 5000).
@ -112,7 +113,7 @@ handle_cast(_Cast, S) ->
{noreply, S}.
handle_info(Req = {_Pid, _Ref, #message{}}, S) ->
ok = timer:sleep(?DRAIN_TIMEOUT),
ok = timer:sleep(?ACCUM_TIMEOUT),
Batch = [Req | drain_requests(1, max_batch_size())],
_ = flush(Batch, S),
true = erlang:garbage_collect(),
@ -137,7 +138,7 @@ drain_requests(N, M) ->
receive
Req = {_Pid, _Ref, #message{}} ->
[Req | drain_requests(N + 1, M)]
after 0 ->
after ?DRAIN_TIMEOUT ->
[N]
end.