MCPcopy Create free account
hub / github.com/git/git / lookup_lazy_params

Function lookup_lazy_params

name-hash.c:196–224  ·  view source on GitHub ↗

* Decide if we want to use threads (if available) to load * the hash tables. We set "lazy_nr_dir_threads" to zero when * it is not worth it. */

Source from the content-addressed store, hash-verified

194 * it is not worth it.
195 */
196static int lookup_lazy_params(struct index_state *istate)
197{
198 int nr_cpus;
199
200 lazy_nr_dir_threads = 0;
201
202 if (!lazy_try_threaded)
203 return 0;
204
205 /*
206 * If we are respecting case, just use the original
207 * code to build the "istate->name_hash". We don't
208 * need the complexity here.
209 */
210 if (!ignore_case)
211 return 0;
212
213 nr_cpus = online_cpus();
214 if (nr_cpus < 2)
215 return 0;
216
217 if (istate->cache_nr < 2 * LAZY_THREAD_COST)
218 return 0;
219
220 if (istate->cache_nr < nr_cpus * LAZY_THREAD_COST)
221 nr_cpus = istate->cache_nr / LAZY_THREAD_COST;
222 lazy_nr_dir_threads = nr_cpus;
223 return lazy_nr_dir_threads;
224}
225
226/*
227 * Initialize n mutexes for use when searching and inserting

Callers 1

lazy_init_name_hashFunction · 0.85

Calls 1

online_cpusFunction · 0.85

Tested by

no test coverage detected