summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c06c796)
raw | patch | inline | side by side (parent: c06c796)
author | Junio C Hamano <junkio@cox.net> | |
Mon, 13 Mar 2006 00:39:51 +0000 (16:39 -0800) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Mon, 13 Mar 2006 01:26:32 +0000 (17:26 -0800) |
To reduce wasted memory, wait until the hash fills up more
densely before we rehash. This reduces the working set size a
bit further.
Signed-off-by: Junio C Hamano <junkio@cox.net>
densely before we rehash. This reduces the working set size a
bit further.
Signed-off-by: Junio C Hamano <junkio@cox.net>
diffcore-delta.c | patch | blob | history | |
diffcore-rename.c | patch | blob | history |
diff --git a/diffcore-delta.c b/diffcore-delta.c
index 471b98f05de2899f6aaa4818966aa99df7ec8f7e..f8a751837e3e67fef57e3de9670e5a2defc6652a 100644 (file)
--- a/diffcore-delta.c
+++ b/diffcore-delta.c
*/
/* Wild guess at the initial hash size */
-#define INITIAL_HASH_SIZE 10
+#define INITIAL_HASH_SIZE 9
#define HASHBASE 65537 /* next_prime(2^16) */
+/* We leave more room in smaller hash but do not let it
+ * grow to have unused hole too much.
+ */
+#define INITIAL_FREE(sz_log2) ((1<<(sz_log2))*(sz_log2-3)/(sz_log2))
struct spanhash {
unsigned long hashval;
struct spanhash data[FLEX_ARRAY];
};
-static struct spanhash *spanhash_find(struct spanhash_top *top, unsigned long hashval)
+static struct spanhash *spanhash_find(struct spanhash_top *top,
+ unsigned long hashval)
{
int sz = 1 << top->alloc_log2;
int bucket = hashval & (sz - 1);
new = xmalloc(sizeof(*orig) + sizeof(struct spanhash) * sz);
new->alloc_log2 = orig->alloc_log2 + 1;
- new->free = osz;
+ new->free = INITIAL_FREE(new->alloc_log2);
memset(new->data, 0, sizeof(struct spanhash) * sz);
for (i = 0; i < osz; i++) {
struct spanhash *o = &(orig->data[i]);
i = INITIAL_HASH_SIZE;
hash = xmalloc(sizeof(*hash) + sizeof(struct spanhash) * (1<<i));
hash->alloc_log2 = i;
- hash->free = (1<<i)/2;
+ hash->free = INITIAL_FREE(i);
memset(hash->data, 0, sizeof(struct spanhash) * (1<<i));
/* an 8-byte shift register made of accum1 and accum2. New
diff --git a/diffcore-rename.c b/diffcore-rename.c
index b80b4320ff6ea586d8d3c2800a7c42d68ccdd796..ed99fe2cc043c1c9726680d1dde06672e10c6eb1 100644 (file)
--- a/diffcore-rename.c
+++ b/diffcore-rename.c
m->score = estimate_similarity(one, two,
minimum_score);
}
- free(two->cnt_data);
- two->cnt_data = NULL;
+ /* We do not need the text anymore */
+ diff_free_filespec_data(two);
dst_cnt++;
}
/* cost matrix sorted by most to least similar pair */