[PATCH 1/2] find: use sysconf(_SC_ARG_MAX) to determine the command-line size limit

Denys Vlasenko vda.linux at googlemail.com
Wed Nov 26 14:21:38 UTC 2014


On Thu, Jul 3, 2014 at 2:27 PM, Bartosz Gołaszewski
<bartekgola at gmail.com> wrote:
> have you read my message from June 10th in this thread? Could you
> review the patches I attached back then? Busybox still uses ARG_MAX as
> default, which is smaller than sysconf(_SC_ARG_MAX) on every system I
> checked. In fact commit 5aeae36 isn't even needed if we switch to
> using sysconf() as default.

I am using an uclibc-based toolchain and it has ARG_MAX of 126k.
(It's sysconf(_SC_ARG_MAX) is 128k, btw, and I don't need to
include linux/limits.h to get it.)

The case where ARG_MAX is in use gives a small size advantage
(eliminates a function call). I would like to preserve that.

With sufficiently large ARG_MAX, further wins from sysconf(_SC_ARG_MAX)
being bigger than it are exponentially smaller:
you can see 4 times fewer fork+execs, but when each execed process
already takes a thousand parameters it's likely execution time is dominated
by what that process does with each parameter.

I pushed a change which attempts to find a balance.
Please take a look at current git.


More information about the busybox mailing list