Giter Club home page Giter Club logo

Comments (3)

ferd avatar ferd commented on May 31, 2024

Hm, that number should already be limited, at least in the actual compilation.
The limit is set at

queue(Tasks, WorkF, WArgs, Handler, HArgs) ->
Parent = self(),
Worker = fun() -> worker(Parent, WorkF, WArgs) end,
Jobs = min(length(Tasks), erlang:system_info(schedulers)),
?DIAGNOSTIC("Starting ~B worker(s)", [Jobs]),
Pids = [spawn_monitor(Worker) || _ <- lists:seq(1, Jobs)],
parallel_dispatch(Tasks, Pids, Handler, HArgs).

The queue of worker is set up at:

compile_parallel(Targets, Opts, BaseOpts, Mappings, CompilerMod) ->
Tracking = erlang:function_exported(CompilerMod, compile_and_track, 4),
rebar_parallel:queue(
Targets,
fun compile_worker/2, [Opts, BaseOpts, Mappings, CompilerMod],
fun compile_handler/2, [BaseOpts, Tracking]
).

This should give you no more compile units than there are schedulers on your VM for normal Erlang code builds.

However the issue you show comes from the code server in the analysis step... It is possible that the issue comes from the OTP-provided epp module that we use to access the code's abstract files:

deps(File, Opts) ->
{EppOpts, ExtraOpts} = split_opts(Opts),
{ok, Forms} = epp:parse_file(File, EppOpts),
normalize(handle_forms(Forms, default_attrs(), ExtraOpts)).

What I've found is that we had a patch in the DAG analysis to speed it up that does call for more concurrency, unbounded one at that:

%% Add dependencies of a given file to the DAG. If the file is not found yet,
%% mark its timestamp to 0, which means we have no info on it.
%% Source files will be covered at a later point in their own scan, and
%% non-source files are going to be covered by `populate_deps/3'.
prepopulate_deps(Compiler, InDirs, Source, DepOpts, Control) ->
{Worker, _MRef} = spawn_monitor(
fun () ->
SourceDir = filename:dirname(Source),
AbsIncls = case erlang:function_exported(Compiler, dependencies, 4) of
false ->
Compiler:dependencies(Source, SourceDir, InDirs);
true ->
Compiler:dependencies(Source, SourceDir, InDirs, DepOpts)
end,
Control ! {deps, self(), AbsIncls}
end
),
Worker.

That was added in a performance drive in 2020: #2322

Chances are that the only needed fix is to transform the DAG analysis to use a worker queue to be faster. I can try experimenting with that, it should be workable.

from rebar3.

ferd avatar ferd commented on May 31, 2024

See #2768 for a potential fix to this. It seems fragile, but may allow checking the early approach.

from rebar3.

shionryuu avatar shionryuu commented on May 31, 2024

My project can build successfully after checkout #2768. Thank you.

from rebar3.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.