-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue 210: Fast path hardening take 2 (#215)
* Reverts the basic fast path for u64 to be two folded multiplies. Signed-off-by: Tom Kaitchuck <[email protected]>
- Loading branch information
1 parent
e7481cd
commit 7778357
Showing
9 changed files
with
57 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "ahash" | ||
version = "0.8.8" | ||
version = "0.8.10" | ||
authors = ["Tom Kaitchuck <[email protected]>"] | ||
license = "MIT OR Apache-2.0" | ||
description = "A non-cryptographic hash function using AES-NI for high performance" | ||
|
@@ -100,6 +100,7 @@ rand = "0.8.5" | |
pcg-mwc = "0.2.1" | ||
serde_json = "1.0.59" | ||
hashbrown = "0.14.3" | ||
smallvec = "1.13.1" | ||
|
||
[package.metadata.docs.rs] | ||
rustc-args = ["-C", "target-feature=+aes"] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
use std::io::Error; | ||
use std::fs::File; | ||
use std::io::Write; | ||
use pcg_mwc::Mwc256XXA64; | ||
use ahash::RandomState; | ||
use std::io::BufWriter; | ||
use std::path::Path; | ||
use rand_core::SeedableRng; | ||
use rand::Rng; | ||
use std::time::Instant; | ||
|
||
|
||
fn main() -> Result<(), Error> { | ||
let mut r = Mwc256XXA64::seed_from_u64(0xe786_c22b_119c_1479); | ||
|
||
let path = Path::new("hash_output"); | ||
|
||
let mut file = BufWriter::new(File::create(path)?); | ||
let hasher = RandomState::with_seeds(r.gen(), r.gen(), r.gen(), r.gen()); | ||
let start = Instant::now(); | ||
let mut sum: u64 = 0; | ||
for i in 0..i32::MAX { | ||
let value = hasher.hash_one(i as u64); | ||
sum = sum.wrapping_add(value); | ||
let value: [u8; 8] = value.to_ne_bytes(); | ||
file.write_all(&value)?; | ||
} | ||
let elapsed = start.elapsed(); | ||
println!("Sum {} Elapsed time: {}", sum, elapsed.as_millis()); | ||
file.flush()?; | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters