~mht/cmr

7c61834a0fa0c6eeb4f4164f68c479d6e67d3118 — Martin Hafskjold Thoresen 3 years ago 5b58557
Write comments.
3 files changed, 10 insertions(+), 1 deletions(-)

M benchmarks/src/main.rs
M src/alloc.rs
M src/lib.rs
M benchmarks/src/main.rs => benchmarks/src/main.rs +1 -0
@@ 463,6 463,7 @@ fn hashmap_80_10_10(num_threads: usize) {
            s.hashmap.insert(rng.gen(), i);
        }
    });
    b.sync();
    let res = b.run_for(duration(), func);
    b.with_local_state(|_| cmr::thread_deactivate());
    println!(

M src/alloc.rs => src/alloc.rs +7 -0
@@ 256,6 256,13 @@ thread_local! {
    /// `cmr::THREAD_BOOLS`; This is an array that contains a single bool for
    /// each thread in the system, which signals whether that thread is
    /// currently allocating or not.
    ///
    /// We are using this instead of some other lock for two reasons: we need to
    /// make sure that certain operations does not allocate anything, since we
    /// are using it inside the allocator. In addition we need to support
    /// recursive calls, since we want to be able to eg. allocate while holdnig
    /// `SOME_LOCK`. `::std::sync::RwLock` does not support the latter, and
    /// `parking_lot::RwLock` does not support the former.
    pub(crate) static SOME_LOCK_MARKER: AtomicPtr<AtomicBool> =
        AtomicPtr::new(::std::ptr::null_mut());
}

M src/lib.rs => src/lib.rs +2 -1
@@ 355,13 355,13 @@ fn consolidate() -> Option<usize> {
    // Make sure that no thread have taken the internal malloc lock, so that we control who can
    // alloc. This also ensures that any thread in `without_reclamation` will complete its
    // operation without us signaling them.
    // let alloc_lock = alloc::ALLOC_LOCK.lock();
    let alloc_lock = alloc::SOME_LOCK.lock();
    assert!(
        alloc_lock.is_some(),
        "Somehow, we are the reclaimer in the middle of allocating??"
    );

    // TODO: We might not need this anymore ???
    let _stdout = ::std::io::stdout();
    let mut _stdout_lock = _stdout.lock();
    let _stderr = ::std::io::stderr();


@@ 499,6 499,7 @@ fn consolidate() -> Option<usize> {
        }
        pid => pid,
    };

    compiler_fence(SeqCst);
    drop(alloc_lock);