hush/libbb/sysconf.c
Denys Vlasenko 04c1417602 libbb: use ARG_MAX for bb_arg_max() only if it's 60k+
Sometimes ARG_MAX is small (like 32k) yet sysconf(_SC_ARG_MAX)
is big, and people prefer using the bigger value.

OTOH, with sufficiently large ARG_MAX, further wins from
sysconf(_SC_ARG_MAX) being bigger are exponentially smaller:
you can see 4 times fewer fork+execs when you run find, 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.

Thus, with this change ARG_MAX is used if it's sufficiently big,
otherwise sysconf(_SC_ARG_MAX) is used.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-11-26 15:17:59 +01:00

23 lines
460 B
C

/* vi: set sw=4 ts=4: */
/*
* Various system configuration helpers.
*
* Copyright (C) 2014 Bartosz Golaszewski <bartekgola@gmail.com>
*
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
*/
#include "libbb.h"
#if !defined(bb_arg_max)
unsigned FAST_FUNC bb_arg_max(void)
{
return sysconf(_SC_ARG_MAX);
}
#endif
/* Return the number of clock ticks per second. */
unsigned FAST_FUNC bb_clk_tck(void)
{
return sysconf(_SC_CLK_TCK);
}