Try using Geert similarity code in pack-objects.
It appears the fingerprinting itself is too expensive to be worth doing for this purpose. A failed experiment. Signed-off-by: Junio C Hamano <junkio@cox.net>
Junio C Hamano committed
Apr 16, 2006 at 22:03 UTC
ca9de6cadfa55c9b00476112e2bb52fe20ab95e0
2 files changed
+11
-1
Makefile
+1
-1
@@ -204,7 +204,7 @@ DIFF_OBJS = \
204
diffcore-delta.o log-tree.o
205
206
LIB_OBJS = \
207
- blob.o commit.o connect.o csum-file.o \
207
+ blob.o commit.o connect.o csum-file.o gsimm.o rabinpoly.o \
208
date.o diff-delta.o entry.o exec_cmd.o ident.o index.o \
209
object.o pack-check.o patch-delta.o path.o pkt-line.o \
210
quote.o read-cache.o refs.o run-command.o \
pack-objects.c
+10
@@ -8,6 +8,8 @@
8
#include "pack.h"
9
#include "csum-file.h"
10
#include "tree-walk.h"
11
+#include "rabinpoly.h"
12
+#include "gsimm.h"
13
#include <sys/time.h>
14
#include <signal.h>
15
@@ -993,6 +995,7 @@ static int type_size_sort(const struct object_entry *a, const struct object_entr
995
996
struct unpacked {
997
struct object_entry *entry;
998
+ unsigned char fingerprint[MD_LENGTH];
999
void *data;
1000
};
1001
@@ -1041,6 +1044,9 @@ static int try_delta(struct unpacked *cur, struct unpacked *old, unsigned max_de
1044
if (old_entry->depth >= max_depth)
1045
return 0;
1046
1047
+ if (gb_simm_score(cur->fingerprint, old->fingerprint) < 0.4)
1048
+ return 0;
1049
+
1050
/*
1051
* NOTE!
1052
*
@@ -1077,6 +1083,7 @@ static void find_deltas(struct object_entry **list, int window, int depth)
1083
unsigned processed = 0;
1084
unsigned last_percent = 999;
1085
1086
+ rabin_reset ();
1087
memset(array, 0, array_size);
1088
i = nr_objects;
1089
idx = 0;
@@ -1115,6 +1122,8 @@ static void find_deltas(struct object_entry **list, int window, int depth)
1122
if (size != entry->size)
1123
die("object %s inconsistent object length (%lu vs %lu)", sha1_to_hex(entry->sha1), size, entry->size);
1124
1125
+ gb_simm_process(n->data, size, n->fingerprint);
1126
+
1127
j = window;
1128
while (--j > 0) {
1129
unsigned int other_idx = idx + j;
@@ -1124,6 +1133,7 @@ static void find_deltas(struct object_entry **list, int window, int depth)
1133
m = array + other_idx;
1134
if (!m->entry)
1135
break;
1136
+
1137
if (try_delta(n, m, depth) < 0)
1138
break;
1139
}