builtin/repack.c: allow configuring cruft pack generation
In servers which set the pack.window configuration to a large value, we can wind up spending quite a lot of time finding new bases when breaking delta chains between reachable and unreachable objects while generating a cruft pack. Introduce a handful of `repack.cruft*` configuration variables to control the parameters used by pack-objects when generating a cruft pack. Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
f9825d1cf7
commit
4571324b99
@ -41,9 +41,21 @@ static const char incremental_bitmap_conflict_error[] = N_(
|
||||
"--no-write-bitmap-index or disable the pack.writebitmaps configuration."
|
||||
);
|
||||
|
||||
struct pack_objects_args {
|
||||
const char *window;
|
||||
const char *window_memory;
|
||||
const char *depth;
|
||||
const char *threads;
|
||||
const char *max_pack_size;
|
||||
int no_reuse_delta;
|
||||
int no_reuse_object;
|
||||
int quiet;
|
||||
int local;
|
||||
};
|
||||
|
||||
static int repack_config(const char *var, const char *value, void *cb)
|
||||
{
|
||||
struct pack_objects_args *cruft_po_args = cb;
|
||||
if (!strcmp(var, "repack.usedeltabaseoffset")) {
|
||||
delta_base_offset = git_config_bool(var, value);
|
||||
return 0;
|
||||
@ -65,6 +77,14 @@ static int repack_config(const char *var, const char *value, void *cb)
|
||||
run_update_server_info = git_config_bool(var, value);
|
||||
return 0;
|
||||
}
|
||||
if (!strcmp(var, "repack.cruftwindow"))
|
||||
return git_config_string(&cruft_po_args->window, var, value);
|
||||
if (!strcmp(var, "repack.cruftwindowmemory"))
|
||||
return git_config_string(&cruft_po_args->window_memory, var, value);
|
||||
if (!strcmp(var, "repack.cruftdepth"))
|
||||
return git_config_string(&cruft_po_args->depth, var, value);
|
||||
if (!strcmp(var, "repack.cruftthreads"))
|
||||
return git_config_string(&cruft_po_args->threads, var, value);
|
||||
return git_default_config(var, value, cb);
|
||||
}
|
||||
|
||||
@ -157,18 +177,6 @@ static void remove_redundant_pack(const char *dir_name, const char *base_name)
|
||||
strbuf_release(&buf);
|
||||
}
|
||||
|
||||
struct pack_objects_args {
|
||||
const char *window;
|
||||
const char *window_memory;
|
||||
const char *depth;
|
||||
const char *threads;
|
||||
const char *max_pack_size;
|
||||
int no_reuse_delta;
|
||||
int no_reuse_object;
|
||||
int quiet;
|
||||
int local;
|
||||
};
|
||||
|
||||
static void prepare_pack_objects(struct child_process *cmd,
|
||||
const struct pack_objects_args *args)
|
||||
{
|
||||
@ -692,6 +700,7 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
|
||||
int keep_unreachable = 0;
|
||||
struct string_list keep_pack_list = STRING_LIST_INIT_NODUP;
|
||||
struct pack_objects_args po_args = {NULL};
|
||||
struct pack_objects_args cruft_po_args = {NULL};
|
||||
int geometric_factor = 0;
|
||||
int write_midx = 0;
|
||||
|
||||
@ -746,7 +755,7 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
|
||||
OPT_END()
|
||||
};
|
||||
|
||||
git_config(repack_config, NULL);
|
||||
git_config(repack_config, &cruft_po_args);
|
||||
|
||||
argc = parse_options(argc, argv, prefix, builtin_repack_options,
|
||||
git_repack_usage, 0);
|
||||
@ -921,7 +930,19 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
|
||||
if (*pack_prefix == '/')
|
||||
pack_prefix++;
|
||||
|
||||
ret = write_cruft_pack(&po_args, pack_prefix, &names,
|
||||
if (!cruft_po_args.window)
|
||||
cruft_po_args.window = po_args.window;
|
||||
if (!cruft_po_args.window_memory)
|
||||
cruft_po_args.window_memory = po_args.window_memory;
|
||||
if (!cruft_po_args.depth)
|
||||
cruft_po_args.depth = po_args.depth;
|
||||
if (!cruft_po_args.threads)
|
||||
cruft_po_args.threads = po_args.threads;
|
||||
|
||||
cruft_po_args.local = po_args.local;
|
||||
cruft_po_args.quiet = po_args.quiet;
|
||||
|
||||
ret = write_cruft_pack(&cruft_po_args, pack_prefix, &names,
|
||||
&existing_nonkept_packs,
|
||||
&existing_kept_packs);
|
||||
if (ret)
|
||||
|
Reference in New Issue
Block a user