Skip to content

perf: use erpc multicall in ekka_locker#271

Merged
terry-xiaoyu merged 2 commits into
main-emqx-4.3from
use-erpc-multicall
May 18, 2026
Merged

perf: use erpc multicall in ekka_locker#271
terry-xiaoyu merged 2 commits into
main-emqx-4.3from
use-erpc-multicall

Conversation

@terry-xiaoyu

@terry-xiaoyu terry-xiaoyu commented May 16, 2026

Copy link
Copy Markdown
Member

rpc:multicall/5 has a performance issue when called by many processes in parallel.

rpc-blocked-on-mc_spawn_replies

To reproduce the problem:

Setup a 2-node emqx 4.4.35 cluster, on each node spawn a lot of processes (50K in my example) that call rpc:multicall/5 in a loop:

(fun() ->
    N = 50_000,
    Nodes = ekka_mnesia:running_nodes(),
    _ = [
    spawn_link(fun() ->
      (fun Loop(I) ->
          rpc:multicall(Nodes, erlang, system_time, [], 30000),
          receive
             q -> ok;
             Msg when I =< 0 ->
                io:format("----received ~p~n", [Msg]),
                ok;
             Msg ->
                io:format("----received ~p~n", [Msg]),
                Loop(I - 1)
          after
             1000 ->
                if I =< 0 -> ok;
                   true -> Loop(I - 1)
                end
          end
        end)(30)
    end) || _ <- lists:seq(1, N)]
end)().

I don't know if this problem also exists on newer OTP versions than OTP 24.3.4.17-2.

@zmstone

zmstone commented May 16, 2026

Copy link
Copy Markdown
Member

maybe add description

@terry-xiaoyu terry-xiaoyu merged commit 7d66d88 into main-emqx-4.3 May 18, 2026
4 of 7 checks passed
@terry-xiaoyu terry-xiaoyu deleted the use-erpc-multicall branch May 18, 2026 02:18
@terry-xiaoyu terry-xiaoyu self-assigned this May 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants