~mht/cmr

7d2b8249c68d3a388cef1026afe2ff32e563cdce — Martin Hafskjold Thoresen 3 years ago 25287db
Set the THRESHOLD value to something more towards the average wrt perf.
4 files changed, 24 insertions(+), 21 deletions(-)

M benchmarks/src/main.rs
M extern-benchmarks/src/main.rs
M src/alloc.rs
M src/signalvec.rs
M benchmarks/src/main.rs => benchmarks/src/main.rs +12 -9
@@ 457,8 457,11 @@ fn hashmap_80_10_10(num_threads: usize) {
        cmr::thread_activate();
        *l = gen_hm_80_10_10(10_000_000);
    });
    b.with_global_state(move |g| for i in 0..(1_000_000 / num_threads as u64) {
        g.hashmap.insert(i, i);
    b.with_global_state(move |s| {
        let mut rng = rand::thread_rng();
        for i in 0..(1_000_000 / num_threads as u64) {
            s.hashmap.insert(rng.gen(), i);
        }
    });
    let res = b.run_for(duration(), func);
    b.with_local_state(|_| cmr::thread_deactivate());


@@ 488,13 491,13 @@ fn main() {
        S!(hashmap_remove),
        S!(hashmap_80_10_10),

        S!(queue_push),
        S!(queue_pop),
        S!(queue_5050),

        S!(stack_push),
        S!(stack_pop),
        S!(stack_5050),
        // S!(queue_push),
        // S!(queue_pop),
        // S!(queue_5050),
 
        // S!(stack_push),
        // S!(stack_pop),
        // S!(stack_5050),
    ];

    let mut threads = args.get_integers("threads");

M extern-benchmarks/src/main.rs => extern-benchmarks/src/main.rs +6 -6
@@ 694,16 694,16 @@ fn main() {
        S!(std_hashmap_contains),
        S!(std_hashmap_remove),
        S!(std_hashmap_80_10_10),
        S!(std_queue_push),
        S!(std_queue_pop),
        S!(std_queue_5050),
        // S!(std_queue_push),
        // S!(std_queue_pop),
        // S!(std_queue_5050),
        S!(cb_hashmap_insert),
        S!(cb_hashmap_contains),
        S!(cb_hashmap_remove),
        S!(cb_hashmap_80_10_10),
        S!(cb_queue_push),
        S!(cb_queue_pop),
        S!(cb_queue_5050),
        // S!(cb_queue_push),
        // S!(cb_queue_pop),
        // S!(cb_queue_5050),
        S!(cbo_hashmap_insert),
        S!(cbo_hashmap_contains),
        S!(cbo_hashmap_remove),

M src/alloc.rs => src/alloc.rs +1 -1
@@ 58,7 58,7 @@ const THRESHOLD: usize = 512 * 1024;
                  feature = "threshold_16", feature = "threshold_32",
                  feature = "threshold_64", feature = "threshold_128",
                  feature = "threshold_256", feature = "threshold_512")))]
const THRESHOLD: usize = 1024 * 1024;
const THRESHOLD: usize = 1024 * 32;




M src/signalvec.rs => src/signalvec.rs +5 -5
@@ 14,7 14,7 @@
use std::alloc::{Alloc, Global};
use std::raw::TraitObject;
use std::sync::atomic::AtomicUsize;
use std::sync::atomic::Ordering::Relaxed;
use std::sync::atomic::Ordering::SeqCst;

type T = TraitObject;



@@ 64,13 64,13 @@ impl SignalVec {
            self.cap = new_cap;
        }
        loop {
            let len = self.len.load(Relaxed);
            let len = self.len.load(SeqCst);
            unsafe {
                let p = self.ptr.offset(len as isize);
                ::std::ptr::copy(&t, p, 1);
            }
            // TODO: replace with fetch_add
            if self.len.compare_and_swap(len, len + 1, Relaxed) == len {
            if self.len.compare_and_swap(len, len + 1, SeqCst) == len {
                if let Some(ptr) = old_ptr {
                    unsafe {
                        let b = Box::from_raw(ptr);


@@ 87,12 87,12 @@ impl SignalVec {
    pub(crate) fn clear(&self) {
        let l = self.len();
        // super::without_reclamation(|| println!("[{:p}] signalvec::clear from {}", self as *const SignalVec, l));
        assert_eq!(self.len.compare_and_swap(l, 0, Relaxed), l);
        assert_eq!(self.len.compare_and_swap(l, 0, SeqCst), l);
    }

    /// Get the length of the vector.
    pub(crate) fn len(&self) -> usize {
        self.len.load(Relaxed)
        self.len.load(SeqCst)
    }

    /// Get the data as a slice.