Bug 199976 - [patch] implement xargs -P0
Summary: [patch] implement xargs -P0
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Some People
Assignee: Allan Jude
URL:
Keywords: patch
Depends on: 202152
Blocks:
  Show dependency treegraph
 
Reported: 2015-05-05 20:18 UTC by Nikolai Lifanov
Modified: 2016-01-12 05:51 UTC (History)
1 user (show)

See Also:


Attachments
xargs: implement -P0 (894 bytes, patch)
2015-05-05 20:18 UTC, Nikolai Lifanov
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Nikolai Lifanov 2015-05-05 20:18:26 UTC
Created attachment 156407 [details]
xargs: implement -P0

This simple patch implements GNU-like xargs -P0 to run "as many processes as possible". This option is convenient and allows many of my scripts to port.

There are a couple of differences from GNU behavior to make this consistent with other options in our xargs: -P takes negative numbers, which mean the same as -P0, and the maximum number of procs is equal to maxargs rather than some *_MAX macro. This is probably what the user wants, performs a lot better, and doesn't hurt intended -P0 portability.

Tested with: kyua test -k /usr/tests/Kyuafile usr.bin/xargs (passed)
Comment 1 Nikolai Lifanov 2015-05-05 20:37:11 UTC
If accepted, please MFC this option to 10-STABLE.
It would be awesome to see this in 10.2-RELEASE.
Comment 2 Nikolai Lifanov 2015-05-09 15:06:42 UTC
I'm not sure what kind of workflow is easier, so there is also a pull request #31 on github with this patch.
Comment 3 commit-hook freebsd_committer freebsd_triage 2015-08-04 14:27:31 UTC
A commit references this bug:

Author: allanjude
Date: Tue Aug  4 14:27:26 UTC 2015
New revision: 286289
URL: https://svnweb.freebsd.org/changeset/base/286289

Log:
  xargs now takes -P0, creating as many concurrent processes as possible

  PR:		199976
  Submitted by:	Nikolai Lifanov <lifanov@mail.lifanov.com>
  Reviewed by:	mjg, bjk
  Approved by:	bapt (mentor)
  MFC after:	1 month
  Relnotes:	yes
  Sponsored by:	ScaleEngine Inc.
  Differential Revision:	https://reviews.freebsd.org/D2616

Changes:
  head/usr.bin/xargs/xargs.1
  head/usr.bin/xargs/xargs.c
Comment 4 Allan Jude freebsd_committer freebsd_triage 2015-08-04 14:30:43 UTC
Sorry this missed 10.2-RELEASE, but it will be merged to 10-STABLE after the MFC period.
Comment 5 Nikolai Lifanov 2015-08-22 16:24:52 UTC
This can probably be closed. The issue has been resolved in head/.
Comment 6 Nikolai Lifanov 2015-12-09 20:51:17 UTC
This change was committed (and fixed).
Comment 7 commit-hook freebsd_committer freebsd_triage 2016-01-12 05:51:40 UTC
A commit references this bug:

Author: allanjude
Date: Tue Jan 12 05:51:13 UTC 2016
New revision: 293726
URL: https://svnweb.freebsd.org/changeset/base/293726

Log:
  MFC: r285552
    Use strtonum(3) instead of atoi(3)

  MFC: r286289
    Introduce -P0, creating as many concurrent processes as possible

  Relnotes:	yes

  MFC: r286461
    Fix regression in xargs -Px, add more regression tests

  MFC: r287004
  MFC: r287005
    Fix the racy xargs -P0 -n2 test added in r286289

  PR:		199976
  Submitted by:	Nikolai Lifanov <lifanov@mail.lifanov.com>

Changes:
_U  stable/10/
  stable/10/usr.bin/xargs/tests/Makefile
  stable/10/usr.bin/xargs/tests/regress.0P1.out
  stable/10/usr.bin/xargs/tests/regress.P1.out
  stable/10/usr.bin/xargs/tests/regress.n2P0.out
  stable/10/usr.bin/xargs/tests/regress.sh
  stable/10/usr.bin/xargs/xargs.1
  stable/10/usr.bin/xargs/xargs.c