diff options
| author | Simon MacMullen <simon@rabbitmq.com> | 2011-10-26 13:40:51 +0100 |
|---|---|---|
| committer | Simon MacMullen <simon@rabbitmq.com> | 2011-10-26 13:40:51 +0100 |
| commit | fb39b75030bfbeacda12f3ce19f7e9ab44d47422 (patch) | |
| tree | e3699aab8dacff933d387bed56ac56504931f86e /src/rabbit.erl | |
| parent | 2c809f93f1d70f14d7778e7ff661d40b158c08c5 (diff) | |
| download | rabbitmq-server-git-fb39b75030bfbeacda12f3ce19f7e9ab44d47422.tar.gz | |
Use multiple processes for compilation. 2 seems to be as fast as any > 1, but this does go about 25% faster for me.
Diffstat (limited to 'src/rabbit.erl')
| -rw-r--r-- | src/rabbit.erl | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/src/rabbit.erl b/src/rabbit.erl index b0f6d92009..16af316145 100644 --- a/src/rabbit.erl +++ b/src/rabbit.erl @@ -191,6 +191,12 @@ rabbit_exchange_type_fanout, rabbit_exchange_type_topic, mnesia, mnesia_lib, rpc, mnesia_tm, qlc, sofs, proplists]). +%% 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). + %%---------------------------------------------------------------------------- -ifdef(use_specs). @@ -248,14 +254,35 @@ hipe_compile() -> io:format("HiPE compiling: |~s|~n |", [string:copies("-", Count)]), T1 = erlang:now(), - [hipe_compile(M) || M <- ?HIPE_WORTHY], + S = self(), + [spawn(fun () -> hipe_compile(S, Ms) end) + || Ms <- split(?HIPE_WORTHY, ?HIPE_PROCESSES)], + wait(?HIPE_PROCESSES), T2 = erlang:now(), T = timer:now_diff(T2, T1) div 1000000, io:format("|~n~nCompiled ~B modules in ~Bs~n", [Count, T]). +wait(0) -> ok; +wait(C) -> receive + ok -> wait(C - 1); + {error, E} -> exit(E) + end. + +split(L, N) -> split0(L, [[] || _ <- lists:seq(1, N)]). + +split0([], Ls) -> Ls; +split0([I | Is], [L | Ls]) -> split0(Is, Ls ++ [[I | L]]). + +hipe_compile(S, Ms) -> + S ! try [hipe_compile(M) || M <- Ms], + ok + catch _:E -> + {error, E} + end. + hipe_compile(M) -> - io:format("#"), - {ok, M} = hipe:c(M, [o3]). + {ok, M} = hipe:c(M, [o3]), + io:format("#"). prepare() -> ok = ensure_working_log_handlers(), |
