summaryrefslogtreecommitdiff
path: root/src/rebar3.erl
diff options
context:
space:
mode:
authorFred Hebert <mononcqc@ferd.ca>2018-10-11 08:38:37 -0400
committerFred Hebert <mononcqc@ferd.ca>2018-10-11 08:45:04 -0400
commitdada4e36e6d9a5c4b41bbe1f68389520e7c59ace (patch)
tree27f3d5451fad7a6c2157965af811a65898704054 /src/rebar3.erl
parentaf5cecd8eec9692f43d04ad53c8f28734012b873 (diff)
Optimize path handling
- Only set paths that need to be put as a priority - Clean up paths before leaving API mode The first point accounted for some performance cost, but the latter one explains the 40% overhead in test runs: since rebar3 calls rebar3 a lot with a bunch of fake apps, and that the new mechanism for path handling by default does not _remove_ paths, it just _orders_ them, we would end up in a situation where as the tests ran, more and more fake paths would get added to the VM. By the time the run was over, all path handling would take longer since more paths needed filtering every time. By resetting paths at the end of an API run, we prevent a given 'project' from polluting another one's runtime and performance once the API successfully returns.
Diffstat (limited to 'src/rebar3.erl')
-rw-r--r--src/rebar3.erl15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/rebar3.erl b/src/rebar3.erl
index c931a85..059d530 100644
--- a/src/rebar3.erl
+++ b/src/rebar3.erl
@@ -175,7 +175,20 @@ run_aux(State, RawArgs) ->
State10 = rebar_state:code_paths(State9, default, code:get_path()),
- rebar_core:init_command(rebar_state:command_args(State10, Args), Task).
+ case rebar_core:init_command(rebar_state:command_args(State10, Args), Task) of
+ {ok, State11} ->
+ case rebar_state:get(State11, caller, command_line) of
+ api ->
+ rebar_paths:unset_paths([deps, plugins], State11),
+ {ok, State11};
+ _ ->
+ {ok, State11}
+ end;
+ Other ->
+ Other
+ end.
+
+
%% @doc set up base configuration having to do with verbosity, where
%% to find config files, and so on, and return an internal rebar3 state term.