perf(webhook): evaluate replies in fresh process rather than in ehttpc

This surprisingly simple change yields a big performance improvement
in throughput.

While the previous commit achieves ~ 55 k messages / s
in throughput under some test conditions (100 k concurrent publishers
publishing 1 QoS 1 message per second), the simple change in this
commit improves it further to ~ 63 k messages / s.

Benchmarks indicated that the evaluating one reply function is
consistently quite fast (~ 20 µs), which makes this performance gain
counterintuitive.  Perhaps, although each call is cheap, `ehttpc`
calls several of these in a row when there are several sent requests,
and those costs might add up in latency.
This commit is contained in:
Thales Macedo Garitezi 2023-05-12 13:52:11 -03:00
parent a7b41e1cdf
commit bc7d0d5fd6
1 changed files with 1 additions and 1 deletions

View File

@ -645,7 +645,7 @@ to_bin(Atom) when is_atom(Atom) ->
atom_to_binary(Atom, utf8). atom_to_binary(Atom, utf8).
reply_delegator(Context, ReplyFunAndArgs, Result) -> reply_delegator(Context, ReplyFunAndArgs, Result) ->
maybe_retry(Result, Context, ReplyFunAndArgs). spawn(fun() -> maybe_retry(Result, Context, ReplyFunAndArgs) end).
transform_result(Result) -> transform_result(Result) ->
case Result of case Result of