Skip to content

Improve performance of federation #3085

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

Conversation

luos
Copy link
Contributor

@luos luos commented Jun 4, 2021

When a federated message is processed, certain headers are added,
cluster_name is called for every message.
This every single time creates an UDP port and queries into the
inet_drv to get the hostname.
Now we first try to look it up in the database instead of
calculating a default which will not be needed.

Some benchmarks on my local machine:

Old version:
lists:sum([begin {R, _ } = timer:tc(rabbit_nodes, cluster_name, []), R end || _ <- lists:seq(0,1000)])/1000.
2052.328 microseconds (2 milliseconds) average

Tested this not on my local and it still takes around 0.2 ms, which seems lower but it's very often I can see the exchange link federation process in `inet gethostname`. 

New version:

lists:sum([begin {R, _ } = timer:tc(rabbit_nodes, cluster_name, []), R end || _ <- lists:seq(0,1000)])/1000.
1.296 microseconds

Proposed Changes

Defer the calculation of a default value when we know it's needed.

Types of Changes

  • Performance improvement

Checklist

Put an x in the boxes that apply. You can also fill these out after creating
the PR. If you're unsure about any of them, don't hesitate to ask on the
mailing list. We're here to help! This is simply a reminder of what we are
going to look for before merging your code.

  • I have read the CONTRIBUTING.md document
  • I have signed the CA (see https://cla.pivotal.io/sign/rabbitmq)
  • All tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)
  • Any dependent changes have been merged and published in related repositories

When a federated message is processed, certain headers are added,
cluster_name is called for every message.
This every single time creates an UDP port and queries into the
inet_drv to get the hostname.
Now we first try to look it up in the database instead of
calculating a default which will not be needed.
@michaelklishin michaelklishin added this to the 3.8.17 milestone Jun 4, 2021
@michaelklishin michaelklishin merged commit 1645542 into rabbitmq:master Jun 4, 2021
michaelklishin added a commit that referenced this pull request Jun 4, 2021
Improve performance of federation

(cherry picked from commit 1645542)
@michaelklishin
Copy link
Collaborator

Backported to v3.8.x.

the-mikedavis added a commit that referenced this pull request Jul 3, 2024
`rabbit_runtime_parameters:value_global/2` was only used in
`rabbit_nodes:cluster_name/0` since near the beginning of the commit
history of the server and its usage was eliminated in 06932b9
(#3085, released in v3.8.17+ and v3.9.0+).

`rabbit_runtime_parameters:value/4` doesn't appear to have been ever
used since it was introduced near the beginning of the commit history.
It may have been added just to mirror `value_global/2`'s interface.

Eliminating these dead functions allows us to also eliminate a somewhat
complicated function `rabbit_db_rtparams:get_or_set/2`.
mergify bot pushed a commit that referenced this pull request Jul 3, 2024
`rabbit_runtime_parameters:value_global/2` was only used in
`rabbit_nodes:cluster_name/0` since near the beginning of the commit
history of the server and its usage was eliminated in 06932b9
(#3085, released in v3.8.17+ and v3.9.0+).

`rabbit_runtime_parameters:value/4` doesn't appear to have been ever
used since it was introduced near the beginning of the commit history.
It may have been added just to mirror `value_global/2`'s interface.

Eliminating these dead functions allows us to also eliminate a somewhat
complicated function `rabbit_db_rtparams:get_or_set/2`.

(cherry picked from commit 427876b)
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.

2 participants