]> git.ipfire.org Git - thirdparty/coreutils.git/commit
sort: avoid pthread calls with --parallel=1
authorPádraig Brady <P@draigBrady.com>
Mon, 10 Nov 2025 23:17:24 +0000 (23:17 +0000)
committerPádraig Brady <P@draigBrady.com>
Wed, 12 Nov 2025 14:12:43 +0000 (14:12 +0000)
commite8dcdb993202fb76a97424abd45b1ccc83e9153d
tree6029eb179534c7b0c74af72ee7e1d352f9b5aea7
parent6f265b515e5b93cef9bef0c4994622574c55a1ba
sort: avoid pthread calls with --parallel=1

Before this change there were the following unneeded pthread calls:

  $ seq 1e6 | ltrace -c -e 'pthread*' sort --parallel=1 | wc -l
  % time     seconds  usecs/call     calls      function
  ------ ----------- ----------- --------- --------------------
   39.13    0.031757          67       468 pthread_mutex_lock
   37.96    0.030811          65       468 pthread_mutex_unlock
   13.17    0.010691          65       162 pthread_cond_signal
    2.15    0.001747          64        27 pthread_mutex_destroy
    2.00    0.001620          60        27 pthread_mutex_init
    0.70    0.000565          62         9 pthread_cond_destroy
    0.64    0.000518          57         9 pthread_cond_init
  ------ ----------- ----------- --------- --------------------
  100.00    0.081159                  1170 total

* src/sort.c (sort): Avoid merge tree overhead when single threaded.
src/sort.c