summaryrefslogtreecommitdiff
path: root/builtin-pack-objects.c
diff options
context:
space:
mode:
authorNicolas Pitre <nico@cam.org>2007-09-10 00:06:11 -0400
committerJunio C Hamano <gitster@pobox.com>2007-09-09 22:26:06 -0700
commit367f4a4343d467ac76641362b102bc86da5cb584 (patch)
tree9a9bf81d459b619366dee8e72ffc989320946ead /builtin-pack-objects.c
parent59921b4b3f24b19e2593085ee27d5e1f2448c6bb (diff)
downloadgit-367f4a4343d467ac76641362b102bc86da5cb584.tar.gz
threaded delta search: specify number of threads at run time
This adds a --threads=<n> parameter to 'git pack-objects' with documentation. Signed-off-by: Nicolas Pitre <nico@cam.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin-pack-objects.c')
-rw-r--r--builtin-pack-objects.c26
1 files changed, 21 insertions, 5 deletions
diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c
index b13558ee7e..42698d2948 100644
--- a/builtin-pack-objects.c
+++ b/builtin-pack-objects.c
@@ -24,7 +24,7 @@ git-pack-objects [{ -q | --progress | --all-progress }] \n\
[--max-pack-size=N] [--local] [--incremental] \n\
[--window=N] [--window-memory=N] [--depth=N] \n\
[--no-reuse-delta] [--no-reuse-object] [--delta-base-offset] \n\
- [--non-empty] [--revs [--unpacked | --all]*] [--reflog] \n\
+ [--threads=N] [--non-empty] [--revs [--unpacked | --all]*] [--reflog] \n\
[--stdout | base-name] [<ref-list | <object-list]";
struct object_entry {
@@ -72,6 +72,7 @@ static int progress = 1;
static int window = 10;
static uint32_t pack_size_limit;
static int depth = 50;
+static int delta_search_threads = 1;
static int pack_to_stdout;
static int num_preferred_base;
static struct progress progress_state;
@@ -1605,19 +1606,22 @@ static void *threaded_find_deltas(void *arg)
}
}
-#define NR_THREADS 4
-
static void ll_find_deltas(struct object_entry **list, unsigned list_size,
int window, int depth, unsigned *processed)
{
- struct thread_params p[NR_THREADS];
+ struct thread_params p[delta_search_threads];
int i, ret;
unsigned chunk_size;
+ if (delta_search_threads <= 1) {
+ find_deltas(list, list_size, window, depth, processed);
+ return;
+ }
+
pthread_mutex_lock(&data_provider);
pthread_mutex_lock(&data_ready);
- for (i = 0; i < NR_THREADS; i++) {
+ for (i = 0; i < delta_search_threads; i++) {
p[i].window = window;
p[i].depth = depth;
p[i].processed = processed;
@@ -1900,6 +1904,18 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
usage(pack_usage);
continue;
}
+ if (!prefixcmp(arg, "--threads=")) {
+ char *end;
+ delta_search_threads = strtoul(arg+10, &end, 0);
+ if (!arg[10] || *end || delta_search_threads < 1)
+ usage(pack_usage);
+#ifndef THREADED_DELTA_SEARCH
+ if (delta_search_threads > 1)
+ warning("no threads support, "
+ "ignoring %s", arg);
+#endif
+ continue;
+ }
if (!prefixcmp(arg, "--depth=")) {
char *end;
depth = strtoul(arg+8, &end, 0);