Reduce ETS copy overhead when delivering to target queues (backport #14570) #14608
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What?
This commit avoids copying the full amqqueue record from ETS per incoming message
and target queue.
The amqqueue record contains 21 elements and for some queue types,
especially streams, some elements are themselves nested terms.
How?
In Khepri, use a new
rabbit_khepri_queue_targetprojection whichcontains a subset of the full amqqueue record.
This way all relevant information to deliver to a target queue can be
looked up in a single ets:lookup_element call.
Alternative approaches are described in erlang/otp#10211
Benchmark
Fanout to 3 streams
Start broker:
high-credit.configcontains:Create the 3 streams and bindings to the fanout exchange:
Start the client:
mainbranch:with this PR:
Hence, this PR increases the throughput when sending to 3 streams via AMQP by ~14%.
This is an automatic backport of pull request #14570 done by Mergify.