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

Function ll_find_deltas

builtin/pack-objects.c:3201–3328  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3199}
3200
3201static void ll_find_deltas(struct object_entry **list, unsigned list_size,
3202 int window, int depth, unsigned *processed)
3203{
3204 struct thread_params *p;
3205 int i, ret, active_threads = 0;
3206
3207 init_threaded_search();
3208
3209 if (delta_search_threads <= 1) {
3210 find_deltas(list, &list_size, window, depth, processed);
3211 cleanup_threaded_search();
3212 return;
3213 }
3214 if (progress > pack_to_stdout)
3215 fprintf_ln(stderr, _("Delta compression using up to %d threads"),
3216 delta_search_threads);
3217 CALLOC_ARRAY(p, delta_search_threads);
3218
3219 /* Partition the work amongst work threads. */
3220 for (i = 0; i < delta_search_threads; i++) {
3221 unsigned sub_size = list_size / (delta_search_threads - i);
3222
3223 /* don't use too small segments or no deltas will be found */
3224 if (sub_size < 2*window && i+1 < delta_search_threads)
3225 sub_size = 0;
3226
3227 p[i].window = window;
3228 p[i].depth = depth;
3229 p[i].processed = processed;
3230 p[i].working = 1;
3231 p[i].data_ready = 0;
3232
3233 /* try to split chunks on "path" boundaries */
3234 while (sub_size && sub_size < list_size &&
3235 list[sub_size]->hash &&
3236 list[sub_size]->hash == list[sub_size-1]->hash)
3237 sub_size++;
3238
3239 p[i].list = list;
3240 p[i].list_size = sub_size;
3241 p[i].remaining = sub_size;
3242
3243 list += sub_size;
3244 list_size -= sub_size;
3245 }
3246
3247 /* Start work threads. */
3248 for (i = 0; i < delta_search_threads; i++) {
3249 if (!p[i].list_size)
3250 continue;
3251 pthread_mutex_init(&p[i].mutex, NULL);
3252 pthread_cond_init(&p[i].cond, NULL);
3253 ret = pthread_create(&p[i].thread, NULL,
3254 threaded_find_deltas, &p[i]);
3255 if (ret)
3256 die(_("unable to create thread: %s"), strerror(ret));
3257 active_threads++;
3258 }

Callers 1

prepare_packFunction · 0.85

Calls 7

init_threaded_searchFunction · 0.85
find_deltasFunction · 0.85
cleanup_threaded_searchFunction · 0.85
fprintf_lnFunction · 0.85
pthread_createFunction · 0.85
pthread_cond_waitFunction · 0.85
dieFunction · 0.50

Tested by

no test coverage detected