Skip to content

Commit

Permalink
Merge branch 'np/auto-thread'
Browse files Browse the repository at this point in the history
* np/auto-thread:
  Force t5302 to use a single thread
  pack-objects: don't use too many threads with few objects
  autodetect number of CPUs by default when using threads
  • Loading branch information
Junio C Hamano committed Dec 29, 2008
2 parents 373654e + 1415be8 commit 78d4096
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
9 changes: 8 additions & 1 deletion builtin-pack-objects.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ static int progress = 1;
static int window = 10;
static uint32_t pack_size_limit, pack_size_limit_cfg;
static int depth = 50;
static int delta_search_threads = 1;
static int delta_search_threads;
static int pack_to_stdout;
static int num_preferred_base;
static struct progress *progress_state;
Expand Down Expand Up @@ -1612,11 +1612,18 @@ static void ll_find_deltas(struct object_entry **list, unsigned list_size,
find_deltas(list, &list_size, window, depth, processed);
return;
}
if (progress > pack_to_stdout)
fprintf(stderr, "Delta compression using %d threads.\n",
delta_search_threads);

/* Partition the work amongst work threads. */
for (i = 0; i < delta_search_threads; i++) {
unsigned sub_size = list_size / (delta_search_threads - i);

/* don't use too small segments or no deltas will be found */
if (sub_size < 2*window && i+1 < delta_search_threads)
sub_size = 0;

p[i].window = window;
p[i].depth = depth;
p[i].processed = processed;
Expand Down
1 change: 1 addition & 0 deletions t/t5302-pack-index.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ test_expect_success \
'setup' \
'rm -rf .git
git init &&
git config pack.threads 1 &&
i=1 &&
while test $i -le 100
do
Expand Down

0 comments on commit 78d4096

Please sign in to comment.