Conversation
This seems to shave about 30% off the time for a riak build. I've reviewed the code and tested it and I'm +1 on this change. |
30% off the time for a build when everythng is already built, I should clarity. |
set_path does verification of the paths and read file data. e.g. here: https://github.com/erlang/otp/blob/maint/lib/kernel/src/code_server.erl#L777 so makes sense that manual cleanup via del_path is faster. |
@@ -603,3 +604,17 @@ filter_defines([{platform_define, ArchRegex, Key, Value} | Rest], Acc) -> | |||
end; | |||
filter_defines([Opt | Rest], Acc) -> | |||
filter_defines(Rest, [Opt | Acc]). | |||
|
|||
cleanup_path(OrigPath) -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about renaming the fun to cleanup_code_path/1
, as this module is a collection of many unrelated funs?
Thanks @evanmcc. We don't (yet) have a test suite for code path changes, but the updated CONTRIBUTING guide requires tests for behavioral changes. So, we should try to write tests before we merge this. |
Minor commit message issue: following CONTRIBUTING#commit-titlesummary, there should be no period in the title/summary. |
I've addressed all of the concerns but adding the test. If someone sees an easy way to test this, I'm all ears. Otherwise I'll try to figure it out on Monday. |
Thanks. |
cleanup_code_path(OrigPath) -> | ||
CurrentPath = code:get_path(), | ||
AddedPaths = CurrentPath -- OrigPath, | ||
%% if someone has removed paths, it's hard to get them back into |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor typo: if someone -> If someone
Looking at the operations in This sounds safe enough to me for a decent performance gain. |
Sorry, I noticed that we never re-add paths. In the off-chance some paths were deleted somewhere in the code we |
Can I get some clarification on what needs to happen to get this mergeable? A test and ?? |
I'm guessing tests and fixing the typo @Tuncer has seen in a comment. The rest seemed good to me, unless someone has something else to point out. |
What would a test even look like, I don't even know why rebar resets paths like this, is it in case a task changes the paths somehow? Presumably via some plugin? |
My plan was just to manually add and remove some paths and then test that they get properly reset. I have no idea how to test it as it would actually be used in rebar. |
I would probably be fine testing the path changes done with |
Typo fixed, tests added, LC return explicitly ignored. |
The eunit tests are calling teardown without setting the path and teardown() calls set_cwd(".."), which is silly but hard to fix right now. Here's a patch to make the tests green: code_path_test_() ->
[{"Ensuring that fast code path cleanup is correct for adds",
- setup, fun make_tmp_dir/0, fun teardown/1,
+ setup, fun make_tmp_dir/0,
+ fun(_) -> remove_tmp_dir() end,
fun() ->
OPath = code:get_path(),
PathZ = ?TMP_DIR ++ "some_path", |
Using code:set_path/1 with very large paths is very slow on larger projects. On my mid-sized project, it seems to take around .4s per call. Emulating the call with direct path removal (using code:del_path/1) seems to be quite a lot faster.
Merging this. |
Using code:set_path/1 with very large paths is very slow on larger
projects. On my mid-sized project, it seems to take around .4s per
call. Emulating the call with direct path removal (using
code:del_path/1) seems to be quite a lot faster.