Subject: Re: [PATCH] pack-objects: Add runtime detection of online CPU's

From: Andreas Ericsson <[email-masked]>
Date: Tue, 12 Feb 2008 13:21:47 +0100

Bert Wesarg wrote:
> Hi,
> 
> On Feb 12, 2008 9:20 AM, Andreas Ericsson <[email-masked]> wrote:
>> +#ifdef THREADED_DELTA_SEARCH
>> +# ifdef _SC_NPROCESSORS_ONLN
>> +       long ncpus;
>> +
>> +       if ((ncpus = (long)sysconf(_SC_NPROCESSORS_ONLN)) > 0)
>> +               return (int)ncpus;
>> +# else
> I can't find the right pointer, but for linux it would be more usable
> to use sched_getaffinity(). Than you can do thinks like this:
> 
> $ taskset 0x3 git gc ...
> 
> and you will get 2 cpus, even 4 are online.
> 

Since you can do roughly the same by saying "git pack-objects --threads=2",
I'd rather not add a GNU/Linux specific hack for this.

-- 
Andreas Ericsson                   [email-masked]
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231