I'm creating a latch-free concurrent HashMap
in Rust. The throughput curve looks as I would expect up to around 16 threads, at which point performance beings to drop.
Throughput (MOps/sec) vs. Num threads
I used a Google Cloud instance with 48 vCPUs and 200GB RAM. I tried enabling/disabling hyperthreading but it had no noticeable result.
Here's how I'm spawning the threads:
for i in 0..num_threads {
//clone the shared data structure
let ht = Arc::clone(&ht);
let handle = thread::spawn(move || {
for j in 0..adds_per_thread {
//randomly generate and add a (key, value)
let key = thread_rng().gen::<u32>();
let value = thread_rng().gen::<u32>();
ht.set_item(key, value);
}
});
handles.push(handle);
}
for handle in handles {
handle.join().unwrap();
}
I'm out of ideas; is my Rust code correct for multithreading?