Add rebar_parallel pool, use in DAG scans #2768
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This addresses #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.