Check whether EPMD is running before starting it #10457
Merged
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.
rabbit_nodes_common:ensure_epmd/0
unconditionally starts EPMD by spawningerl
with nodename options. Spawningerl
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 asepmd -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 runningerl
, 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
andplugins_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 onerl
when reading each option.