Start the penalty after queues are 25% full because a) that makes sense, and b)
that avoids some odd badarith errors when PctBusy is very small.
This commit is contained in:
parent
2ddf0da53e
commit
48419ce4d0
1 changed files with 9 additions and 7 deletions
|
@ -22,13 +22,15 @@
|
||||||
%% -------------------------------------------------------------------
|
%% -------------------------------------------------------------------
|
||||||
|
|
||||||
-define(ASYNC_NIF_CALL(Fun, Args),
|
-define(ASYNC_NIF_CALL(Fun, Args),
|
||||||
F = fun(F, A) ->
|
F = fun(F) ->
|
||||||
R = erlang:make_ref(),
|
R = erlang:make_ref(),
|
||||||
case erlang:apply(F, [R|A]) of
|
case erlang:apply(Fun, [R|Args]) of
|
||||||
{ok, {enqueued, PctBusy}} ->
|
{ok, {enqueued, PctBusy}} ->
|
||||||
case PctBusy of
|
if
|
||||||
0.0 -> ok;
|
PctBusy > 0.25 andalso PctBusy =< 1.0 ->
|
||||||
_ -> erlang:bump_reductions(erlang:trunc(2000 * PctBusy))
|
erlang:bump_reductions(erlang:trunc(2000 * PctBusy));
|
||||||
|
true ->
|
||||||
|
ok
|
||||||
end,
|
end,
|
||||||
receive
|
receive
|
||||||
{R, {error, shutdown}=Error} ->
|
{R, {error, shutdown}=Error} ->
|
||||||
|
@ -41,9 +43,9 @@
|
||||||
Reply
|
Reply
|
||||||
end;
|
end;
|
||||||
{error, eagain} ->
|
{error, eagain} ->
|
||||||
F(F, A);
|
F(F);
|
||||||
Other ->
|
Other ->
|
||||||
Other
|
Other
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
F(Fun, Args)).
|
F(F)).
|
||||||
|
|
Loading…
Reference in a new issue