diff options
author | Björn Gustavsson <[email protected]> | 2015-12-16 14:50:56 +0100 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2015-12-16 15:52:26 +0100 |
commit | af9bfce55f0df03edaab638dcd3612c8478dfcc9 (patch) | |
tree | 9433741c63c6324b86faf7d9417f1a413d3d6aaf /erts/preloaded/src/init.erl | |
parent | 471d2408de06f3c93507769ce0eb0a9f42c3d119 (diff) | |
download | otp-af9bfce55f0df03edaab638dcd3612c8478dfcc9.tar.gz otp-af9bfce55f0df03edaab638dcd3612c8478dfcc9.tar.bz2 otp-af9bfce55f0df03edaab638dcd3612c8478dfcc9.zip |
Remove erl_prim_loader:get_files/2
erl_prim_loader:get_files/2 was an optimization introduced before the
SMP emulator (that is, before R11). The idea was to use the async
threads in the efile driver to read multiple BEAM files from the disk
in parallel.
In a modern computer with the SMP emulator, loading a BEAM module
seems to be more time-consuming than reading it from disk. To optimize
loading we would need to load several modules in parallel. We could
modify get_files/2 so that it would support parallel loading, but it
is cleaner to first remove get_files/2 and then (in a future commit),
introduce new functions to support parallel loading.
Diffstat (limited to 'erts/preloaded/src/init.erl')
-rw-r--r-- | erts/preloaded/src/init.erl | 51 |
1 files changed, 5 insertions, 46 deletions
diff --git a/erts/preloaded/src/init.erl b/erts/preloaded/src/init.erl index cc30999ba5..b5c1d46e60 100644 --- a/erts/preloaded/src/init.erl +++ b/erts/preloaded/src/init.erl @@ -85,7 +85,6 @@ path_choice, prim_load, load_mode, - par_load, vars }). @@ -749,13 +748,11 @@ do_boot(Init,Flags,Start) -> Deb = b2a(get_flag(init_debug, Flags, false)), catch ?ON_LOAD_HANDLER ! {init_debug_flag,Deb}, BootVars = get_boot_vars(Root, Flags), - ParLoad = Pgm =:= "efile" andalso - erlang:system_info(thread_pool_size) > 0, PathChoice = code_path_choice(), Es = #es{init=Init,debug=Deb,path=Path,pa=Pa,pz=Pz, path_choice=PathChoice, - prim_load=true,load_mode=LoadMode,par_load=ParLoad, + prim_load=true,load_mode=LoadMode, vars=BootVars}, eval_script(BootList, Es), @@ -857,15 +854,12 @@ eval_script([{kernel_load_completed}|T], #es{load_mode=Mode}=Es0) -> _ -> Es0#es{prim_load=false} end, eval_script(T, Es); -eval_script([{primLoad,Mods}|T], #es{init=Init,prim_load=PrimLoad, - par_load=Par}=Es) +eval_script([{primLoad,Mods}|T], #es{prim_load=PrimLoad}=Es) when is_list(Mods) -> - case {PrimLoad,Par} of - {true,true} -> - par_load_modules(Mods, Init); - {true,false} -> + case PrimLoad of + true -> load_modules(Mods); - {false,_} -> + false -> %% Do not load now, code_server does that dynamically! ok end, @@ -892,41 +886,6 @@ load_modules([Mod|Mods]) -> load_modules([]) -> ok. -%%% An optimization: erl_prim_loader gets the chance of loading many -%%% files in parallel, using threads. This will reduce the seek times, -%%% and loaded code can be processed while other threads are waiting -%%% for the disk. The optimization is not tried unless the loader is -%%% "efile" and there is a non-empty pool of threads. -%%% -%%% Many threads are needed to get a good result, so it would be -%%% beneficial to load several applications in parallel. However, -%%% measurements show that the file system handles one directory at a -%%% time, regardless if parallel threads are created for files on -%%% several directories (a guess: writing the meta information when -%%% the file was last read ('mtime'), forces the file system to sync -%%% between directories). - -par_load_modules(Mods,Init) -> - Ext = objfile_extension(), - ModFiles = [{Mod,concat([Mod,Ext])} || Mod <- Mods, - not erlang:module_loaded(Mod)], - Self = self(), - Fun = fun(Mod, BinCode, FullName) -> - case catch load_mod_code(Mod, BinCode, FullName) of - {ok, _} -> - Init ! {Self,loaded,{Mod,FullName}}, - ok; - _EXIT -> - {error, Mod} - end - end, - case erl_prim_loader:get_files(ModFiles, Fun) of - ok -> - ok; - {error,Mod} -> - exit({'cannot load',Mod,get_files}) - end. - make_path(Pa, Pz, Path, Vars) -> append([Pa,append([fix_path(Path,Vars),Pz])]). |