* 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. */
| 194 | * it is not worth it. |
| 195 | */ |
| 196 | static 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 |
no test coverage detected