Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #15269

Re: How does this wait -n work to cap parallelism?

From Earnestly <zibeon@googlemail.com>
Newsgroups gnu.bash.bug
Subject Re: How does this wait -n work to cap parallelism?
Date 2019-07-29 21:27 +0100
Message-ID <mailman.194.1564432067.1985.bug-bash@gnu.org> (permalink)
References <20190729181242.GB2032@teapot> <20190729202741.GD2032@teapot>

Show all headers | View raw


On Mon, Jul 29, 2019 at 07:12:42PM +0100, Earnestly wrote:
> The question is about how the example works in order to maintain
> parallelism capped at num_proc.

Thanks to emg on #bash for explaining how what is essentially going on.
Bash essentially maintains a list of completed jobs until wait -n
is called and removes one of those completed jobs.  Bash then adds another
job according to the loop I used.

After the "slow" phase of my synthetic code it just so happens that
these jobs are removed and new ones are added rapidly.

And so the jobs are added and then removed accordingly but is never
allowed to exceed "nproc" because wait -n is always called thereafter.

> Below I've provided a synthetic scenario which hopefully highlights my
> (and others) confusion.

It was because of this that I trapped my mind.  Because I was watching
top I concluded that once a job had ended, bash itself would also do
likewise and discard it.  I wasn't able to consider that bash might
maintain a list of *completed* jobs for which subsequent 'wait' calls
would remove.

Sorry for the noise.

Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread


Thread

Re: How does this wait -n work to cap parallelism? Earnestly <zibeon@googlemail.com> - 2019-07-29 21:27 +0100

csiph-web