[erlang-questions] Feedback wanted: Remove compilation times from BEAM files in OTP 19?

Martin Bjorklund mbj@REDACTED
Fri Apr 8 14:43:10 CEST 2016


Serge Aleynikov <serge@REDACTED> wrote:
> I've been relying on module's compilation time for figuring out the changed
> modules (see below).

I also use this function all the time
(I.e, in user_default: lm() -> [c:l(M) || M <- modified_modules()].
 super convenient!)

Anyway, if there's an alternative way to do the same thing that would
be fine.

> In the absence of {time, CompileTime}, would there be a way to determine
> the modification time stamp of the file at the time it was loaded by code
> loader?


/martin


> 
> Serge
> 
> modified_modules() ->
>     [M || {M, _} <-  code:all_loaded(), module_modified(M) == true].
> 
> module_modified(Module) ->
>     case code:is_loaded(Module) of
>     {file, preloaded} ->
>         false;
>     {file, Path} ->
>         CompileOpts = proplists:get_value(compile, Module:module_info()),
>         CompileTime = proplists:get_value(time, CompileOpts),
>         Src = proplists:get_value(source, CompileOpts),
>         module_modified(Path, CompileTime, Src);
>     _ ->
>         false
>     end.
> 
> module_modified(Path, PrevCompileTime, PrevSrc) ->
>     case find_module_file(Path) of
>     false ->
>         false;
>     ModPath ->
>         {ok, {_, [{_, CB}]}} = beam_lib:chunks(ModPath, ["CInf"]),
>         CompileOpts =  binary_to_term(CB),
>         CompileTime = proplists:get_value(time, CompileOpts),
>         Src = proplists:get_value(source, CompileOpts),
>         not (CompileTime == PrevCompileTime) and (Src == PrevSrc)
>     end.
> 
> 
> On Fri, Apr 8, 2016 at 6:32 AM, Björn Gustavsson <bjorn@REDACTED> wrote:
> 
> > As long as anyone can remember, the compilation time has been included
> > in BEAM files (and can be retrieved using module_info()).
> >
> > As far as I know, the inclusion of the time has only caused problems.
> > I can't remember that anyone has found any use for the compilation
> > time.
> >
> > So if we decide to remove the compilation time by default in OTP 19...
> >
> > ... would it cause any problem for someone in some workflow?
> >
> > ... would we need an option to include the compilation time?
> >
> > /Bjorn
> >
> > --
> > Björn Gustavsson, Erlang/OTP, Ericsson AB
> > _______________________________________________
> > erlang-questions mailing list
> > erlang-questions@REDACTED
> > http://erlang.org/mailman/listinfo/erlang-questions
> >



More information about the erlang-questions mailing list