Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ libquicer_nif.so
rebar3
*.crashdump
_checkouts/
.envrc
erlang_ls.config
18 changes: 14 additions & 4 deletions src/emqtt_bench.erl
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
, loop/5
]).

%% Internal callback
-export([wakeup_main_loop/2, main_loop/2]).

-define(STARTNUMBER_DESC,
"The start point when assigning sequence numbers to clients. "
"This is useful when running multiple emqtt-bench "
Expand Down Expand Up @@ -502,12 +505,20 @@ main_loop(Uptime, Count) ->
maybe_print_qoe(Count),
maybe_dump_nst_dets(Count),
garbage_collect(),
main_loop(Uptime, Count);
hibernate_main_loop(Uptime, Count);
Msg ->
print("main_loop_msg: ~p~n", [Msg]),
main_loop(Uptime, Count)
hibernate_main_loop(Uptime, Count)
after 5 ->
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here.

hibernate_main_loop(Uptime, Count)
end.

hibernate_main_loop(Uptime, Count) ->
proc_lib:hibernate(?MODULE, wakeup_main_loop, [Uptime, Count]).

wakeup_main_loop(Uptime, Count) ->
?MODULE:main_loop(Uptime, Count).

maybe_dump_nst_dets(Count)->
Count == ets:info(quic_clients_nsts, size)
andalso undefined =/= dets:info(dets_quic_nsts)
Expand Down Expand Up @@ -743,7 +754,6 @@ maybe_retry(Parent, N, PubSub, Opts, ContinueFn) ->
loop(Parent, N, Client, PubSub, Opts) ->
Interval = proplists:get_value(interval_of_msg, Opts, 0),
Prometheus = lists:member(prometheus, Opts),
Idle = max(Interval * 2, 500),
MRef = proplists:get_value(publish_signal_mref, Opts),
receive
{'DOWN', MRef, process, _Pid, start_publishing} ->
Expand Down Expand Up @@ -818,7 +828,7 @@ loop(Parent, N, Client, PubSub, Opts) ->
io:format("client(~w): discarded unknown message ~p~n", [N, Other]),
loop(Parent, N, Client, PubSub, Opts)
after
Idle ->
_Idle = max(Interval * 2, 50) ->
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the 'perf improvements' is mostly by changing it from 500ms to 50ms and it is case by case, we see reduced CPU usage and lowered memeory usage but latency become higher I guess.

Could you make this configurable instead rather than hardcode it?

case proplists:get_bool(lowmem, Opts) of
true ->
erlang:garbage_collect(Client, [{type, major}]),
Expand Down
Loading