Skip to content

Commit ad5707f

Browse files
authored
rabbit_boot_steps: Search boot steps only in RabbitMQ-related apps (#10064)
[Why] We used to search for boot steps (i.e. `rabbit_boot_step` module attributes) in every modules in every Erlang loaded applications. This included the Erlang/OTP standard libraries and all depedencies. This takes a looot of time. That's a lot of applications where we will never find a boot step anyway. So most of this time is wasted. [How] `rabbit_misc:rabbitmq_related_module_attributes/1` was introduced for the Feature flags subsystem for the same need to search for specific module attributes. This function only considers the RabbitMQ core and all plugins. This saves a significant amount of time. And because all those modules were already loaded when RabbitMQ search for feature flags earlier during boot, the boot steps lookup should be quite fast. We could consider this a change of behavior because applications which didn't depend on the `rabbit` application are now excluded from the search. But all plugins should depend on `rabbit`, so excluded applications are already broken.
1 parent e7273f6 commit ad5707f

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

deps/rabbit/src/rabbit_boot_steps.erl

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77

88
-module(rabbit_boot_steps).
99

10+
-include_lib("kernel/include/logger.hrl").
11+
-include_lib("rabbit_common/include/logging.hrl").
12+
1013
-export([run_boot_steps/0, run_boot_steps/1, run_cleanup_steps/1]).
1114
-export([find_steps/0, find_steps/1]).
1215

@@ -31,7 +34,14 @@ find_steps() ->
3134
find_steps(loaded_applications()).
3235

3336
find_steps(Apps) ->
34-
All = sort_boot_steps(rabbit_misc:all_module_attributes(rabbit_boot_step)),
37+
T0 = erlang:timestamp(),
38+
AttrsPerApp = rabbit_misc:rabbitmq_related_module_attributes(rabbit_boot_step),
39+
T1 = erlang:timestamp(),
40+
?LOG_DEBUG(
41+
"Boot steps: time to find boot steps: ~tp us",
42+
[timer:now_diff(T1, T0)],
43+
#{domain => ?RMQLOG_DOMAIN_GLOBAL}),
44+
All = sort_boot_steps(AttrsPerApp),
3545
[Step || {App, _, _} = Step <- All, lists:member(App, Apps)].
3646

3747
run_step(Attributes, AttributeName) ->

0 commit comments

Comments
 (0)