X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/45f133b9769fb45a329d3d41e121109d430e307d..c95da96a0c51c66c8cb2eff97b768a717d9e0c79:/match.c diff --git a/match.c b/match.c index 0d8bc31b..272025aa 100644 --- a/match.c +++ b/match.c @@ -29,18 +29,18 @@ extern int remote_version; typedef unsigned short tag; #define TABLESIZE (1<<16) -#define NULL_TAG ((tag)-1) +#define NULL_TAG (-1) static int false_alarms; static int tag_hits; static int matches; -static int data_transfer; +static int64 data_transfer; static int total_false_alarms; static int total_tag_hits; static int total_matches; -static int64 total_data_transfer; +extern struct stats stats; struct target { tag t; @@ -49,7 +49,7 @@ struct target { static struct target *targets; -static tag *tag_table; +static int *tag_table; #define gettag2(s1,s2) (((s1) + (s2)) & 0xFFFF) #define gettag(sum) gettag2((sum)&0xFFFF,(sum)>>16) @@ -65,7 +65,7 @@ static void build_hash_table(struct sum_struct *s) int i; if (!tag_table) - tag_table = (tag *)malloc(sizeof(tag)*TABLESIZE); + tag_table = (int *)malloc(sizeof(tag_table[0])*TABLESIZE); targets = (struct target *)malloc(sizeof(targets[0])*s->count); if (!tag_table || !targets) @@ -103,11 +103,10 @@ static void matched(int f,struct sum_struct *s,struct map_struct *buf, send_token(f,i,buf,last_match,n,i<0?0:s->sums[i].len); data_transfer += n; - if (n > 0) - write_flush(f); - - if (i >= 0) + if (i >= 0) { + stats.matched_data += s->sums[i].len; n += s->sums[i].len; + } for (j=0;j 2) rprintf(FINFO,"hash search b=%d len=%d\n",s->n,(int)len); @@ -214,21 +212,15 @@ static void hash_search(int f,struct sum_struct *s, --k; } - if (!do_compression) { - /* By matching early we avoid re-reading the - data 3 times in the case where a token - match comes a long way after last - match. The 3 reads are caused by the - running match, the checksum update and the - literal send. - - we don't enable this for the compressed - case yet as the deflated token code can't - handle it. Paul is working on it */ - if (offset-last_match >= CHUNK_SIZE+s->n && - (end-offset > CHUNK_SIZE)) { - matched(f,s,buf,offset - s->n, -2); - } + /* By matching early we avoid re-reading the + data 3 times in the case where a token + match comes a long way after last + match. The 3 reads are caused by the + running match, the checksum update and the + literal send. */ + if (offset-last_match >= CHUNK_SIZE+s->n && + (end-offset > CHUNK_SIZE)) { + matched(f,s,buf,offset - s->n, -2); } } while (++offset < end); @@ -283,7 +275,7 @@ void match_sums(int f,struct sum_struct *s,struct map_struct *buf,OFF_T len) total_tag_hits += tag_hits; total_false_alarms += false_alarms; total_matches += matches; - total_data_transfer += data_transfer; + stats.literal_data += data_transfer; } void match_report(void) @@ -292,7 +284,8 @@ void match_report(void) return; rprintf(FINFO, - "total: matches=%d tag_hits=%d false_alarms=%d data=%ld\n", + "total: matches=%d tag_hits=%d false_alarms=%d data=%.0f\n", total_matches,total_tag_hits, - total_false_alarms,(long)total_data_transfer); + total_false_alarms, + (double)stats.literal_data); }