On Sat, Oct 27, 2018 at 07:30:06PM +0200, Nguyễn Thái Ngọc Duy wrote:
> -#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