Skip to content

Make AMQP 1.0 faster #14238

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jul 16, 2025
Merged

Make AMQP 1.0 faster #14238

merged 7 commits into from
Jul 16, 2025

Conversation

ansd
Copy link
Member

@ansd ansd commented Jul 15, 2025

This PR results in noteworthy performance improvements for AMQP 1.0 (depending on the workload).

Stream filtering via AMQP SQL Filters or AMQP Property Filters where the
broker reads messages from the stream into memory and the filter returns
false, i.e. messages are not sent to the client:

  • Before this PR: ~400,000 msgs/s
  • After this PR: ~500,000 msgs/s

There is also a ~10% increase in end-to-end throughput for normal
AMQP workloads, e.g. when sending to and receiving from a classic queue.

Prior to this PR, a lot of garbage was created leading to many minor
garbage collections.

This PR reduces the garbage being generated.
The new module amqp10_composite performs very well:

  • Single tuple update setting multiple fields at once, sometimes done even in-place
    without copying the tuple.
  • The list of fields is passed into X registers, no need for any new
    allocations.

On the serialisation side, this PR also generates less garbage by:

  1. Avoiding tuple_to_list/1
  2. Omitting trailing elements of the list that are null

This will also lead to fewer bytes per message sent on the wire and less
resource usage for the clients as they need to parse fewer fields.

ansd added 3 commits July 15, 2025 15:55
This commit results in great performance improvements for AMQP 1.0.

Stream filtering via AMQP SQL Filters or AMQP Property Filters where the
broker reads messages from the stream into memory and the filter returns
false, i.e. messages are not sent to the client:
Before this commit: ~400,000 msgs/s
After this commit:  ~500,000 msgs/s

There is also a ~10% increase in end-to-end throughput for normal
AMQP workloads, e.g. when sending to and receiving from a classic queue.

Prior to this commit, a lot of garbage was created leading to many minor
garbage collections.

This commit reduces the garbage being generated.
The new module amqp10_composite performs very well:
* Single tuple update setting multiple fields at once, sometimes done even in-place
  without copying the tuple.
* The list of fields is passed into X registers, no need for any new
  allocations.

On the serialisation side, this commit also generates less garbage by:
1. Avoiding tuple_to_list/1
2. Omitting trailing elements of the list that are null

This will also lead to fewer bytes per message sent on the wire and less
resource usage for the clients as they need to parse fewer fields.
@ansd ansd added this to the 4.2.0 milestone Jul 15, 2025
@ansd ansd self-assigned this Jul 15, 2025
ansd added 4 commits July 16, 2025 09:39
This commit fixes the failing test cases
```
make -C deps/rabbit ct-msg_size_metrics t=tests:message_size
make -C deps/amqp10_client ct-system t=rabbitmq:roundtrip_large_messages
```

The second test case failed with:
```
flush {amqp10_event,
          {connection,<0.193.0>,
              {closed,
                  {framing_error,
                      <<"frame size (131073 bytes) > maximum frame size (131072 bytes)">>}}}}
```
This commit fixes the following test case:
```
make -C deps/rabbit ct-amqp_dotnet t=cluster_size_1:fragmentation
```

Previously, the server sent a frame that was 1 byte too large.
@ansd ansd marked this pull request as ready for review July 16, 2025 11:12
@ansd ansd merged commit da2255d into main Jul 16, 2025
558 of 561 checks passed
@ansd ansd deleted the optimise-amqp-parser branch July 16, 2025 13:27
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.

1 participant