diff options
author | Tuncer Ayaz <tuncer.ayaz@gmail.com> | 2015-06-11 20:10:27 +0200 |
---|---|---|
committer | Tuncer Ayaz <tuncer.ayaz@gmail.com> | 2015-06-12 12:52:24 +0200 |
commit | ec018cf5a5f102eb96c0972a0175f74f2016f77c (patch) | |
tree | ff895644d297b15f67ed59db4ba04e55a03b7b32 | |
parent | 02c43007b4500018b4bc028d4ddff6f11001b4a8 (diff) | |
download | rebar-ec018cf5a5f102eb96c0972a0175f74f2016f77c.tar.gz |
Start using memoization server
1. memoize otp release vsn string function call
2. memoize expensive filename:absname/1 call which happens
to be called quite frequently
-rw-r--r-- | src/rebar.erl | 6 | ||||
-rw-r--r-- | src/rebar_utils.erl | 25 |
2 files changed, 12 insertions, 19 deletions
diff --git a/src/rebar.erl b/src/rebar.erl index b2358c7..dcfb353 100644 --- a/src/rebar.erl +++ b/src/rebar.erl @@ -214,6 +214,12 @@ run_aux(BaseConfig, Commands) -> {error,{already_started,crypto}} -> ok end, + %% Make sure memoization server is running + case rmemo:start() of + {ok, _} -> ok; + {error, {already_started, _}} -> ok + end, + %% Convert command strings to atoms CommandAtoms = [list_to_atom(C) || C <- Commands], diff --git a/src/rebar_utils.erl b/src/rebar_utils.erl index f1aeef0..b250671 100644 --- a/src/rebar_utils.erl +++ b/src/rebar_utils.erl @@ -237,9 +237,11 @@ prop_check(false, Msg, Args) -> ?ABORT(Msg, Args). %% Convert all the entries in the code path to absolute paths. expand_code_path() -> - CodePath = lists:foldl(fun(Path, Acc) -> - [filename:absname(Path) | Acc] - end, [], code:get_path()), + CodePath = lists:foldl( + fun(Path, Acc) -> + Path1 = rmemo:call(filename, absname, [Path]), + [Path1 | Acc] + end, [], code:get_path()), code:set_path(lists:reverse(CodePath)). %% @@ -403,22 +405,7 @@ patch_env(Config, [E | Rest]) -> %% ==================================================================== otp_release() -> - %% NOTE: All and any pdict use has been erased from rebar a long - %% time ago in a big refactoring, and while extra processes (think - %% base_compiler) may have to re-cache the vsn string, this is - %% tolerable as an exception. After all, it's a write-once value. - %% - %% We cache the return of otp_release1, since otherwise, we're - %% repeatedly reading the same file off the hard drive and - %% generating warnings if they aren't there. - case erlang:get(otp_release_cache) of - undefined -> - Vsn = otp_release1(erlang:system_info(otp_release)), - erlang:put(otp_release_cache, Vsn), - Vsn; - Vsn -> - Vsn - end. + rmemo:call(fun otp_release1/1, [(erlang:system_info(otp_release))]). %% If OTP <= R16, otp_release is already what we want. otp_release1([$R,N|_]=Rel) when is_integer(N) -> |