[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: How could you load only once a Linux ultility without a batch --input-files kind of option and repeatedly use it on many files? . . .



On Fri 15 May 2020 at 18:58:04 (-0400), Greg Wooledge wrote:
> On Fri, May 15, 2020 at 03:34:53PM -0700, David Christensen wrote:
> > Another consideration is concurrency.  If you have a multi-core processor
> > and implement a solution that puts two or more cores to work at the same
> > time, a concurrent program should finish sooner than a sequential program.
> > Again, benchmarking.
> 
> One of the main reasons why people still suggest learning the xargs -0
> variant is because GNU xargs has a lovely little -P option that runs
> tasks in parallel.
> 
> It's super easy to go from
> 
> find ... -print0 | xargs -0 sha256sum
> 
> to something like
> 
> find ... -print0 | xargs -0 -P 4 sha256sum
> 
> This is one of the main advantages of the xargs -0 approach over the
> find -exec + approach.  If you don't need any of GNU xargs's fancy
> features, you can just stick with the standard -exec +.

It seems to be even more flexible than having to write different
-P values on the command line. By sending the process (however started)
signals SIGUSR1/2, the number of processes can be varied on the fly,
allowing you to interactively judge the effect on throughput. This
also avoids having to kill one find command just to change -P and
start another.

Cheers,
David.


Reply to: