-
Notifications
You must be signed in to change notification settings - Fork 3
Use faster hash map implementation #1
base: master
Are you sure you want to change the base?
Conversation
src/main.rs
Outdated
@@ -21,6 +22,7 @@ fn main() { | |||
|
|||
// fp p<=0.001, 32GiB, k=2 | |||
let filter = bloom_t1(&T1_INVERSE); | |||
println!("[timing]: bloom_t1 {} milliseconds", total.elapsed().as_millis()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will break entirely if we don't have the unstable feature enabled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated it to use seconds/milliseconds correctly:
cargo +nightly run --features numa --release | grep Completed
[bloom_t1] Completed 4294967296 in 120 sec
[t2_map] Completed 4294967296 in 12 sec
[final_sieve] Completed in 1 sec
Completed in: 134 sec, primes found: 55
cargo +nightly run --features numa,unstable --release | grep Completed
[bloom_t1] Completed 4294967296 in 13813 ms
[t2_map] Completed 4294967296 in 6179 ms
[final_sieve] Completed in 1923 ms
Completed in: 21945 ms, primes found: 55
src/numa_threadpool.rs
Outdated
@@ -49,7 +49,7 @@ pub use self::numa::*; | |||
mod numa { | |||
extern crate nix; | |||
|
|||
use libc::{c_char, c_uint, c_int, c_ulong}; | |||
use numa_threadpool::numa::nix::libc::{c_char, c_uint, c_int, c_ulong}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't quite understand why removing the unstable flag caused the build to fail for missing imports, the compile suggested this and it fixed it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's because lib.rs has a #[cfg(feature="unstable")]
mark on the libc extern crate (and I think cargo conditional-depends on it as well)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To fix this:
- Remove
optional=true
from the libc clause in Cargo.toml - Remove
"libc"
from the feature definitions in Cargo.toml - Add an
extern crate libc;
to src/lib.rs - or update to Rust 2018 :)
Fixed a typo
Issue #, if available:
N/A
Description of changes:
While reading this blog post about how hash maps and Google's SwissTable work I was curious to see it's impact to this code. Hashbrown is a rust implementation of SwissTable. There is a discussion about using this in the standard rust hash map in rust-lang/rust#55514 but until that get migrated this saves us ~3 seconds. It only affects the final sieve:
Standard:
hashbrown:
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.