[PATCH] pack-objects: move thread autodetection closer to relevant code
- From
Nicolas Pitre <nico@fluxnic.net>
- Date
- Nov 4, 2009, 21:32 UTC
- Message-ID
- <alpine.LFD.2.00.0911041623570.10340@xanadu.home>
- In-Reply-To
- <16cee31f0911041316n20fc9f12s6595dadc813d8f46@mail.gmail.com>
Let's keep thread stuff close together if possible. And in this case, this even reduces the #ifdef noise, and allows for skipping the autodetection altogether if delta search is not needed (like with a pure clone).
Signed-off-by: Nicolas Pitre <nico@fluxnic.net> ---
Show 13 quoted lines
> 2009/11/4 Nicolas Pitre <nico@fluxnic.net>: > >> @@ -2327,6 +2354,8 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix) > >> #ifdef THREADED_DELTA_SEARCH > >> if (!delta_search_threads) /* --threads=0 means autodetect */ > >> delta_search_threads = online_cpus(); > >> + > >> + init_threaded_delta_search(); > > > > What about doing this at the beginning of ll_find_deltas() instead? > > And similarly for cleanup_threaded_delta_search(): call it right before > > leaving ll_find_deltas(). This way thread issues would remain more > > localized. In fact I'd move the whole thing above in ll_find_deltas() > > as well (separately from this patch though).
So here it is.
diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c index 02f9246..4c91e94 100644 --- a/builtin-pack-objects.c +++ b/builtin-pack-objects.c @@ -1629,6 +1629,8 @@ static void ll_find_deltas(struct object_entry **list, unsigned list_size, struct thread_params *p; int i, ret, active_threads = 0; + if (!delta_search_threads) /* --threads=0 means autodetect */ + delta_search_threads = online_cpus(); if (delta_search_threads <= 1) { find_deltas(list, &list_size, window, depth, processed); return; @@ -2324,11 +2326,6 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix) if (keep_unreachable && unpack_unreachable) die("--keep-unreachable and --unpack-unreachable are incompatible."); -#ifdef THREADED_DELTA_SEARCH - if (!delta_search_threads) /* --threads=0 means autodetect */ - delta_search_threads = online_cpus(); -#endif - prepare_packed_git(); if (progress)