From 20905b0cdcb960c9949763c606f15e7e09d02e00 Mon Sep 17 00:00:00 2001 From: Bo Borgerson Date: Sat, 5 Apr 2008 13:33:51 -0400 Subject: sort: accept new option --batch-size=NMERGE * src/sort.c: (static unsigned int nmerge) Replace constant NMERGE. (specify_nmerge) Validate and apply new option. (mergefps) Replace some arrays with pointers to xnmalloc'd storage. * tests/misc/sort-merge: Test new option. * doc/coreutils.texi: Describe new option. * NEWS: Advertise new option. --- doc/coreutils.texi | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'doc') diff --git a/doc/coreutils.texi b/doc/coreutils.texi index e4a979e61..f7b9e7844 100644 --- a/doc/coreutils.texi +++ b/doc/coreutils.texi @@ -3804,6 +3804,29 @@ multiple fields. Example: To sort on the second field, use @option{--key=2,2} (@option{-k 2,2}). See below for more examples. +@item --batch-size=@var{nmerge} +@opindex --batch-size +@cindex number of inputs to merge, nmerge +Merge at most @var{nmerge} inputs at once. + +When @command{sort} has to merge more than @var{nmerge} inputs, +it merges them in groups of @var{nmerge}, saving the result in +a temporary file, which is then used as an input in a subsequent merge. + +A large value of @var{nmerge} may improve merge performance and decrease +temporary storage utilization at the expense of increased memory usage +and I/0. Conversely a small value of @var{nmerge} may reduce memory +requirements and I/0 at the expense of temporary storage consumption and +merge performance. + +The value of @var{nmerge} must be at least 2. + +The value of @var{nmerge} may be bounded by a resource limit for open +file descriptors. Try @samp{ulimit -n} or @samp{getconf OPEN_MAX} to +to display the limit for a particular system. +If the value of @var{nmerge} exceeds this limit, then @command{sort} will +issue a warning to standard error and exit with a nonzero status. + @item -o @var{output-file} @itemx --output=@var{output-file} @opindex -o -- cgit v1.2.3-54-g00ecf