1. 29 Oct, 2018 1 commit
    • Duy Nguyen's avatar
      thread-utils: macros to unconditionally compile pthreads API · 0ec79358
      Duy Nguyen authored
      When built with NO_PTHREADS, the macros are used make the code build
      even though pthreads header and library may be missing. The code can
      still have different code paths for no threads support with
      HAVE_THREADS variable.
      
      There are of course impacts on no-pthreads builds:
      
      - data structure may get slightly bigger because all the mutexes and
        pthread_t are present (as an int)
      
      - code execution is not impacted much. Locking (in hot path) is
        no-op. Other wrapper function calls really should not matter much.
      
      - the binary size grows bigger because of threaded code. But at least
        on Linux this does not matter, if some code is not executed, it's
        not mapped in memory.
      
      This is a preparation step to remove "#ifdef NO_PTHREADS" in the code
      mostly because of maintainability. As Jeff put it
      
      > it's probably OK to stop thinking of it as "non-threaded platforms
      > are the default and must pay zero cost" and more as "threaded
      > platforms are the default, and non-threaded ones are OK to pay a
      > small cost as long as they still work".
      Signed-off-by: Duy Nguyen's avatarNguyễn Thái Ngọc Duy <pclouds@gmail.com>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
      0ec79358
  2. 13 Oct, 2014 1 commit
    • Junio C Hamano's avatar
      pack-objects: set number of threads before checking and warning · 0c45d258
      Junio C Hamano authored
      Under NO_PTHREADS build, we warn when delta_search_threads is not
      set to 1, because that is the only sensible value on a single
      threaded build.
      
      However, the auto detection that kicks in when that variable is set
      to 0 (e.g. there is no configuration variable or command line option,
      or an explicit --threads=0 is given from the command line to override
      the pack.threads configuration to force auto-detection) was not done
      before the condition to issue this warning was tested.
      
      Move the auto-detection code and place it at an appropriate spot.
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
      0c45d258
  3. 10 Dec, 2010 1 commit
    • Junio C Hamano's avatar
      thread-utils.h: simplify the inclusion · b361888d
      Junio C Hamano authored
      All files that include this header file use the same four line
      incantation:
      
          #ifndef NO_PTHREADS
          #include <pthread.h>
          #include "thread-utils.h"
          #endif
      
      Move the responsibility for that gymnastics to the header file from the
      files that include it.  This approach makes it easier to later declare new
      services that are related to threading in thread-utils.h and have them
      available to all the threading code.
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
      b361888d
  4. 09 Apr, 2010 1 commit
  5. 23 Feb, 2008 1 commit
    • Andreas Ericsson's avatar
      pack-objects: Add runtime detection of online CPU's · 833e3df1
      Andreas Ericsson authored
      Packing objects can be done in parallell nowadays, but it's
      only done if the config option pack.threads is set to a value
      above 1. Because of that, the code-path used is often not the
      most optimal one.
      
      This patch adds a routine to detect the number of online CPU's
      at runtime (online_cpus()). When pack.threads (or --threads=) is
      given a value of 0, the number of threads is set to the number of
      online CPU's. This feature is also documented.
      
      As per Nicolas Pitre's recommendations, the default is still to
      run pack-objects single-threaded unless explicitly activated,
      either by configuration or by command line parameter.
      
      The routine online_cpus() is a rework of "numcpus.c", written by
      one Philip Willoughby <pgw99@doc.ic.ac.uk>. numcpus.c is in the
      public domain and can presently be downloaded from
      http://csgsoft.doc.ic.ac.uk/numcpus/Signed-off-by: default avatarAndreas Ericsson <ae@op5.se>
      Signed-off-by: default avatarBrandon Casey <casey@nrlssc.navy.mil>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
      833e3df1