summaryrefslogtreecommitdiff
path: root/src/rebar_prv_compile.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/rebar_prv_compile.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/rebar_prv_compile.erl')
-rw-r--r--src/rebar_prv_compile.erl12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/rebar_prv_compile.erl b/src/rebar_prv_compile.erl
index 4b36636..ee96d9f 100644
--- a/src/rebar_prv_compile.erl
+++ b/src/rebar_prv_compile.erl
@@ -37,7 +37,7 @@ init(State) ->
-spec do(rebar_state:t()) -> {ok, rebar_state:t()} | {error, string()}.
do(State) ->
IsDepsOnly = is_deps_only(State),
- rebar_paths:set_paths([deps, plugins], State),
+ rebar_paths:set_paths([deps], State),
Providers = rebar_state:providers(State),
Deps = rebar_state:deps_to_build(State),
@@ -50,7 +50,7 @@ do(State) ->
handle_project_apps(Providers, State)
end,
- rebar_paths:set_paths([plugins, deps], State1),
+ rebar_paths:set_paths([plugins], State1),
{ok, State1}.
@@ -172,10 +172,10 @@ compile(State, Providers, AppInfo) ->
%% The rebar_otp_app compilation step is safe regarding the
%% overall path management, so we can just load all plugins back
%% in memory.
- rebar_paths:set_paths([plugins, deps], State),
+ rebar_paths:set_paths([plugins], State),
AppFileCompileResult = rebar_otp_app:compile(State, AppInfo4),
- %% Clean up after ourselves, leave things as they were.
- rebar_paths:set_paths([deps, plugins], State),
+ %% Clean up after ourselves, leave things as they were with deps first
+ rebar_paths:set_paths([deps], State),
case AppFileCompileResult of
{ok, AppInfo5} ->
@@ -203,7 +203,7 @@ build_app(AppInfo, State) ->
%% load plugins since thats where project builders would be
rebar_paths:set_paths([plugins, deps], State),
Res = Module:build(AppInfo),
- rebar_paths:set_paths([deps, plugins], State),
+ rebar_paths:set_paths([deps], State),
case Res of
ok -> ok;
{error, Reason} -> throw({error, {Module, Reason}})