From: Ben Peart Date: Mon, 29 Oct 2018 18:05:58 GMT Subject: Re: [PATCH v2 06/10] preload-index.c: remove #ifdef NO_PTHREADS Message-ID: <2935e3e8-c529-4292-baa3-fc3c9074028b@gmail.com> In-Reply-To: On 10/29/2018 1:26 PM, Duy Nguyen wrote: > On Mon, Oct 29, 2018 at 6:21 PM Ben Peart wrote: >> @@ -114,6 +104,9 @@ static void preload_index(struct index_state *index, >> threads = index->cache_nr / THREAD_COST; >> if ((index->cache_nr > 1) && (threads < 2) && >> git_env_bool("GIT_TEST_PRELOAD_INDEX", 0)) >> threads = 2; >> + cpus = online_cpus(); >> + if (threads > cpus) >> + threads = cpus; >> if (threads < 2) >> return; >> trace_performance_enter(); > > Capping the number of threads to online_cpus() does not always make > sense. In this case (or at least the original use case where we stat() > over nfs) we want to issue as many requests to nfs server as possible > to reduce latency and it has nothing to do with how many cores we > have. Using more threads than cores might make sense since threads are > blocked by nfs client, but we still want to send more to the server. > That makes sense. Some test will be necessary then. I guess HAVE_THREADS is functionally the same as online_cpus() == 1. For some reason, I prefer the latter - probably because I'm typically already calling it and so it doesn't feel like a 'special' value/test I have to remember. I just know I need to make sure the logic works correctly with any number of cps greater than zero. :-)