Adapt max-heap-size to Arch-32 systems
The erlang:process_flag(max_heap_size, MaxHeapSize) can only set a MaxHeapSize of `small integer`, which is smaller than 2^59 on 64-bit systems, and 2^27 on 32-bit systems.
This commit is contained in:
parent
b4c659fb54
commit
a1eb7ca7d2
|
@ -556,7 +556,11 @@ zone.external.force_gc_policy = 1000|1MB
|
||||||
## of queued MQTT messages of QoS 1 and 2.
|
## of queued MQTT messages of QoS 1 and 2.
|
||||||
##
|
##
|
||||||
## Numbers delimited by `|'. Zero or negative is to disable.
|
## Numbers delimited by `|'. Zero or negative is to disable.
|
||||||
zone.external.force_shutdown_policy = 10000|1024MB
|
##
|
||||||
|
## Default:
|
||||||
|
## - 8000|800MB on ARCH_64 system
|
||||||
|
## - 1000|100MB on ARCH_32 sytem
|
||||||
|
## zone.external.force_shutdown_policy = 8000|800MB
|
||||||
|
|
||||||
## Maximum MQTT packet size allowed.
|
## Maximum MQTT packet size allowed.
|
||||||
##
|
##
|
||||||
|
|
|
@ -850,7 +850,7 @@ end}.
|
||||||
%% of queued MQTT messages of QoS 1 and 2.
|
%% of queued MQTT messages of QoS 1 and 2.
|
||||||
%% Zero or negative is to disable.
|
%% Zero or negative is to disable.
|
||||||
{mapping, "zone.$name.force_shutdown_policy", "emqx.zones", [
|
{mapping, "zone.$name.force_shutdown_policy", "emqx.zones", [
|
||||||
{default, "0 | 0MB"},
|
{default, "default"},
|
||||||
{datatype, string}
|
{datatype, string}
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
|
@ -899,15 +899,34 @@ end}.
|
||||||
count => list_to_integer(Count)}
|
count => list_to_integer(Count)}
|
||||||
end,
|
end,
|
||||||
{force_gc_policy, GcPolicy};
|
{force_gc_policy, GcPolicy};
|
||||||
|
("force_shutdown_policy", "default") ->
|
||||||
|
{DefaultLen, DefaultSiz} =
|
||||||
|
case erlang:system_info(wordsize) of
|
||||||
|
8 -> % arch_64
|
||||||
|
{8000, cuttlefish_bytesize:parse("800MB")};
|
||||||
|
4 -> % arch_32
|
||||||
|
{1000, cuttlefish_bytesize:parse("100MB")}
|
||||||
|
end,
|
||||||
|
{force_shutdown_policy, #{message_queue_len => DefaultLen,
|
||||||
|
max_heap_size => DefaultSiz}};
|
||||||
("force_shutdown_policy", Val) ->
|
("force_shutdown_policy", Val) ->
|
||||||
[Len, Siz] = string:tokens(Val, "| "),
|
[Len, Siz] = string:tokens(Val, "| "),
|
||||||
ShutdownPolicy = case cuttlefish_bytesize:parse(Siz) of
|
MaxSiz = case erlang:system_info(wordsize) of
|
||||||
{error, Reason} ->
|
8 -> % arch_64
|
||||||
error(Reason);
|
(1 bsl 59) - 1;
|
||||||
Siz1 ->
|
4 -> % arch_32
|
||||||
#{message_queue_len => list_to_integer(Len),
|
(1 bsl 27) - 1
|
||||||
max_heap_size => Siz1}
|
end,
|
||||||
end,
|
ShutdownPolicy =
|
||||||
|
case cuttlefish_bytesize:parse(Siz) of
|
||||||
|
{error, Reason} ->
|
||||||
|
error(Reason);
|
||||||
|
Siz1 when Siz1 > MaxSiz ->
|
||||||
|
cuttlefish:invalid(io_lib:format("force_shutdown_policy: heap-size ~s is too large", [Siz]));
|
||||||
|
Siz1 ->
|
||||||
|
#{message_queue_len => list_to_integer(Len),
|
||||||
|
max_heap_size => Siz1}
|
||||||
|
end,
|
||||||
{force_shutdown_policy, ShutdownPolicy};
|
{force_shutdown_policy, ShutdownPolicy};
|
||||||
("mqueue_priorities", Val) ->
|
("mqueue_priorities", Val) ->
|
||||||
case Val of
|
case Val of
|
||||||
|
|
|
@ -160,6 +160,7 @@ websocket_init(#state{request = Req, options = Options}) ->
|
||||||
EnableStats = emqx_zone:get_env(Zone, enable_stats, true),
|
EnableStats = emqx_zone:get_env(Zone, enable_stats, true),
|
||||||
IdleTimout = emqx_zone:get_env(Zone, idle_timeout, 30000),
|
IdleTimout = emqx_zone:get_env(Zone, idle_timeout, 30000),
|
||||||
emqx_logger:set_metadata_peername(esockd_net:format(Peername)),
|
emqx_logger:set_metadata_peername(esockd_net:format(Peername)),
|
||||||
|
ok = emqx_misc:init_proc_mng_policy(Zone),
|
||||||
{ok, #state{peername = Peername,
|
{ok, #state{peername = Peername,
|
||||||
sockname = Sockname,
|
sockname = Sockname,
|
||||||
parse_state = ParserState,
|
parse_state = ParserState,
|
||||||
|
|
Loading…
Reference in New Issue