Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: increase GC frequency when in low memory mode #155

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
3 changes: 2 additions & 1 deletion src/emqtt.erl
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,8 @@ start_link(Options) when is_list(Options) ->
false -> [];
true ->
[{spawn_opt, [{min_heap_size, 16},
{min_bin_vheap_size,16}
{min_bin_vheap_size,16},
{fullsweep_after, 1_000}
]},
{hibernate_after, 50}
]
Expand Down
11 changes: 9 additions & 2 deletions test/emqtt_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ groups() ->
t_stop,
t_pause_resume,
t_init,
t_connected]},
t_connected,
t_low_mem_opts]},
{mqttv3,[non_parallel_tests],
[basic_test_v3]},
{mqttv4, [non_parallel_tests],
Expand Down Expand Up @@ -446,6 +447,12 @@ t_connected(Config) ->
Clientid = gen_statem:call(C, clientid),
[ ?assertMatch(Clientid, Value) || {Key, Value} <- emqtt:info(C), Key =:= clientid].

t_low_mem_opts(Config) ->
Port = ?config(port, Config),
{ok, C} = emqtt:start_link([{port, Port}, {low_mem, true}]),
%% TODO: check min_heap_size, min_bin_vheap_size
Copy link
Contributor Author

Choose a reason for hiding this comment

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

For some reason, those values are not set to 16. Maybe it overrides to an internal minimum value.

Failure/Error: ?assertEqual([], process_info ( C , [ min_heap_size , min_bin_vheap_size , fullsweep_after ] ))
  expected: []
       got: [{min_heap_size,233},
             {min_bin_vheap_size,46422},
             {fullsweep_after,1000}]
      line: 455

?assertEqual([{fullsweep_after, 1_000}], process_info(C, [fullsweep_after])).

t_inflight_full(_) ->
error('TODO').

Expand Down Expand Up @@ -520,7 +527,7 @@ retry_interval_test(Config) ->

timer:sleep(timer:seconds(2)),
?assertEqual(2, counters:get(CRef, 1)),

meck:unload(emqtt_sock),
meck:unload(emqtt_quic),
ok = emqtt:disconnect(Pub).
Expand Down