File rabbitmq-server-3.7.17-hipe.patch of Package rabbitmq-server
diff -Ndurp rabbitmq-server-3.7.17/docs/rabbitmq.conf.example rabbitmq-server-3.7.17-hipe/docs/rabbitmq.conf.example
--- rabbitmq-server-3.7.17/docs/rabbitmq.conf.example 2019-07-08 03:21:22.000000000 +0300
+++ rabbitmq-server-3.7.17-hipe/docs/rabbitmq.conf.example 2024-04-27 17:32:14.562516201 +0300
@@ -444,10 +444,6 @@
## NB: Change these only if you understand what you are doing!
##
-## Explicitly enable/disable hipe compilation.
-##
-# hipe_compile = false
-
## Timeout used when waiting for Mnesia tables in a cluster to
## become available.
##
diff -Ndurp rabbitmq-server-3.7.17/docs/rabbitmq.config.example rabbitmq-server-3.7.17-hipe/docs/rabbitmq.config.example
--- rabbitmq-server-3.7.17/docs/rabbitmq.config.example 2019-07-08 03:21:22.000000000 +0300
+++ rabbitmq-server-3.7.17-hipe/docs/rabbitmq.config.example 2024-04-27 17:32:14.562516201 +0300
@@ -390,10 +390,6 @@
%%
%% {trace_vhosts, []},
- %% Explicitly enable/disable HiPE compilation.
- %%
- %% {hipe_compile, false},
-
%% Number of delegate processes to use for intra-cluster communication.
%% On a node which is part of cluster, has more than 16 cores and plenty of network bandwidth,
%% it may make sense to increase this value.
diff -Ndurp rabbitmq-server-3.7.17/docs/rabbitmqctl.8 rabbitmq-server-3.7.17-hipe/docs/rabbitmqctl.8
--- rabbitmq-server-3.7.17/docs/rabbitmqctl.8 2019-07-08 03:21:22.000000000 +0300
+++ rabbitmq-server-3.7.17-hipe/docs/rabbitmqctl.8 2024-04-27 17:32:14.562516201 +0300
@@ -143,27 +143,6 @@ For example, to reset the RabbitMQ node:
.sp
.Dl rabbitmqctl force_reset
.\" ------------------------------------
-.It Cm hipe_compile Ar directory
-Performs HiPE-compilation and caches resulting
-.Pa .beam Ns -files in the given directory.
-.Pp
-Parent directories are created if necessary.
-Any existing
-.Pa .beam
-files from the directory are automatically deleted prior to compilation.
-.Pp
-To use this precompiled files, you should set
-.Ev RABBITMQ_SERVER_CODE_PATH
-environment variable to directory specified in
-.Cm hipe_compile
-invocation.
-.Pp
-For example, to HiPE-compile modules and store them to
-.Pa /tmp/rabbit-hipe/ebin
-directory:
-.sp
-.Dl rabbitmqctl hipe_compile /tmp/rabbit-hipe/ebin
-.\" ------------------------------------
.It Cm reset
Returns a RabbitMQ node to its virgin state.
.Pp
diff -Ndurp rabbitmq-server-3.7.17/Makefile rabbitmq-server-3.7.17-hipe/Makefile
--- rabbitmq-server-3.7.17/Makefile 2019-07-08 03:21:22.000000000 +0300
+++ rabbitmq-server-3.7.17-hipe/Makefile 2024-04-27 17:32:14.562516201 +0300
@@ -62,24 +62,6 @@ define PROJECT_ENV
{exit_on_close, false}
]},
{halt_on_upgrade_failure, true},
- {hipe_compile, false},
- %% see bug 24513 [in legacy Bugzilla] for how this list was created
- {hipe_modules,
- [rabbit_reader, rabbit_channel, gen_server2, rabbit_exchange,
- rabbit_command_assembler, rabbit_framing_amqp_0_9_1, rabbit_basic,
- rabbit_event, lists, queue, priority_queue, rabbit_router,
- rabbit_trace, rabbit_misc, rabbit_binary_parser,
- rabbit_exchange_type_direct, rabbit_guid, rabbit_net,
- rabbit_amqqueue_process, rabbit_variable_queue,
- rabbit_binary_generator, rabbit_writer, delegate, gb_sets, lqueue,
- sets, orddict, rabbit_amqqueue, rabbit_limiter, gb_trees,
- rabbit_queue_index, rabbit_exchange_decorator, gen, dict, ordsets,
- file_handle_cache, rabbit_msg_store, array,
- rabbit_msg_store_ets_index, rabbit_msg_file,
- rabbit_exchange_type_fanout, rabbit_exchange_type_topic, mnesia,
- mnesia_lib, rpc, mnesia_tm, qlc, sofs, proplists, credit_flow,
- pmon, ssl_connection, tls_connection, ssl_record, tls_record,
- gen_fsm, ssl]},
{ssl_apps, [asn1, crypto, public_key, ssl]},
%% see rabbitmq-server#114
{mirroring_flow_control, true},
diff -Ndurp rabbitmq-server-3.7.17/priv/schema/rabbit.schema rabbitmq-server-3.7.17-hipe/priv/schema/rabbit.schema
--- rabbitmq-server-3.7.17/priv/schema/rabbit.schema 2019-07-08 03:21:22.000000000 +0300
+++ rabbitmq-server-3.7.17-hipe/priv/schema/rabbit.schema 2024-04-27 17:32:14.562516201 +0300
@@ -1001,13 +1001,6 @@ end}.
%% NB: Change these only if you understand what you are doing!
%%
-%% Explicitly enable/disable hipe compilation.
-%%
-%% {hipe_compile, true},
-
-{mapping, "hipe_compile", "rabbit.hipe_compile",
- [{datatype, {enum, [true, false]}}]}.
-
%% Timeout used when waiting for Mnesia tables in a cluster to
%% become available.
%%
diff -Ndurp rabbitmq-server-3.7.17/src/rabbit.erl rabbitmq-server-3.7.17-hipe/src/rabbit.erl
--- rabbitmq-server-3.7.17/src/rabbit.erl 2019-07-08 03:21:22.000000000 +0300
+++ rabbitmq-server-3.7.17-hipe/src/rabbit.erl 2024-04-27 17:33:16.737185497 +0300
@@ -304,7 +304,7 @@
%%----------------------------------------------------------------------------
ensure_application_loaded() ->
- %% We end up looking at the rabbit app's env for HiPE and log
+ %% We end up looking at the rabbit app's env for log
%% handling, so it needs to be loaded. But during the tests, it
%% may end up getting loaded twice, so guard against that.
case application:load(rabbit) of
@@ -317,9 +317,7 @@ start() ->
%% We do not want to upgrade mnesia after just
%% restarting the app.
ok = ensure_application_loaded(),
- HipeResult = rabbit_hipe:maybe_hipe_compile(),
ok = start_logger(),
- rabbit_hipe:log_hipe_result(HipeResult),
Apps = load_all_apps(),
rabbit_feature_flags:initialize_registry(),
rabbit_node_monitor:prepare_cluster_status_files(),
@@ -331,9 +329,7 @@ boot() ->
start_it(fun() ->
ensure_config(),
ok = ensure_application_loaded(),
- HipeResult = rabbit_hipe:maybe_hipe_compile(),
ok = start_logger(),
- rabbit_hipe:log_hipe_result(HipeResult),
Apps = load_all_apps(),
rabbit_feature_flags:initialize_registry(),
rabbit_node_monitor:prepare_cluster_status_files(),
diff -Ndurp rabbitmq-server-3.7.17/src/rabbit_hipe.erl rabbitmq-server-3.7.17-hipe/src/rabbit_hipe.erl
--- rabbitmq-server-3.7.17/src/rabbit_hipe.erl 2019-07-08 03:21:22.000000000 +0300
+++ rabbitmq-server-3.7.17-hipe/src/rabbit_hipe.erl 1970-01-01 03:00:00.000000000 +0300
@@ -1,154 +0,0 @@
--module(rabbit_hipe).
-
-%% HiPE compilation uses multiple cores anyway, but some bits are
-%% IO-bound so we can go faster if we parallelise a bit more. In
-%% practice 2 processes seems just as fast as any other number > 1,
-%% and keeps the progress bar realistic-ish.
--define(HIPE_PROCESSES, 2).
-
--export([maybe_hipe_compile/0, log_hipe_result/1]).
--export([compile_to_directory/1]).
--export([can_hipe_compile/0]).
-
-%% Compile and load during server startup sequence
-maybe_hipe_compile() ->
- {ok, Want} = application:get_env(rabbit, hipe_compile),
- case {Want, can_hipe_compile()} of
- {true, true} -> hipe_compile();
- {true, false} -> false;
- {false, _} -> {ok, disabled}
- end.
-
-log_hipe_result({ok, disabled}) ->
- ok;
-log_hipe_result({ok, already_compiled}) ->
- rabbit_log:info(
- "HiPE in use: modules already natively compiled.~n", []);
-log_hipe_result({ok, Count, Duration}) ->
- rabbit_log:info(
- "HiPE in use: compiled ~B modules in ~Bs.~n", [Count, Duration]);
-log_hipe_result(false) ->
- io:format(
- "~nNot HiPE compiling: HiPE not found in this Erlang installation.~n"),
- rabbit_log:warning(
- "Not HiPE compiling: HiPE not found in this Erlang installation.~n").
-
-hipe_compile() ->
- hipe_compile(fun compile_and_load/1, false).
-
-compile_to_directory(Dir0) ->
- Dir = rabbit_file:filename_as_a_directory(rabbit_data_coercion:to_list(Dir0)),
- case prepare_ebin_directory(Dir) of
- ok ->
- hipe_compile(fun (Mod) -> compile_and_save(Mod, Dir) end, true);
- {error, Err} ->
- {error, Err}
- end.
-
-needs_compilation(Mod, Force) ->
- Exists = code:which(Mod) =/= non_existing,
- %% We skip modules already natively compiled. This
- %% happens when RabbitMQ is stopped (just the
- %% application, not the entire node) and started
- %% again.
- NotYetCompiled = not already_hipe_compiled(Mod),
- NotVersioned = not compiled_with_version_support(Mod),
- Exists andalso (Force orelse (NotYetCompiled andalso NotVersioned)).
-
-%% HiPE compilation happens before we have log handlers and can take a
-%% long time, so make an exception to our no-stdout policy and display
-%% progress via stdout.
-hipe_compile(CompileFun, Force) ->
- {ok, HipeModulesAll} = application:get_env(rabbit, hipe_modules),
- HipeModules = lists:filter(fun(Mod) -> needs_compilation(Mod, Force) end, HipeModulesAll),
- case HipeModules of
- [] -> {ok, already_compiled};
- _ -> do_hipe_compile(HipeModules, CompileFun)
- end.
-
-already_hipe_compiled(Mod) ->
- try
- %% OTP 18.x or later
- Mod:module_info(native) =:= true
- %% OTP prior to 18.x
- catch error:badarg ->
- code:is_module_native(Mod) =:= true
- end.
-
-compiled_with_version_support(Mod) ->
- proplists:get_value(erlang_version_support, Mod:module_info(attributes))
- =/= undefined.
-
-do_hipe_compile(HipeModules, CompileFun) ->
- Count = length(HipeModules),
- io:format("~nHiPE compiling: |~s|~n |",
- [string:copies("-", Count)]),
- T1 = erlang:monotonic_time(),
- %% We use code:get_object_code/1 below to get the beam binary,
- %% instead of letting hipe get it itself, because hipe:c/{1,2}
- %% expects the given filename to actually exist on disk: it does not
- %% work with an EZ archive (rabbit_common is one).
- %%
- %% Then we use the mode advanced hipe:compile/4 API because the
- %% simpler hipe:c/3 is not exported (as of Erlang 18.1.4). This
- %% advanced API does not load automatically the code, except if the
- %% 'load' option is set.
- PidMRefs = [spawn_monitor(fun () -> [begin
- CompileFun(M),
- io:format("#")
- end || M <- Ms]
- end) ||
- Ms <- split(HipeModules, ?HIPE_PROCESSES)],
- [receive
- {'DOWN', MRef, process, _, normal} -> ok;
- {'DOWN', MRef, process, _, Reason} -> exit(Reason)
- end || {_Pid, MRef} <- PidMRefs],
- T2 = erlang:monotonic_time(),
- Duration = erlang:convert_time_unit(T2 - T1, native, seconds),
- io:format("|~n~nCompiled ~B modules in ~Bs~n", [Count, Duration]),
- {ok, Count, Duration}.
-
-split(L, N) -> split0(L, [[] || _ <- lists:seq(1, N)]).
-
-split0([], Ls) -> Ls;
-split0([I | Is], [L | Ls]) -> split0(Is, Ls ++ [[I | L]]).
-
-prepare_ebin_directory(Dir) ->
- case rabbit_file:ensure_dir(Dir) of
- ok ->
- ok = delete_beam_files(Dir),
- ok;
- {error, eperm} ->
- {error, eperm}
- end.
-
-delete_beam_files(Dir) ->
- {ok, Files} = file:list_dir(Dir),
- lists:foreach(fun(File) ->
- case filename:extension(File) of
- ".beam" ->
- ok = file:delete(filename:join([Dir, File]));
- _ ->
- ok
- end
- end,
- Files).
-
-compile_and_load(Mod) ->
- {Mod, Beam, _} = code:get_object_code(Mod),
- {ok, _} = hipe:compile(Mod, [], Beam, [o3, load]).
-
-compile_and_save(Module, Dir) ->
- {Module, BeamCode, _} = code:get_object_code(Module),
- BeamName = filename:join([Dir, atom_to_list(Module) ++ ".beam"]),
- {ok, {Architecture, NativeCode}} = hipe:compile(Module, [], BeamCode, [o3]),
- {ok, _, Chunks0} = beam_lib:all_chunks(BeamCode),
- ChunkName = hipe_unified_loader:chunk_name(Architecture),
- Chunks1 = lists:keydelete(ChunkName, 1, Chunks0),
- Chunks = Chunks1 ++ [{ChunkName,NativeCode}],
- {ok, BeamPlusNative} = beam_lib:build_module(Chunks),
- ok = file:write_file(BeamName, BeamPlusNative),
- BeamName.
-
-can_hipe_compile() ->
- code:which(hipe) =/= non_existing.