[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[coreutils] draft [PATCH] sort: explicit --parallel=N now overrides envi
From: |
Paul Eggert |
Subject: |
[coreutils] draft [PATCH] sort: explicit --parallel=N now overrides environment |
Date: |
Sat, 11 Dec 2010 01:05:52 -0800 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.13) Gecko/20101208 Thunderbird/3.1.7 |
It seems to me that this code in sort.c:
unsigned long int np2 = num_processors (NPROC_CURRENT_OVERRIDABLE);
if (!nthreads || nthreads > np2)
nthreads = np2;
is now obsolete. It was written assuming spin locks, but now that
we use mutexes, shouldn't we respect an explicit --parallel=N
flag? Something like the following, say? This would let the user
override the environment in the command line, which is normally what
people would expect.
>From bbc60da9222e38bb7983464cec35c42ad41f2eb8 Mon Sep 17 00:00:00 2001
From: Paul Eggert <address@hidden>
Date: Sat, 11 Dec 2010 01:02:57 -0800
Subject: [PATCH] sort: explicit --parallel=N now overrides environment
* NEWS: Document this.
* doc/coreutils.texi (sort invocation): Likewise.
* src/sort.c (main): Implement it.
---
NEWS | 4 ++++
doc/coreutils.texi | 3 +--
src/sort.c | 13 +++++++------
3 files changed, 12 insertions(+), 8 deletions(-)
diff --git a/NEWS b/NEWS
index 9f55cbb..d70de31 100644
--- a/NEWS
+++ b/NEWS
@@ -20,6 +20,10 @@ GNU coreutils NEWS -*-
outline -*-
** New features
+ sort --parallel=N now respects values of N greater than the number
+ of processors available, thus overriding any settings in the
+ OMP_NUM_THREADS environment variable.
+
split accepts the --number option to generate a specific number of files.
diff --git a/doc/coreutils.texi b/doc/coreutils.texi
index 34d9ff0..3ecc4d2 100644
--- a/doc/coreutils.texi
+++ b/doc/coreutils.texi
@@ -4128,8 +4128,7 @@ disks and controllers.
@opindex --parallel
@cindex multithreaded sort
Limit the number of sorts run in parallel to @var{n}. By default,
-@var{n} is set to the number of available processors, and values
-greater than that are reduced to that limit. Also see
+@var{n} is set to the number of available processors. Also see
@ref{nproc invocation}.
@item -u
diff --git a/src/sort.c b/src/sort.c
index 2c0f852..babc437 100644
--- a/src/sort.c
+++ b/src/sort.c
@@ -4624,14 +4624,15 @@ main (int argc, char **argv)
}
else
{
- unsigned long int np2 = num_processors (NPROC_CURRENT_OVERRIDABLE);
- if (!nthreads || nthreads > np2)
- nthreads = np2;
-
/* Avoid integer overflow later. */
size_t nthreads_max = SIZE_MAX / (2 * sizeof (struct merge_node));
- if (nthreads_max < nthreads)
- nthreads = nthreads_max;
+ if (nthreads)
+ nthreads = MIN (nthreads, nthreads_max);
+ else
+ {
+ unsigned long int np2 = num_processors (NPROC_CURRENT_OVERRIDABLE);
+ nthreads = MIN (np2, nthreads_max);
+ }
sort (files, nfiles, outfile, nthreads);
}
--
1.7.2
- [coreutils] Re: bug#7597: multi-threaded sort can segfault (unrelated to the sort -u segfault), (continued)
- [coreutils] Re: bug#7597: multi-threaded sort can segfault (unrelated to the sort -u segfault), Chen Guo, 2010/12/10
- [coreutils] Re: bug#7597: multi-threaded sort can segfault (unrelated to the sort -u segfault), Paul Eggert, 2010/12/11
- [coreutils] Re: bug#7597: multi-threaded sort can segfault (unrelated to the sort -u segfault), Jim Meyering, 2010/12/11
- [coreutils] Re: bug#7597: multi-threaded sort can segfault (unrelated to the sort -u segfault), Paul Eggert, 2010/12/11
- [coreutils] Re: bug#7597: multi-threaded sort can segfault (unrelated to the sort -u segfault), Jim Meyering, 2010/12/12
- [coreutils] Re: bug#7597: multi-threaded sort can segfault (unrelated to the sort -u segfault), Paul Eggert, 2010/12/12
- [coreutils] Re: bug#7597: multi-threaded sort can segfault (unrelated to the sort -u segfault), Jim Meyering, 2010/12/13
- [coreutils] Re: bug#7597: multi-threaded sort can segfault (unrelated to the sort -u segfault), Paul Eggert, 2010/12/13
- [coreutils] Re: bug#7597: multi-threaded sort can segfault (unrelated to the sort -u segfault), Paul Eggert, 2010/12/16
- [coreutils] Re: bug#7597: multi-threaded sort can segfault (unrelated to the sort -u segfault), Pádraig Brady, 2010/12/16
- [coreutils] draft [PATCH] sort: explicit --parallel=N now overrides environment,
Paul Eggert <=
- Re: [coreutils] draft [PATCH] sort: explicit --parallel=N now overrides environment, Pádraig Brady, 2010/12/11
- Re: [coreutils] draft [PATCH] sort: explicit --parallel=N now overrides environment, Jim Meyering, 2010/12/12
Re: bug#7489: [coreutils] over aggressive threads in sort, Paul Eggert, 2010/12/04