Re: [PATCH v2 08/10] read-cache.c: remove #ifdef NO_PTHREADS
- From
Jeff King <peff@peff.net>
- Date
- Oct 29, 2018, 14:30 UTC
- Message-ID
- <20181029143033.GF17668@sigill.intra.peff.net>
- In-Reply-To
- <20181027173008.18852-9-pclouds@gmail.com>
On Sat, Oct 27, 2018 at 07:30:06PM +0200, Nguyễn Thái Ngọc Duy wrote:
Show 21 quoted lines
> -#ifndef NO_PTHREADS
> - nr_threads = git_config_get_index_threads();
> + if (HAVE_THREADS) {
> + nr_threads = git_config_get_index_threads();
>
> - /* TODO: does creating more threads than cores help? */
> - if (!nr_threads) {
> - nr_threads = istate->cache_nr / THREAD_COST;
> - cpus = online_cpus();
> - if (nr_threads > cpus)
> - nr_threads = cpus;
> + /* TODO: does creating more threads than cores help? */
> + if (!nr_threads) {
> + nr_threads = istate->cache_nr / THREAD_COST;
> + cpus = online_cpus();
> + if (nr_threads > cpus)
> + nr_threads = cpus;
> + }
> + } else {
> + nr_threads = 1;
> }I'd have thought we could just rely on online_cpus() returning 1 here to avoid having to ask "do we even have thread support?". But I guess that TODO comment implies that we might one day two 2 threads on a single CPU.
-Peff