-
Notifications
You must be signed in to change notification settings - Fork 521
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
limit the number of parallel build process #2767
Comments
Hm, that number should already be limited, at least in the actual compilation. rebar3/apps/rebar/src/rebar_parallel.erl Lines 13 to 19 in 69a5898
The queue of worker is set up at: rebar3/apps/rebar/src/rebar_compiler.erl Lines 316 to 322 in 69a5898
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 rebar3/apps/rebar/src/rebar_compiler_epp.erl Lines 35 to 38 in 69a5898
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: rebar3/apps/rebar/src/rebar_compiler_dag.erl Lines 449 to 466 in 69a5898
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. |
This addresses erlang#2767 by creating a pool mechanism in rebar_parallel that keeps as similar of an interface as possible as the queue mechanism, with the one caveat that it allows the asynchronous creation of tasks rather than requiring them all at start time. The mechanism is not tested super deeply, which is probably a mistake, but I wanted to get a reviewable PR first. The mechanism is also added to the rebar_compiler_dag module to cover use cases that were handled by spawning an unbounded number of processes before, which would cause problem with low file descriptors being allocated and lots of files being used and open in parallel. The pool mechanism puts an upper bound on processing but also on resource usage. So this PR may also come with a performance regression, and if so we'd want to override the default 1-per-scheduler pool options to use a lot more and hit a middleground in performance vs. resource usage.
See #2768 for a potential fix to this. It seems fragile, but may allow checking the early approach. |
This addresses erlang#2767 by creating a pool mechanism in rebar_parallel that keeps as similar of an interface as possible as the queue mechanism, with the one caveat that it allows the asynchronous creation of tasks rather than requiring them all at start time. The mechanism is not tested super deeply, which is probably a mistake, but I wanted to get a reviewable PR first. The mechanism is also added to the rebar_compiler_dag module to cover use cases that were handled by spawning an unbounded number of processes before, which would cause problem with low file descriptors being allocated and lots of files being used and open in parallel. The pool mechanism puts an upper bound on processing but also on resource usage. So this PR may also come with a performance regression, and if so we'd want to override the default 1-per-scheduler pool options to use a lot more and hit a middleground in performance vs. resource usage.
My project can build successfully after checkout #2768. Thank you. |
This addresses erlang#2767 by creating a pool mechanism in rebar_parallel that keeps as similar of an interface as possible as the queue mechanism, with the one caveat that it allows the asynchronous creation of tasks rather than requiring them all at start time. The mechanism is not tested super deeply, which is probably a mistake, but I wanted to get a reviewable PR first. The mechanism is also added to the rebar_compiler_dag module to cover use cases that were handled by spawning an unbounded number of processes before, which would cause problem with low file descriptors being allocated and lots of files being used and open in parallel. The pool mechanism puts an upper bound on processing but also on resource usage. So this PR may also come with a performance regression, and if so we'd want to override the default 1-per-scheduler pool options to use a lot more and hit a middleground in performance vs. resource usage.
Environment
Current behaviour
rebar compile open too many process, occupy too mary resources (cpu, memory) and will kill by system
Expected behaviour
limit the number of parallel build process
The text was updated successfully, but these errors were encountered: