tCount cache hit/miss for the current run only - dedup - deduplicating backup program
(HTM) git clone git://git.z3bra.org/dedup.git
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit f32c0a57bf01c2734bbc927d7fe3c94f42b3e430
(DIR) parent 53741db3458c3a8fc633b7a5336d08062fa5e8a6
(HTM) Author: z3bra <contactatz3bradotorg>
Date: Wed, 20 Feb 2019 15:37:42 +0100
Count cache hit/miss for the current run only
Diffstat:
M dedup.c | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
---
(DIR) diff --git a/dedup.c b/dedup.c
t@@ -42,9 +42,7 @@ struct stats {
uint64_t min_blk_size;
uint64_t max_blk_size;
uint64_t nr_blks;
- uint64_t cache_hits;
- uint64_t cache_misses;
- uint64_t reserved[4];
+ uint64_t reserved[6];
};
struct snapshot_hdr {
t@@ -86,6 +84,8 @@ int sfd;
int cfd;
int verbose;
int cache_dirty;
+unsigned long long cache_hits;
+unsigned long long cache_misses;
char *argv0;
/*
t@@ -236,10 +236,8 @@ print_stats(struct stats *st)
(unsigned long long)st->max_blk_size);
fprintf(stderr, "number of blocks: %llu\n",
(unsigned long long)st->nr_blks);
- fprintf(stderr, "total cache hits: %llu\n",
- (unsigned long long)st->cache_hits);
- fprintf(stderr, "total cache misses: %llu\n",
- (unsigned long long)st->cache_misses);
+ fprintf(stderr, "cache hits: %llu\n", cache_hits);
+ fprintf(stderr, "cache misses: %llu\n", cache_misses);
}
void
t@@ -513,10 +511,10 @@ dedup(int fd, char *msg)
ent->blk_desc = blk_desc;
add_cache_entry(ent);
cache_dirty = 1;
+ cache_misses++;
snaphdr.st.dedup_size += blk_desc.size;
snaphdr.st.nr_blks++;
- snaphdr.st.cache_misses++;
if (blk_desc.size > snaphdr.st.max_blk_size)
snaphdr.st.max_blk_size = blk_desc.size;
t@@ -524,7 +522,7 @@ dedup(int fd, char *msg)
snaphdr.st.min_blk_size = blk_desc.size;
} else {
snap->blk_desc[snap->nr_blk_descs++] = blk_desc;
- snaphdr.st.cache_hits++;
+ cache_hits++;
}
memmove(inp, inp + blksize, bufsize - blksize);