diff options
author | Björn Gustavsson <[email protected]> | 2016-11-05 09:02:23 +0100 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2016-11-05 10:03:25 +0100 |
commit | 4fe94be102150d2b2b31f188a8ef045209e79f8c (patch) | |
tree | 1ec32798e263447b2571380e5062e8fbb7d07fdb /erts | |
parent | 926391fbb8761d5833b3a6f5c9e523fcda373c6d (diff) | |
download | otp-4fe94be102150d2b2b31f188a8ef045209e79f8c.tar.gz otp-4fe94be102150d2b2b31f188a8ef045209e79f8c.tar.bz2 otp-4fe94be102150d2b2b31f188a8ef045209e79f8c.zip |
Fix performance bug in erl_prim_loader:get_modules/{2,3}
The erl_prim_loader:get_modules/{2,3} functions were introduced in
cd283583f8. Unfortunately, while the functions worked correctly, there
was a bug in that many garbage maessages would be sent to the
erl_prim_loader process. The number of extra messages depended on
both the length of the code path and of the number of modules that
were fetched. The messages were ignored and ultimately discarded,
causing no harm except for a performance degradation and increase of
the heap size for the erl_prim_loader process.
The following functions were hit by the performance bug:
code:atomic_load/1
code:ensure_modules_loaded/1
code:prepare_loading/1
Diffstat (limited to 'erts')
-rw-r--r-- | erts/preloaded/src/erl_prim_loader.erl | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/erts/preloaded/src/erl_prim_loader.erl b/erts/preloaded/src/erl_prim_loader.erl index b3ec73a60e..1d09aeded9 100644 --- a/erts/preloaded/src/erl_prim_loader.erl +++ b/erts/preloaded/src/erl_prim_loader.erl @@ -555,17 +555,18 @@ efile_gm_get(Paths, Mod, ParentRef, Process) -> efile_gm_get_1([P|Ps], File0, Mod, {Parent,Ref}=PR, Process) -> File = join(P, File0), - Res = try prim_file:read_file(File) of - {ok,Bin} -> - gm_process(Mod, File, Bin, Process); - Error -> - _ = check_file_result(get_modules, File, Error), - efile_gm_get_1(Ps, File0, Mod, PR, Process) - catch - _:Reason -> - {error,{crash,Reason}} - end, - Parent ! {Ref,Mod,Res}; + try prim_file:read_file(File) of + {ok,Bin} -> + Res = gm_process(Mod, File, Bin, Process), + Parent ! {Ref,Mod,Res}; + Error -> + _ = check_file_result(get_modules, File, Error), + efile_gm_get_1(Ps, File0, Mod, PR, Process) + catch + _:Reason -> + Res = {error,{crash,Reason}}, + Parent ! {Ref,Mod,Res} + end; efile_gm_get_1([], _, Mod, {Parent,Ref}, _Process) -> Parent ! {Ref,Mod,{error,enoent}}. |