src/backup/chunker.rs: use 64 byte chunker window size

This results in faster code.
This commit is contained in:
Dietmar Maurer 2019-02-19 12:27:37 +01:00
parent 9a3e869cf5
commit cd1598302a
1 changed files with 8 additions and 5 deletions

View File

@ -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; }