Skip to content

Check whether EPMD is running before starting it #10457

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 1 commit into from
Feb 1, 2024

Conversation

the-mikedavis
Copy link
Collaborator

rabbit_nodes_common:ensure_epmd/0 unconditionally starts EPMD by spawning erl with nodename options. Spawning erl can be quite slow though (around 250ms for me locally), so we should try to avoid it when we detect that EPMD is already running.

We can relatively cheaply check whether EPMD is already running with net_adm:names/0, a function that asks the daemon on localhost to list any registered names, the same as epmd -names on the comand line. If we can successfully get the list of names from the daemon then we don't need to start EPMD. net_adm:names/0 is relatively cheap compared to running erl, costing around 8ms when EPMD is running and less than a millisecond when it is not.

This improves the CLI's total run time for commands that read the enabled_plugins_file and plugins_dir config options. Those options try to consult a running node and so they start distribution and ensure that EPMD is running. rabbitmqctl --help saves nearly 500ms when EPMD is already running as it reads both options, since previously it spawned and blocked on erl when reading each option.

`rabbit_nodes_common:ensure_epmd/0` unconditionally starts EPMD by
spawning `erl` with nodename options. Spawning `erl` can be quite slow
though (around 250ms for me locally), so we should try to avoid it when
we detect that EPMD is already running.

We can relatively cheaply check whether EPMD is already running with
`net_adm:names/0`, a function that asks the daemon on localhost to list
any registered names, the same as `epmd -names` on the comand line. If
we can successfully get the list of names from the daemon then we don't
need to start EPMD. `net_adm:names/0` is relatively cheap compared to
running `erl`, costing around 8ms when EPMD is running and less than a
millisecond when it is not.

This improves the CLI's total run time for commands that read the
`enabled_plugins_file` and `plugins_dir` config options. Those options
try to consult a running node and so they start distribution and ensure
that EPMD is running. `rabbitmqctl --help` saves nearly 500ms when EPMD
is already running as it reads both options, since previously it
spawned and blocked on `erl` when reading each option.
@lukebakken
Copy link
Collaborator

I'm going to test this out on Windows since the CLI is notoriously slow and I bet this is part of it 👍

Copy link
Collaborator

@lukebakken lukebakken left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

20ms faster on Windows! 🚤

@michaelklishin michaelklishin added this to the 3.13.0 milestone Feb 1, 2024
@michaelklishin michaelklishin merged commit 1aa9e13 into main Feb 1, 2024
@michaelklishin michaelklishin deleted the md-check-epmd-before-starting branch February 1, 2024 23:55
michaelklishin added a commit that referenced this pull request Feb 2, 2024
Check whether EPMD is running before starting it (backport #10457)
michaelklishin added a commit that referenced this pull request Feb 2, 2024
Check whether EPMD is running before starting it (backport #10457) (backport #10461)
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.

3 participants