summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon MacMullen <simon@rabbitmq.com>2011-10-24 18:21:56 +0100
committerSimon MacMullen <simon@rabbitmq.com>2011-10-24 18:21:56 +0100
commit62a12405525bd1e27734db0f0759ac4ca82b3287 (patch)
tree2e47ab4e49a4ac82f837b543a6fd02040c0db947
parentc5b13a91e29f03630a5fd8016f1d42ea46a11865 (diff)
downloadrabbitmq-server-62a12405525bd1e27734db0f0759ac4ca82b3287.tar.gz
Go faster stripes.
-rw-r--r--ebin/rabbit_app.in3
-rw-r--r--src/rabbit.erl37
-rw-r--r--src/rabbit_prelaunch.erl3
3 files changed, 39 insertions, 4 deletions
diff --git a/ebin/rabbit_app.in b/ebin/rabbit_app.in
index 65a3269a..5ead1051 100644
--- a/ebin/rabbit_app.in
+++ b/ebin/rabbit_app.in
@@ -14,7 +14,8 @@
%% we also depend on crypto, public_key and ssl but they shouldn't be
%% in here as we don't actually want to start it
{mod, {rabbit, []}},
- {env, [{tcp_listeners, [5672]},
+ {env, [{hipe_compile, false},
+ {tcp_listeners, [5672]},
{ssl_listeners, []},
{ssl_options, []},
{vm_memory_high_watermark, 0.4},
diff --git a/src/rabbit.erl b/src/rabbit.erl
index 530955c2..8b2a2ef8 100644
--- a/src/rabbit.erl
+++ b/src/rabbit.erl
@@ -18,8 +18,8 @@
-behaviour(application).
--export([prepare/0, start/0, stop/0, stop_and_halt/0, status/0,
- is_running/0 , is_running/1, environment/0,
+-export([maybe_hipe_compile/0, prepare/0, start/0, stop/0, stop_and_halt/0,
+ status/0, is_running/0, is_running/1, environment/0,
rotate_logs/1, force_event_refresh/0]).
-export([start/2, stop/1]).
@@ -177,6 +177,20 @@
-define(APPS, [os_mon, mnesia, rabbit]).
+-define(HIPE_WORTHY,
+ [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, 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]).
+
%%----------------------------------------------------------------------------
-ifdef(use_specs).
@@ -185,6 +199,7 @@
%% this really should be an abstract type
-type(log_location() :: 'tty' | 'undefined' | file:filename()).
+-spec(maybe_hipe_compile/0 :: () -> 'ok').
-spec(prepare/0 :: () -> 'ok').
-spec(start/0 :: () -> 'ok').
-spec(stop/0 :: () -> 'ok').
@@ -218,6 +233,24 @@
%%----------------------------------------------------------------------------
+maybe_hipe_compile() ->
+ {ok, Compile} = application:get_env(rabbit, hipe_compile),
+ case Compile of
+ true -> Count = length(?HIPE_WORTHY),
+ io:format("HiPE compiling: |~s|~n ",
+ [string:copies("-", Count - 2)]),
+ T1 = erlang:now(),
+ [hipe_compile(M) || M <- ?HIPE_WORTHY],
+ T2 = erlang:now(),
+ io:format("~n~nCompiled ~B modules in ~Bs~n",
+ [Count, trunc(timer:now_diff(T2, T1) / 1000000)]);
+ false -> ok
+ end.
+
+hipe_compile(M) ->
+ io:format("#"),
+ {ok, M} = hipe:c(M, [o3]).
+
prepare() ->
ok = ensure_working_log_handlers(),
ok = rabbit_upgrade:maybe_upgrade_mnesia().
diff --git a/src/rabbit_prelaunch.erl b/src/rabbit_prelaunch.erl
index d34ed44a..8beff019 100644
--- a/src/rabbit_prelaunch.erl
+++ b/src/rabbit_prelaunch.erl
@@ -233,7 +233,8 @@ post_process_script(ScriptFile) ->
end.
process_entry(Entry = {apply,{application,start_boot,[mnesia,permanent]}}) ->
- [{apply,{rabbit,prepare,[]}}, Entry];
+ [{apply,{rabbit,maybe_hipe_compile,[]}},
+ {apply,{rabbit,prepare,[]}}, Entry];
process_entry(Entry) ->
[Entry].