Skip to content

Commit

Permalink
builtin-pack-object: cache small deltas
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Koegler <mkoegler@auto.tuwien.ac.at>
Signed-off-by: Junio C Hamano <junkio@cox.net>
  • Loading branch information
Martin Koegler authored and Junio C Hamano committed May 29, 2007
1 parent 074b2ee commit e3dfddb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Documentation/config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,10 @@ pack.deltaCacheSize::
gitlink:git-pack-objects[1].
A value of 0 means no limit. Defaults to 0.

pack.deltaCacheLimit::
The maxium size of a delta, that is cached in
gitlink:git-pack-objects[1]. Defaults to 1000.

pull.octopus::
The default merge strategy to use when pulling multiple branches
at once.
Expand Down
8 changes: 8 additions & 0 deletions builtin-pack-objects.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ static int pack_compression_seen;

static unsigned long delta_cache_size = 0;
static unsigned long max_delta_cache_size = 0;
static unsigned long cache_max_small_delta_size = 1000;

/*
* The object names in objects array are hashed with this hashtable,
Expand Down Expand Up @@ -1403,6 +1404,9 @@ static int delta_cacheable(struct unpacked *trg, struct unpacked *src,
if (max_delta_cache_size && delta_cache_size + delta_size > max_delta_cache_size)
return 0;

if (delta_size < cache_max_small_delta_size)
return 1;

/* cache delta, if objects are large enough compared to delta size */
if ((src_size >> 20) + (trg_size >> 21) > (delta_size >> 10))
return 1;
Expand Down Expand Up @@ -1654,6 +1658,10 @@ static int git_pack_config(const char *k, const char *v)
max_delta_cache_size = git_config_int(k, v);
return 0;
}
if (!strcmp(k, "pack.deltacachelimit")) {
cache_max_small_delta_size = git_config_int(k, v);
return 0;
}
return git_default_config(k, v);
}

Expand Down

0 comments on commit e3dfddb

Please sign in to comment.