From ec4215e6baf1d52efa21ff929c8f4b78f0b1c7d4 Mon Sep 17 00:00:00 2001 From: Wayne Davison Date: Sat, 3 Jul 2004 00:18:40 +0000 Subject: [PATCH] Modified to work with the trunk's hash_search() optimization. --- inplace.diff | 90 +++++++++++++++++++++++++++------------------------- 1 file changed, 47 insertions(+), 43 deletions(-) diff --git a/inplace.diff b/inplace.diff index 07b3442..44b6993 100644 --- a/inplace.diff +++ b/inplace.diff @@ -6,10 +6,14 @@ Run these commands after applying the patch: autoconf autoheader ./configure - make proto + make + +Optional: + + make rsync.1 --- configure.in 30 Apr 2004 18:03:33 -0000 1.196 -+++ configure.in 2 Jul 2004 21:10:25 -0000 ++++ configure.in 3 Jul 2004 00:16:50 -0000 @@ -442,7 +442,7 @@ dnl AC_FUNC_MEMCMP AC_FUNC_UTIME_NULL AC_FUNC_ALLOCA @@ -19,8 +23,8 @@ Run these commands after applying the patch: memmove lchown vsnprintf snprintf asprintf setsid glob strpbrk \ strlcat strlcpy strtol mallinfo getgroups setgroups geteuid getegid) ---- match.c 21 May 2004 08:27:04 -0000 1.62 -+++ match.c 2 Jul 2004 21:20:10 -0000 +--- match.c 2 Jul 2004 23:35:30 -0000 1.63 ++++ match.c 3 Jul 2004 00:16:50 -0000 @@ -23,6 +23,7 @@ extern int verbose; extern int am_server; extern int do_progress; @@ -29,7 +33,7 @@ Run these commands after applying the patch: typedef unsigned short tag; -@@ -52,9 +53,27 @@ static size_t *tag_table; +@@ -52,9 +53,23 @@ static size_t *tag_table; #define gettag2(s1,s2) (((s1) + (s2)) & 0xFFFF) #define gettag(sum) gettag2((sum)&0xFFFF,(sum)>>16) @@ -40,7 +44,6 @@ Run these commands after applying the patch: { - return (int)t1->t - (int)t2->t; + struct sum_buf *s1, *s2; -+ int diff; + + if (t1->t != t2->t) + return t1->t < t2->t ? -1 : 1; @@ -51,14 +54,11 @@ Run these commands after applying the patch: + if (s1->sum1 != s2->sum1) + return s1->sum1 < s2->sum1 ? -1 : 1; + -+ if ((diff = memcmp(s1->sum2, s2->sum2, current_s2length)) != 0) -+ return diff; -+ -+ return s1->offset - s2->offset; ++ return memcmp(s1->sum2, s2->sum2, current_s2length); } -@@ -74,6 +93,8 @@ static void build_hash_table(struct sum_ +@@ -74,6 +89,8 @@ static void build_hash_table(struct sum_ targets[i].t = gettag(s->sums[i].sum1); } @@ -67,7 +67,7 @@ Run these commands after applying the patch: qsort(targets,s->count,sizeof(targets[0]),(int (*)())compare_targets); for (i = 0; i < TABLESIZE; i++) -@@ -192,12 +213,24 @@ static void hash_search(int f,struct sum +@@ -192,12 +209,24 @@ static void hash_search(int f,struct sum unsigned int l; size_t i = targets[j].i; @@ -94,7 +94,7 @@ Run these commands after applying the patch: continue; if (verbose > 3) -@@ -215,15 +248,34 @@ static void hash_search(int f,struct sum +@@ -215,15 +244,39 @@ static void hash_search(int f,struct sum continue; } @@ -104,36 +104,40 @@ Run these commands after applying the patch: + * can hint at a better match. If inplace is enabled, + * the best possible match is one with an identical + * offset, so we prefer that over a last_i+1 match. */ -+ if (inplace && s->sums[i].offset == offset) { -+ s->sums[i].i = -1; -+ j = s->count; -+ } else if (i == last_i + 1) -+ j = s->count; - for (j++; j < s->count && targets[j].t == t; j++) { - size_t i2 = targets[j].i; -- if (i2 == last_i + 1) { -+ if (i2 == last_i + 1 -+ || (inplace && s->sums[i2].offset == offset)) { - if (sum != s->sums[i2].sum1) - break; - if (memcmp(sum2,s->sums[i2].sum2,s->s2length) != 0) - break; -+ if (inplace) { -+ if (s->sums[i2].offset < offset -+ && s->sums[i2].i >= 0) -+ continue; -+ i = i2; -+ if (s->sums[i2].offset == offset) { -+ s->sums[i2].i = -1; -+ break; -+ } ++ if (inplace) { ++ for (; j < s->count && targets[j].t == t; j++) { ++ size_t i2 = targets[j].i; ++ if (s->sums[i2].offset != offset) + continue; ++ if (i2 != i) { ++ if (sum != s->sums[i2].sum1) ++ break; ++ if (memcmp(sum2, s->sums[i2].sum2, ++ s->s2length) != 0) ++ break; ++ i = i2; + } - /* we've found an adjacent match - the RLL coder - * will be happy */ - i = i2; ++ /* Use this as a flag to indicate that ++ * this chunk was at the same offset on ++ * both the sender and the receiver. */ ++ s->sums[i].i = -1; ++ goto set_last_i; ++ } ++ } + if (i != last_i + 1 && last_i + 1 < s->count ++ && (!inplace || s->sums[last_i+1].offset >= offset || s->sums[last_i+1].i < 0) + && sum == s->sums[last_i+1].sum1 + && memcmp(sum2, s->sums[last_i+1].sum2, s->s2length) == 0) { + /* we've found an adjacent match - the RLL coder + * will be happy */ + i = last_i + 1; + } ++ set_last_i: + last_i = i; + + matched(f,s,buf,offset,i); --- options.c 20 Jun 2004 19:47:05 -0000 1.157 -+++ options.c 2 Jul 2004 21:20:10 -0000 ++++ options.c 3 Jul 2004 00:16:50 -0000 @@ -94,6 +94,7 @@ int ignore_errors = 0; int modify_window = 0; int blocking_io = -1; @@ -218,7 +222,7 @@ Run these commands after applying the patch: args[ac++] = "--temp-dir"; args[ac++] = tmpdir; --- receiver.c 2 Jul 2004 18:23:57 -0000 1.86 -+++ receiver.c 2 Jul 2004 21:20:10 -0000 ++++ receiver.c 3 Jul 2004 00:16:50 -0000 @@ -48,6 +48,7 @@ extern int ignore_errors; extern int orig_umask; extern int keep_partial; @@ -357,7 +361,7 @@ Run these commands after applying the patch: if (!am_server && verbose) rprintf(FINFO, "%s\n", fname); --- rsync.c 2 Jul 2004 18:13:53 -0000 1.142 -+++ rsync.c 2 Jul 2004 21:20:11 -0000 ++++ rsync.c 3 Jul 2004 00:16:51 -0000 @@ -34,6 +34,7 @@ extern int force_delete; extern int recurse; extern int make_backups; @@ -381,7 +385,7 @@ Run these commands after applying the patch: if (verbose > 2) rprintf(FINFO, "renaming %s to %s\n", fnametmp, fname); --- rsync.yo 5 Jun 2004 16:16:30 -0000 1.171 -+++ rsync.yo 2 Jul 2004 21:20:12 -0000 ++++ rsync.yo 3 Jul 2004 00:16:52 -0000 @@ -289,6 +289,7 @@ verb( --backup-dir make backups into this directory --suffix=SUFFIX backup suffix (default ~ w/o --backup-dir) -- 2.34.1