From b2cbf0699e05c5b51e6f814aa0d655013fd8e9dd Mon Sep 17 00:00:00 2001 From: Moinak Ghosh Date: Sun, 11 Nov 2012 14:58:39 +0530 Subject: [PATCH] Use fixed rolling-hash mask for better block size approximation. --- rabin/rabin_dedup.c | 2 +- rabin/rabin_dedup.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/rabin/rabin_dedup.c b/rabin/rabin_dedup.c index aed8989..ad32df8 100755 --- a/rabin/rabin_dedup.c +++ b/rabin/rabin_dedup.c @@ -180,7 +180,7 @@ create_dedupe_context(uint64_t chunksize, uint64_t real_chunksize, int rab_blk_s ctx->fixed_flag = fixed_flag; ctx->rabin_break_patt = 0; ctx->rabin_poly_avg_block_size = 1 << (rab_blk_sz + RAB_BLK_MIN_BITS); - ctx->rabin_avg_block_mask = ((ctx->rabin_poly_avg_block_size - 1) >> 2); + ctx->rabin_avg_block_mask = RAB_BLK_MASK; ctx->rabin_poly_min_block_size = dedupe_min_blksz(rab_blk_sz); ctx->delta_flag = 0; diff --git a/rabin/rabin_dedup.h b/rabin/rabin_dedup.h index 37b1a55..7aab87f 100644 --- a/rabin/rabin_dedup.h +++ b/rabin/rabin_dedup.h @@ -73,6 +73,7 @@ #define RAB_POLYNOMIAL_MIN_WIN_SIZE 8 #define RAB_POLYNOMIAL_MAX_WIN_SIZE 64 #define RAB_POLYNOMIAL_MAX_BLOCK_SIZE (128 * 1024) +#define RAB_BLK_MASK (((1 << RAB_BLK_MIN_BITS) - 1) >> 1) // Minimum practical chunk size when doing dedup #define RAB_MIN_CHUNK_SIZE (1048576L)