Some performance tests indicate that calling `telemetry` is costly in
hot paths. Since increasing a counter by 0 is a no-op, we should
avoid calling `telemetry` if the amount to increase is 0.
(Almost?) fixes https://emqx.atlassian.net/browse/EMQX-9637
During the course of performance tests comparing the performance of
e5.0.3 and e4.4.16 regarding the webhook bridge in sync mode, we
observed that the throughput in e5.0.3 (sync) was much lower than in
e4.4.16: ~ 9 k msgs / s vs. ~ 50 k msgs / s, respectively.
Analyzing `observer_cli` output, we noticed that a lot of the time
both buffer workers and ehttpc processes was spent in `ets:info/2`.
That function was called to check the size of the inflight table when
updating metrics and checking if the inflight table was full. Other
uses of `ets:info/2` were contained inside the arguments to some
`?tp/2` macro usages (https://github.com/kafka4beam/snabbkaffe/pull/60).
By using a specific record to track the size of the table, we managed
to improve the bridge performance to ~ 45 k msgs / s in sync mode.
Fixes https://emqx.atlassian.net/browse/EMQX-9656
See also https://github.com/emqx/ehttpc/pull/45
This fixes a race condition where the remote server would close the
connection before or during requests, and, depending on timing, an
`{error, normal}` response would be returned. In those cases, we
should just retry the request without using up "retry credits".
Fixes https://emqx.atlassian.net/browse/EMQX-9635
During a sync call from process `A` to a buffer worker `B`, its call
to the underlying resource `C` can be very slow. In those cases, `A`
will receive a timeout response and expect no more messages from `B`
nor `C`. However, prior to this fix, if `B` is stuck in a long sync
call to `C` and then gets its response after `A` timed out, `B` would
still send the late response to `A`, polluting its mailbox.
ekka 0.15.1 uses mria 0.5.2, which includes the following changes:
- fix(mria_membership): call `mria_rlog:role/1` safely
- feat: add extra field to ?rlog_sync table (for future use)
ekka 0.15.0 uses mria 0.5.0, which adds several fixes, enhancements and features:
- protect `mria:join/1,2` with a global lock
- implement new function `mria:sync_transaction/4,3,2`, which waits for
a transaction replication to be ready on the local node
(if the local node is a replicant)
- optimize `mria:running_nodes/0`
- optimize `mria:ro_transaction/2` when called on a replicant node.
Fixes: EMQX-9588 (#10380), EMQX-9102, EMQX-9152, EMQX-9213