mirror of
https://github.com/fluxerapp/fluxer.git
synced 2026-09-02 21:04:06 +03:00
perf(gateway): drop per-recipient mailbox probe on dispatch (#2146)
This commit is contained in:
@@ -64,20 +64,13 @@ dispatch_direct(SessionPid, Event, Payload) when is_pid(SessionPid) ->
|
||||
Msg = {dispatch, Event, Payload},
|
||||
case node(SessionPid) of
|
||||
LocalNode when LocalNode =:= node() ->
|
||||
safe_cast_local(SessionPid, Msg);
|
||||
gen_server:cast(SessionPid, Msg);
|
||||
RemoteNode ->
|
||||
remote_dispatch_cast(RemoteNode, SessionPid, Msg)
|
||||
end;
|
||||
dispatch_direct(_SessionPid, _Event, _Payload) ->
|
||||
ok.
|
||||
|
||||
-spec safe_cast_local(pid(), term()) -> ok.
|
||||
safe_cast_local(SessionPid, Msg) ->
|
||||
case shard_utils:safe_cast(SessionPid, Msg) of
|
||||
ok -> ok;
|
||||
{error, overloaded} -> ok
|
||||
end.
|
||||
|
||||
-spec remote_dispatch_cast(node(), pid(), term()) -> ok.
|
||||
remote_dispatch_cast(RemoteNode, SessionPid, Msg) ->
|
||||
try erpc:cast(RemoteNode, gen_server, cast, [SessionPid, Msg]) of
|
||||
@@ -249,6 +242,16 @@ dispatch_direct_local_cast_test() ->
|
||||
?assert(false)
|
||||
end.
|
||||
|
||||
dispatch_direct_local_cast_under_mailbox_pressure_test() ->
|
||||
Self = self(),
|
||||
Receiver = spawn(fun() -> test_dispatch_receiver(Self, pressured) end),
|
||||
lists:foreach(fun(N) -> Receiver ! {filler, N} end, lists:seq(1, 6000)),
|
||||
{message_queue_len, QueueLen} = erlang:process_info(Receiver, message_queue_len),
|
||||
?assert(QueueLen > 5000),
|
||||
Payload = #{<<"pressure">> => true},
|
||||
?assertEqual(ok, dispatch_direct(Receiver, guild_update, Payload)),
|
||||
assert_dispatch_received(pressured, guild_update, Payload).
|
||||
|
||||
group_by_node_empty_test() ->
|
||||
?assertEqual([], group_by_node([])).
|
||||
|
||||
|
||||
Reference in New Issue
Block a user