diff options
| -rw-r--r-- | Makefile | 18 | ||||
| -rw-r--r-- | docs/rabbitmq.conf.example | 6 | ||||
| -rw-r--r-- | docs/rabbitmqctl.8 | 23 | ||||
| -rw-r--r-- | priv/schema/rabbit.schema | 7 | ||||
| -rw-r--r-- | src/rabbit.erl | 10 | ||||
| -rw-r--r-- | src/rabbit_hipe.erl | 171 | ||||
| -rw-r--r-- | src/rabbit_prelaunch_hipe.erl | 26 |
7 files changed, 1 insertions, 260 deletions
@@ -64,24 +64,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 --git a/docs/rabbitmq.conf.example b/docs/rabbitmq.conf.example index 53611abbcc..fb78a83da9 100644 --- a/docs/rabbitmq.conf.example +++ b/docs/rabbitmq.conf.example @@ -463,12 +463,6 @@ ## NB: Change these only if you understand what you are doing! ## -## Explicitly enable/disable hipe compilation. This option is deprecated -## because HiPE supported has been -## effectively discontinued in Erlang 22. -## -# hipe_compile = false - ## Timeout used when waiting for Mnesia tables in a cluster to ## become available. ## diff --git a/docs/rabbitmqctl.8 b/docs/rabbitmqctl.8 index f524e3e084..0760d2c51d 100644 --- a/docs/rabbitmqctl.8 +++ b/docs/rabbitmqctl.8 @@ -2084,29 +2084,6 @@ to the connected client: .Pp Evaluates an Erlang expression on the target node .\" ------------------------------------------------------------------ -.It Cm hipe_compile Ar directory -.Pp -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 -.El -.\" ------------------------------------------------------------------ .\" ## Queue Operations .\" ------------------------------------------------------------------ .Ss Queue Operations diff --git a/priv/schema/rabbit.schema b/priv/schema/rabbit.schema index b81ba0f1c4..71ba11f372 100644 --- a/priv/schema/rabbit.schema +++ b/priv/schema/rabbit.schema @@ -1067,13 +1067,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 --git a/src/rabbit.erl b/src/rabbit.erl index c0fde5beb6..83f9e4a02a 100644 --- a/src/rabbit.erl +++ b/src/rabbit.erl @@ -353,15 +353,7 @@ run_prelaunch_second_phase() -> %% 3. Logging. ok = rabbit_prelaunch_logging:setup(Context), - case IsInitialPass of - true -> - %% 4. HiPE compilation. - ok = rabbit_prelaunch_hipe:setup(Context); - false -> - ok - end, - - %% 5. Clustering. + %% 4. Clustering. ok = rabbit_prelaunch_cluster:setup(Context), %% Start Mnesia now that everything is ready. diff --git a/src/rabbit_hipe.erl b/src/rabbit_hipe.erl deleted file mode 100644 index eb167fc828..0000000000 --- a/src/rabbit_hipe.erl +++ /dev/null @@ -1,171 +0,0 @@ -%% The contents of this file are subject to the Mozilla Public License -%% Version 1.1 (the "License"); you may not use this file except in -%% compliance with the License. You may obtain a copy of the License -%% at https://www.mozilla.org/MPL/ -%% -%% Software distributed under the License is distributed on an "AS IS" -%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See -%% the License for the specific language governing rights and -%% limitations under the License. -%% -%% The Original Code is RabbitMQ. -%% -%% The Initial Developer of the Original Code is GoPivotal, Inc. -%% Copyright (c) 2007-2020 VMware, Inc. or its affiliates. All rights reserved. -%% - --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}) -> - rabbit_log_prelaunch:info( - "HiPE disabled: no modules were natively recompiled.~n", []); -log_hipe_result({ok, already_compiled}) -> - rabbit_log_prelaunch:info( - "HiPE in use: modules already natively compiled.~n", []); -log_hipe_result({ok, Count, Duration}) -> - rabbit_log_prelaunch: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_prelaunch: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. diff --git a/src/rabbit_prelaunch_hipe.erl b/src/rabbit_prelaunch_hipe.erl deleted file mode 100644 index 9357368c07..0000000000 --- a/src/rabbit_prelaunch_hipe.erl +++ /dev/null @@ -1,26 +0,0 @@ -%% The contents of this file are subject to the Mozilla Public License -%% Version 1.1 (the "License"); you may not use this file except in -%% compliance with the License. You may obtain a copy of the License -%% at https://www.mozilla.org/MPL/ -%% -%% Software distributed under the License is distributed on an "AS IS" -%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See -%% the License for the specific language governing rights and -%% limitations under the License. -%% -%% The Original Code is RabbitMQ. -%% -%% The Initial Developer of the Original Code is GoPivotal, Inc. -%% Copyright (c) 2007-2020 VMware, Inc. or its affiliates. All rights reserved. -%% - --module(rabbit_prelaunch_hipe). - --export([setup/1]). - -setup(_Context) -> - rabbit_log_prelaunch:debug(""), - rabbit_log_prelaunch:debug("== HiPE compitation =="), - HipeResult = rabbit_hipe:maybe_hipe_compile(), - rabbit_hipe:log_hipe_result(HipeResult), - ok. |
