Merge branch 'np/pack' into next
* np/pack: pack-object: slightly more efficient simple euristic for further free packing improvements
This commit is contained in:
commit
8dd84b0169
2
delta.h
2
delta.h
@ -18,6 +18,8 @@ create_delta_index(const void *buf, unsigned long bufsize);
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* free_delta_index: free the index created by create_delta_index()
|
* free_delta_index: free the index created by create_delta_index()
|
||||||
|
*
|
||||||
|
* Given pointer must be what create_delta_index() returned, or NULL.
|
||||||
*/
|
*/
|
||||||
extern void free_delta_index(struct delta_index *index);
|
extern void free_delta_index(struct delta_index *index);
|
||||||
|
|
||||||
|
@ -1039,8 +1039,8 @@ static int try_delta(struct unpacked *trg, struct unpacked *src,
|
|||||||
|
|
||||||
/* Now some size filtering euristics. */
|
/* Now some size filtering euristics. */
|
||||||
size = trg_entry->size;
|
size = trg_entry->size;
|
||||||
max_size = size / 2 - 20;
|
max_size = (size/2 - 20) / (src_entry->depth + 1);
|
||||||
if (trg_entry->delta)
|
if (trg_entry->delta && trg_entry->delta_size <= max_size)
|
||||||
max_size = trg_entry->delta_size-1;
|
max_size = trg_entry->delta_size-1;
|
||||||
src_size = src_entry->size;
|
src_size = src_entry->size;
|
||||||
sizediff = src_size < size ? size - src_size : 0;
|
sizediff = src_size < size ? size - src_size : 0;
|
||||||
@ -1105,17 +1105,14 @@ static void find_deltas(struct object_entry **list, int window, int depth)
|
|||||||
|
|
||||||
if (entry->size < 50)
|
if (entry->size < 50)
|
||||||
continue;
|
continue;
|
||||||
if (n->index)
|
free_delta_index(n->index);
|
||||||
free_delta_index(n->index);
|
n->index = NULL;
|
||||||
free(n->data);
|
free(n->data);
|
||||||
n->entry = entry;
|
n->entry = entry;
|
||||||
n->data = read_sha1_file(entry->sha1, type, &size);
|
n->data = read_sha1_file(entry->sha1, type, &size);
|
||||||
if (size != entry->size)
|
if (size != entry->size)
|
||||||
die("object %s inconsistent object length (%lu vs %lu)",
|
die("object %s inconsistent object length (%lu vs %lu)",
|
||||||
sha1_to_hex(entry->sha1), size, entry->size);
|
sha1_to_hex(entry->sha1), size, entry->size);
|
||||||
n->index = create_delta_index(n->data, size);
|
|
||||||
if (!n->index)
|
|
||||||
die("out of memory");
|
|
||||||
|
|
||||||
j = window;
|
j = window;
|
||||||
while (--j > 0) {
|
while (--j > 0) {
|
||||||
@ -1129,15 +1126,17 @@ static void find_deltas(struct object_entry **list, int window, int depth)
|
|||||||
if (try_delta(n, m, m->index, depth) < 0)
|
if (try_delta(n, m, m->index, depth) < 0)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#if 0
|
|
||||||
/* if we made n a delta, and if n is already at max
|
/* if we made n a delta, and if n is already at max
|
||||||
* depth, leaving it in the window is pointless. we
|
* depth, leaving it in the window is pointless. we
|
||||||
* should evict it first.
|
* should evict it first.
|
||||||
* ... in theory only; somehow this makes things worse.
|
|
||||||
*/
|
*/
|
||||||
if (entry->delta && depth <= entry->depth)
|
if (entry->delta && depth <= entry->depth)
|
||||||
continue;
|
continue;
|
||||||
#endif
|
|
||||||
|
n->index = create_delta_index(n->data, size);
|
||||||
|
if (!n->index)
|
||||||
|
die("out of memory");
|
||||||
|
|
||||||
idx++;
|
idx++;
|
||||||
if (idx >= window)
|
if (idx >= window)
|
||||||
idx = 0;
|
idx = 0;
|
||||||
@ -1147,8 +1146,7 @@ static void find_deltas(struct object_entry **list, int window, int depth)
|
|||||||
fputc('\n', stderr);
|
fputc('\n', stderr);
|
||||||
|
|
||||||
for (i = 0; i < window; ++i) {
|
for (i = 0; i < window; ++i) {
|
||||||
if (array[i].index)
|
free_delta_index(array[i].index);
|
||||||
free_delta_index(array[i].index);
|
|
||||||
free(array[i].data);
|
free(array[i].data);
|
||||||
}
|
}
|
||||||
free(array);
|
free(array);
|
||||||
|
Loading…
Reference in New Issue
Block a user