From cd1598302aa675ea65a63ec428bf25efe91bdb3b Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Tue, 19 Feb 2019 12:27:37 +0100 Subject: [PATCH] src/backup/chunker.rs: use 64 byte chunker window size This results in faster code. --- src/backup/chunker.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/backup/chunker.rs b/src/backup/chunker.rs index f1014460..7e19d9e7 100644 --- a/src/backup/chunker.rs +++ b/src/backup/chunker.rs @@ -1,4 +1,4 @@ -const CA_CHUNKER_WINDOW_SIZE: usize = 48; +const CA_CHUNKER_WINDOW_SIZE: usize = 64; /// Slinding window chunker (Buzhash) /// @@ -161,14 +161,16 @@ impl Chunker { self.start(); } - let mut idx = self.chunk_size % CA_CHUNKER_WINDOW_SIZE; + //let mut idx = self.chunk_size % CA_CHUNKER_WINDOW_SIZE; + let mut idx = self.chunk_size & 0x3f; while pos < data_len { // roll window let enter = data[pos]; let leave = self.window[idx]; self.h = self.h.rotate_left(1) ^ - BUZHASH_TABLE[leave as usize].rotate_left(CA_CHUNKER_WINDOW_SIZE as u32) ^ + //BUZHASH_TABLE[leave as usize].rotate_left(CA_CHUNKER_WINDOW_SIZE as u32) ^ + BUZHASH_TABLE[leave as usize] ^ BUZHASH_TABLE[enter as usize]; self.chunk_size += 1; @@ -183,7 +185,8 @@ impl Chunker { return pos; } - idx = self.chunk_size % CA_CHUNKER_WINDOW_SIZE; + //idx = self.chunk_size % CA_CHUNKER_WINDOW_SIZE; + idx = self.chunk_size & 0x3f; //idx += 1; if idx >= CA_CHUNKER_WINDOW_SIZE { idx = 0 }; } @@ -191,7 +194,7 @@ impl Chunker { } // fast implementation avoiding modulo - #[inline(always)] + // #[inline(always)] fn shall_break(&self) -> bool { if self.chunk_size >= self.chunk_size_max { return true; }