diff --git a/comparison/benchmark_result.txt b/comparison/benchmark_result.txt new file mode 100644 index 0000000..e13116a --- /dev/null +++ b/comparison/benchmark_result.txt @@ -0,0 +1,70 @@ + +running 60 tests +test bench32::xxhash32_0_byte ... bench: 7 ns/iter (+/- 1) +test bench32::xxhash32_1024_byte ... bench: 2,147 ns/iter (+/- 370) = 7154 MB/s +test bench32::xxhash32_128_byte ... bench: 289 ns/iter (+/- 52) = 6643 MB/s +test bench32::xxhash32_16_byte ... bench: 37 ns/iter (+/- 5) = 6486 MB/s +test bench32::xxhash32_1_byte ... bench: 23 ns/iter (+/- 2) = 652 MB/s +test bench32::xxhash32_256_byte ... bench: 521 ns/iter (+/- 52) = 7370 MB/s +test bench32::xxhash32_32_byte ... bench: 70 ns/iter (+/- 10) = 6857 MB/s +test bench32::xxhash32_4_byte ... bench: 22 ns/iter (+/- 1) = 2727 MB/s +test bench32::xxhash32_512_byte ... bench: 1,028 ns/iter (+/- 296) = 7470 MB/s +test bench32::xxhash32_megabyte ... bench: 2,168,024 ns/iter (+/- 531,375) = 7254 MB/s +test bench32::zerohash32_0_byte ... bench: 2 ns/iter (+/- 0) +test bench32::zerohash32_1024_byte ... bench: 2,039 ns/iter (+/- 194) = 7533 MB/s +test bench32::zerohash32_128_byte ... bench: 261 ns/iter (+/- 8) = 7356 MB/s +test bench32::zerohash32_16_byte ... bench: 37 ns/iter (+/- 0) = 6486 MB/s +test bench32::zerohash32_1_byte ... bench: 7 ns/iter (+/- 1) = 2142 MB/s +test bench32::zerohash32_256_byte ... bench: 521 ns/iter (+/- 62) = 7370 MB/s +test bench32::zerohash32_32_byte ... bench: 71 ns/iter (+/- 9) = 6760 MB/s +test bench32::zerohash32_4_byte ... bench: 11 ns/iter (+/- 0) = 5454 MB/s +test bench32::zerohash32_512_byte ... bench: 1,030 ns/iter (+/- 59) = 7456 MB/s +test bench32::zerohash32_megabyte ... bench: 2,145,970 ns/iter (+/- 164,592) = 7329 MB/s +test bench64::fnvhash_0_byte ... bench: 0 ns/iter (+/- 0) +test bench64::fnvhash_1024_byte ... bench: 33,502 ns/iter (+/- 2,556) = 947 MB/s +test bench64::fnvhash_128_byte ... bench: 4,187 ns/iter (+/- 242) = 947 MB/s +test bench64::fnvhash_16_byte ... bench: 523 ns/iter (+/- 43) = 948 MB/s +test bench64::fnvhash_1_byte ... bench: 32 ns/iter (+/- 0) = 968 MB/s +test bench64::fnvhash_256_byte ... bench: 8,375 ns/iter (+/- 383) = 947 MB/s +test bench64::fnvhash_4_byte ... bench: 130 ns/iter (+/- 6) = 953 MB/s +test bench64::fnvhash_512_byte ... bench: 16,750 ns/iter (+/- 910) = 947 MB/s +test bench64::fnvhash_64_byte ... bench: 2,093 ns/iter (+/- 101) = 947 MB/s +test bench64::fnvhash_megabyte ... bench: 35,113,176 ns/iter (+/- 1,149,847) = 925 MB/s +test bench64::siphash_0_byte ... bench: 9 ns/iter (+/- 0) +test bench64::siphash_1024_byte ... bench: 13,503 ns/iter (+/- 748) = 2350 MB/s +test bench64::siphash_128_byte ... bench: 1,698 ns/iter (+/- 143) = 2336 MB/s +test bench64::siphash_16_byte ... bench: 224 ns/iter (+/- 19) = 2214 MB/s +test bench64::siphash_1_byte ... bench: 25 ns/iter (+/- 7) = 1240 MB/s +test bench64::siphash_256_byte ... bench: 3,423 ns/iter (+/- 179) = 2318 MB/s +test bench64::siphash_4_byte ... bench: 63 ns/iter (+/- 12) = 1968 MB/s +test bench64::siphash_512_byte ... bench: 6,811 ns/iter (+/- 366) = 2330 MB/s +test bench64::siphash_64_byte ... bench: 856 ns/iter (+/- 49) = 2317 MB/s +test bench64::siphash_megabyte ... bench: 14,323,033 ns/iter (+/- 1,883,569) = 2269 MB/s +test bench64::xxhash64_0_byte ... bench: 8 ns/iter (+/- 1) +test bench64::xxhash64_1024_byte ... bench: 2,110 ns/iter (+/- 149) = 15044 MB/s +test bench64::xxhash64_128_byte ... bench: 278 ns/iter (+/- 18) = 14273 MB/s +test bench64::xxhash64_16_byte ... bench: 49 ns/iter (+/- 7) = 10122 MB/s +test bench64::xxhash64_1_byte ... bench: 28 ns/iter (+/- 1) = 1107 MB/s +test bench64::xxhash64_256_byte ... bench: 540 ns/iter (+/- 142) = 14696 MB/s +test bench64::xxhash64_4_byte ... bench: 31 ns/iter (+/- 4) = 4000 MB/s +test bench64::xxhash64_512_byte ... bench: 1,067 ns/iter (+/- 102) = 14875 MB/s +test bench64::xxhash64_64_byte ... bench: 142 ns/iter (+/- 13) = 13971 MB/s +test bench64::xxhash64_megabyte ... bench: 2,533,382 ns/iter (+/- 172,558) = 12831 MB/s +test bench64::zerohash64_0_byte ... bench: 4 ns/iter (+/- 0) +test bench64::zerohash64_1024_byte ... bench: 2,112 ns/iter (+/- 184) = 15030 MB/s +test bench64::zerohash64_128_byte ... bench: 274 ns/iter (+/- 42) = 14481 MB/s +test bench64::zerohash64_16_byte ... bench: 42 ns/iter (+/- 4) = 11809 MB/s +test bench64::zerohash64_1_byte ... bench: 8 ns/iter (+/- 0) = 3875 MB/s +test bench64::zerohash64_256_byte ... bench: 540 ns/iter (+/- 54) = 14696 MB/s +test bench64::zerohash64_4_byte ... bench: 20 ns/iter (+/- 5) = 6200 MB/s +test bench64::zerohash64_512_byte ... bench: 1,058 ns/iter (+/- 38) = 15001 MB/s +test bench64::zerohash64_64_byte ... bench: 144 ns/iter (+/- 6) = 13777 MB/s +test bench64::zerohash64_megabyte ... bench: 2,610,637 ns/iter (+/- 99,186) = 12451 MB/s + +test result: ok. 0 passed; 0 failed; 0 ignored; 60 measured; 0 filtered out + + +running 0 tests + +test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out + diff --git a/comparison/result.txt b/comparison/result.txt deleted file mode 100644 index 9223480..0000000 --- a/comparison/result.txt +++ /dev/null @@ -1,70 +0,0 @@ - -running 60 tests -test bench32::xxhash32_0_byte ... bench: 7 ns/iter (+/- 3) -test bench32::xxhash32_1024_byte ... bench: 143 ns/iter (+/- 14) = 7160 MB/s -test bench32::xxhash32_128_byte ... bench: 22 ns/iter (+/- 2) = 5818 MB/s -test bench32::xxhash32_16_byte ... bench: 9 ns/iter (+/- 1) = 1777 MB/s -test bench32::xxhash32_1_byte ... bench: 11 ns/iter (+/- 2) = 90 MB/s -test bench32::xxhash32_256_byte ... bench: 44 ns/iter (+/- 6) = 5818 MB/s -test bench32::xxhash32_32_byte ... bench: 12 ns/iter (+/- 2) = 2666 MB/s -test bench32::xxhash32_4_byte ... bench: 14 ns/iter (+/- 1) = 285 MB/s -test bench32::xxhash32_512_byte ... bench: 79 ns/iter (+/- 23) = 6481 MB/s -test bench32::xxhash32_megabyte ... bench: 1,161,021 ns/iter (+/- 72,328) = 7225 MB/s -test bench32::zerohash32_0_byte ... bench: 2 ns/iter (+/- 0) -test bench32::zerohash32_1024_byte ... bench: 148 ns/iter (+/- 15) = 6918 MB/s -test bench32::zerohash32_128_byte ... bench: 22 ns/iter (+/- 2) = 5818 MB/s -test bench32::zerohash32_16_byte ... bench: 5 ns/iter (+/- 0) = 3200 MB/s -test bench32::zerohash32_1_byte ... bench: 3 ns/iter (+/- 1) = 333 MB/s -test bench32::zerohash32_256_byte ... bench: 44 ns/iter (+/- 5) = 5818 MB/s -test bench32::zerohash32_32_byte ... bench: 7 ns/iter (+/- 0) = 4571 MB/s -test bench32::zerohash32_4_byte ... bench: 3 ns/iter (+/- 0) = 1333 MB/s -test bench32::zerohash32_512_byte ... bench: 78 ns/iter (+/- 6) = 6564 MB/s -test bench32::zerohash32_megabyte ... bench: 1,219,860 ns/iter (+/- 129,197) = 6876 MB/s -test bench64::fnvhash_0_byte ... bench: 0 ns/iter (+/- 0) -test bench64::fnvhash_1024_byte ... bench: 1,080 ns/iter (+/- 51) = 948 MB/s -test bench64::fnvhash_128_byte ... bench: 135 ns/iter (+/- 6) = 948 MB/s -test bench64::fnvhash_16_byte ... bench: 16 ns/iter (+/- 0) = 1000 MB/s -test bench64::fnvhash_1_byte ... bench: 1 ns/iter (+/- 0) = 1000 MB/s -test bench64::fnvhash_256_byte ... bench: 270 ns/iter (+/- 8) = 948 MB/s -test bench64::fnvhash_4_byte ... bench: 4 ns/iter (+/- 0) = 1000 MB/s -test bench64::fnvhash_512_byte ... bench: 542 ns/iter (+/- 31) = 944 MB/s -test bench64::fnvhash_64_byte ... bench: 67 ns/iter (+/- 3) = 955 MB/s -test bench64::fnvhash_megabyte ... bench: 17,902,538 ns/iter (+/- 1,614,226) = 937 MB/s -test bench64::siphash_0_byte ... bench: 9 ns/iter (+/- 0) -test bench64::siphash_1024_byte ... bench: 457 ns/iter (+/- 50) = 2240 MB/s -test bench64::siphash_128_byte ... bench: 64 ns/iter (+/- 6) = 2000 MB/s -test bench64::siphash_16_byte ... bench: 16 ns/iter (+/- 0) = 1000 MB/s -test bench64::siphash_1_byte ... bench: 11 ns/iter (+/- 1) = 90 MB/s -test bench64::siphash_256_byte ... bench: 122 ns/iter (+/- 21) = 2098 MB/s -test bench64::siphash_4_byte ... bench: 11 ns/iter (+/- 0) = 363 MB/s -test bench64::siphash_512_byte ... bench: 246 ns/iter (+/- 77) = 2081 MB/s -test bench64::siphash_64_byte ... bench: 40 ns/iter (+/- 5) = 1600 MB/s -test bench64::siphash_megabyte ... bench: 7,244,767 ns/iter (+/- 862,610) = 2315 MB/s -test bench64::xxhash64_0_byte ... bench: 8 ns/iter (+/- 0) -test bench64::xxhash64_1024_byte ... bench: 84 ns/iter (+/- 9) = 12190 MB/s -test bench64::xxhash64_128_byte ... bench: 23 ns/iter (+/- 5) = 5565 MB/s -test bench64::xxhash64_16_byte ... bench: 17 ns/iter (+/- 2) = 941 MB/s -test bench64::xxhash64_1_byte ... bench: 18 ns/iter (+/- 2) = 55 MB/s -test bench64::xxhash64_256_byte ... bench: 31 ns/iter (+/- 3) = 8258 MB/s -test bench64::xxhash64_4_byte ... bench: 17 ns/iter (+/- 1) = 235 MB/s -test bench64::xxhash64_512_byte ... bench: 46 ns/iter (+/- 13) = 11130 MB/s -test bench64::xxhash64_64_byte ... bench: 17 ns/iter (+/- 0) = 3764 MB/s -test bench64::xxhash64_megabyte ... bench: 1,310,591 ns/iter (+/- 62,296) = 12801 MB/s -test bench64::zerohash64_0_byte ... bench: 3 ns/iter (+/- 0) -test bench64::zerohash64_1024_byte ... bench: 77 ns/iter (+/- 4) = 13298 MB/s -test bench64::zerohash64_128_byte ... bench: 17 ns/iter (+/- 1) = 7529 MB/s -test bench64::zerohash64_16_byte ... bench: 6 ns/iter (+/- 2) = 2666 MB/s -test bench64::zerohash64_1_byte ... bench: 5 ns/iter (+/- 1) = 200 MB/s -test bench64::zerohash64_256_byte ... bench: 29 ns/iter (+/- 10) = 8827 MB/s -test bench64::zerohash64_4_byte ... bench: 5 ns/iter (+/- 1) = 800 MB/s -test bench64::zerohash64_512_byte ... bench: 43 ns/iter (+/- 3) = 11906 MB/s -test bench64::zerohash64_64_byte ... bench: 13 ns/iter (+/- 2) = 4923 MB/s -test bench64::zerohash64_megabyte ... bench: 1,361,600 ns/iter (+/- 396,960) = 12321 MB/s - -test result: ok. 0 passed; 0 failed; 0 ignored; 60 measured; 0 filtered out - - -running 0 tests - -test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out - diff --git a/comparison/src/bench32.rs b/comparison/src/bench32.rs index ff83753..2d1f27f 100644 --- a/comparison/src/bench32.rs +++ b/comparison/src/bench32.rs @@ -4,16 +4,17 @@ use test; use twox_hash::XxHash32; use zero_xxhash::hash32::xxhash32; -const size_0: usize = 0; -const size_1: usize = 1; -const size_4: usize = 4; -const size_16: usize = 16; -const size_32: usize = 32; -const size_128: usize = 128; -const size_256: usize = 256; -const size_512: usize = 512; -const size_1024: usize = 1024; -const size_mega: usize = 1024 * 1024 * 8; // 8MB +const degree: usize = 15; +const size_0: usize = 0 * degree; +const size_1: usize = 1 * degree; +const size_4: usize = 4 * degree; +const size_16: usize = 16 * degree; +const size_32: usize = 32 * degree; +const size_128: usize = 128 * degree; +const size_256: usize = 256 * degree; +const size_512: usize = 512 * degree; +const size_1024: usize = 1024 * degree; +const size_mega: usize = 1024 * 1024 * degree; fn hasher_bench(b: &mut test::Bencher, mut hasher: H, len: usize) where diff --git a/comparison/src/bench64.rs b/comparison/src/bench64.rs index 8f94286..f48925d 100644 --- a/comparison/src/bench64.rs +++ b/comparison/src/bench64.rs @@ -5,16 +5,17 @@ use test; use twox_hash::XxHash; use zero_xxhash::hash64::xxhash64; -const size_0: usize = 0; -const size_1: usize = 1; -const size_4: usize = 4; -const size_16: usize = 16; -const size_64: usize = 64; -const size_128: usize = 128; -const size_256: usize = 256; -const size_512: usize = 512; -const size_1024: usize = 1024; -const size_mega: usize = 1024 * 1024 * 16; // 16MB +const degree: usize = 31; +const size_0: usize = 0 * degree; +const size_1: usize = 1 * degree; +const size_4: usize = 4 * degree; +const size_16: usize = 16 * degree; +const size_64: usize = 64 * degree; +const size_128: usize = 128 * degree; +const size_256: usize = 256 * degree; +const size_512: usize = 512 * degree; +const size_1024: usize = 1024 * degree; +const size_mega: usize = 1024 * 1024 * degree; fn hasher_bench(b: &mut test::Bencher, mut hasher: H, len: usize) where diff --git a/src/hash32.rs b/src/hash32.rs index c563d45..b0a9e82 100644 --- a/src/hash32.rs +++ b/src/hash32.rs @@ -31,27 +31,73 @@ fn xxh32_round(acc: u32, input: u32) -> u32 { pub fn xxhash32(data: &[u8], seed: u32) -> u32 { let mut h32: u32; let n = data.len(); - let limit = n - (n & 15); + let mut limit = n - (n & 15); + let mut ptr = data; let mut acc1; let mut acc2; let mut acc3; let mut acc4; - let mut t = 0; - if n >= 16 { acc1 = seed.wrapping_add(PRIME32_1).wrapping_add(PRIME32_2); acc2 = seed.wrapping_add(PRIME32_2); acc3 = seed; acc4 = seed.wrapping_sub(PRIME32_1); - while t < limit { - acc1 = xxh32_round(acc1, read_u32(&data[t..])); - acc2 = xxh32_round(acc2, read_u32(&data[t + 4..])); - acc3 = xxh32_round(acc3, read_u32(&data[t + 8..])); - acc4 = xxh32_round(acc4, read_u32(&data[t + 12..])); - t += 16; + if limit >> 6 > 0 { + for _i in 0..limit >> 6 { + acc1 = xxh32_round(acc1, read_u32(&ptr)); + acc2 = xxh32_round(acc2, read_u32(&ptr[4..8])); + acc3 = xxh32_round(acc3, read_u32(&ptr[8..12])); + acc4 = xxh32_round(acc4, read_u32(&ptr[12..16])); + + acc1 = xxh32_round(acc1, read_u32(&ptr[16..20])); + acc2 = xxh32_round(acc2, read_u32(&ptr[20..24])); + acc3 = xxh32_round(acc3, read_u32(&ptr[24..28])); + acc4 = xxh32_round(acc4, read_u32(&ptr[28..32])); + + acc1 = xxh32_round(acc1, read_u32(&ptr[32..36])); + acc2 = xxh32_round(acc2, read_u32(&ptr[36..40])); + acc3 = xxh32_round(acc3, read_u32(&ptr[40..44])); + acc4 = xxh32_round(acc4, read_u32(&ptr[44..48])); + + acc1 = xxh32_round(acc1, read_u32(&ptr[48..52])); + acc2 = xxh32_round(acc2, read_u32(&ptr[52..56])); + acc3 = xxh32_round(acc3, read_u32(&ptr[56..60])); + acc4 = xxh32_round(acc4, read_u32(&ptr[60..64])); + + ptr = &ptr[64..]; + } + limit = limit & 63; + } + + if limit >> 5 > 0 { + for _i in 0..limit >> 5 { + acc1 = xxh32_round(acc1, read_u32(&ptr)); + acc2 = xxh32_round(acc2, read_u32(&ptr[4..8])); + acc3 = xxh32_round(acc3, read_u32(&ptr[8..12])); + acc4 = xxh32_round(acc4, read_u32(&ptr[12..16])); + + acc1 = xxh32_round(acc1, read_u32(&ptr[16..20])); + acc2 = xxh32_round(acc2, read_u32(&ptr[20..24])); + acc3 = xxh32_round(acc3, read_u32(&ptr[24..28])); + acc4 = xxh32_round(acc4, read_u32(&ptr[28..32])); + + ptr = &ptr[32..]; + } + limit = limit & 31; + } + + if limit >> 4 > 0 { + for _i in 0..limit >> 4 { + acc1 = xxh32_round(acc1, read_u32(&ptr)); + acc2 = xxh32_round(acc2, read_u32(&ptr[4..8])); + acc3 = xxh32_round(acc3, read_u32(&ptr[8..12])); + acc4 = xxh32_round(acc4, read_u32(&ptr[12..16])); + + ptr = &ptr[16..]; + } } h32 = acc1 @@ -63,10 +109,11 @@ pub fn xxhash32(data: &[u8], seed: u32) -> u32 { h32 = seed.wrapping_add(PRIME32_5); } + // add len to hash h32 = h32.wrapping_add(n as u32); // finalize - xxh32_finalize(&data[limit..], h32) + xxh32_finalize(&ptr, h32) } fn xxh32_finalize(data: &[u8], mut h32: u32) -> u32 { diff --git a/src/hash64.rs b/src/hash64.rs index da939c9..dca7f33 100644 --- a/src/hash64.rs +++ b/src/hash64.rs @@ -17,13 +17,13 @@ fn read_u64(data: &[u8]) -> u64 { } #[inline(always)] -fn avalanche64(inp: u64) -> u64 { - let mut h64 = inp ^ (inp >> 33); - h64 = h64.wrapping_mul(PRIME64_2); - h64 ^= h64 >> 29; - h64 = h64.wrapping_mul(PRIME64_3); - h64 ^= h64 >> 32; - h64 +fn avalanche64(mut inp: u64) -> u64 { + inp ^= inp >> 33; + inp = inp.wrapping_mul(PRIME64_2); + inp ^= inp >> 29; + inp = inp.wrapping_mul(PRIME64_3); + inp ^= inp >> 32; + inp } #[inline(always)] @@ -43,27 +43,73 @@ fn xxh64_merge_round(acc: u64, val: u64) -> u64 { pub fn xxhash64(data: &[u8], seed: u64) -> u64 { let mut h64: u64; let n = data.len(); - let limit = n - (n & 31); + let mut limit = n - (n & 31); + let mut ptr = data; let mut acc1; let mut acc2; let mut acc3; let mut acc4; - let mut t = 0; - if n >= 32 { acc1 = seed.wrapping_add(PRIME64_1).wrapping_add(PRIME64_2); acc2 = seed.wrapping_add(PRIME64_2); acc3 = seed; acc4 = seed.wrapping_sub(PRIME64_1); - while t < limit { - acc1 = xxh64_round(acc1, read_u64(&data[t..])); - acc2 = xxh64_round(acc2, read_u64(&data[t + 8..])); - acc3 = xxh64_round(acc3, read_u64(&data[t + 16..])); - acc4 = xxh64_round(acc4, read_u64(&data[t + 24..])); - t += 32; + if limit >> 7 > 0 { + for _i in 0..limit >> 7 { + acc1 = xxh64_round(acc1, read_u64(&ptr)); + acc2 = xxh64_round(acc2, read_u64(&ptr[8..16])); + acc3 = xxh64_round(acc3, read_u64(&ptr[16..24])); + acc4 = xxh64_round(acc4, read_u64(&ptr[24..32])); + + acc1 = xxh64_round(acc1, read_u64(&ptr[32..40])); + acc2 = xxh64_round(acc2, read_u64(&ptr[40..48])); + acc3 = xxh64_round(acc3, read_u64(&ptr[48..56])); + acc4 = xxh64_round(acc4, read_u64(&ptr[56..64])); + + acc1 = xxh64_round(acc1, read_u64(&ptr[64..72])); + acc2 = xxh64_round(acc2, read_u64(&ptr[72..80])); + acc3 = xxh64_round(acc3, read_u64(&ptr[80..88])); + acc4 = xxh64_round(acc4, read_u64(&ptr[88..96])); + + acc1 = xxh64_round(acc1, read_u64(&ptr[96..104])); + acc2 = xxh64_round(acc2, read_u64(&ptr[104..112])); + acc3 = xxh64_round(acc3, read_u64(&ptr[112..120])); + acc4 = xxh64_round(acc4, read_u64(&ptr[120..128])); + + ptr = &ptr[128..] + } + limit = limit & 127 + } + + if limit >> 6 > 0 { + for _i in 0..limit >> 6 { + acc1 = xxh64_round(acc1, read_u64(&ptr)); + acc2 = xxh64_round(acc2, read_u64(&ptr[8..16])); + acc3 = xxh64_round(acc3, read_u64(&ptr[16..24])); + acc4 = xxh64_round(acc4, read_u64(&ptr[24..32])); + + acc1 = xxh64_round(acc1, read_u64(&ptr[32..40])); + acc2 = xxh64_round(acc2, read_u64(&ptr[40..48])); + acc3 = xxh64_round(acc3, read_u64(&ptr[48..56])); + acc4 = xxh64_round(acc4, read_u64(&ptr[56..64])); + + ptr = &ptr[64..] + } + limit = limit & 63 + } + + if limit >> 5 > 0 { + for _i in 0..limit >> 5 { + acc1 = xxh64_round(acc1, read_u64(&ptr)); + acc2 = xxh64_round(acc2, read_u64(&ptr[8..16])); + acc3 = xxh64_round(acc3, read_u64(&ptr[16..24])); + acc4 = xxh64_round(acc4, read_u64(&ptr[24..32])); + + ptr = &ptr[32..]; + } } h64 = acc1 @@ -80,10 +126,11 @@ pub fn xxhash64(data: &[u8], seed: u64) -> u64 { h64 = seed.wrapping_add(PRIME64_5); } - h64 = h64.wrapping_add(data.len() as u64); + // add len to hash + h64 = h64.wrapping_add(n as u64); // finalize - xxh64_finalize(&data[limit..], h64) + xxh64_finalize(&ptr, h64) } fn xxh64_finalize(data: &[u8], mut h64: u64) -> u64 {