Giter Site home page Giter Site logo

numanji's People

Contributors

o0ignition0o avatar r3v2d0g avatar vertexclique avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

surechen smups

numanji's Issues

Is this project still activate?

Hi, just a friendly ping. Is numanji still activate?

I want a NUMA-aware allocator and I find this awesome project. But there seems to have some compile errors for a long time (from the last commit).

I tried for stable-1.50 and nightly-1.52.

failed with signal: 6, SIGABRT: process abort signal

memory allocation of 20 bytes failederror: process didn't exit successfully: `/home/schrodinger/CLionProject/malloc-bench/target/release/deps/malloc_bench-ab1f7987882c35d4 long_cons_then_map --bench` (signal: 6, SIGABRT: process abort signal)

Bench File:

enum ArcList<T> {
    Cons(T, Arc<Self>),
    Nil
}

impl<T> ArcList<T> {
    fn is_nil(&self) -> bool {
        match self {
            Nil => true,
            _ => false
        }
    }
}

impl<T : Debug> Debug for ArcList<T> {
    fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> {
        match self {
            Nil => Ok(()),
            Cons(e, t) if t.is_nil() => write!(f, "{:?}", e),
            Cons(e, t) => write!(f, "{:?}, {:?}", e, *(*t))
        }
    }
}
type Ptr<T> = Arc<ArcList<T>>;

fn cons<T>(t: T, list: Ptr<T>) -> Ptr<T> {
    Arc::new(Cons(t, list.clone()))
}

fn count_inner<T>(acc: usize, list: Ptr<T>) -> usize {
    match & *list {
        Nil => acc,
        Cons(_, t) => count_inner(acc + 1, t.clone())
    }
}

fn count<T>(list: Ptr<T>) -> usize {
    count_inner(0, list)
}

fn to_vec_inner<T : Clone>(mut acc: Vec<T>, list: Ptr<T>) -> Vec<T> {
    match & *list {
        Nil => acc,
        Cons(x, t) => {
            acc.push(x.clone());
            to_vec_inner(acc, t.clone())
        }
    }
}

fn to_vec<T : Clone>(list: Ptr<T>) -> Vec<T> {
    to_vec_inner(Vec::new(), list)
}

fn map<T, U>(f: fn(&T) -> U, list: Ptr<T>) -> Ptr<U> {
    match &* list {
        Nil => Arc::new(Nil),
        Cons(x, t) => Arc::new(Cons(f(x), map(f, t.clone())))
    }
}


#[cfg(test)]
mod list_bench {
    use std::sync::Arc;
    use super::*;
    use rand::Rng;
    const SCALE: usize = 10000;
    #[bench]
    fn long_cons_then_count(bencher: &mut Bencher) {
        bencher.iter(|| {
            let mut rng = rand::thread_rng();
            let mut a = Arc::new(Nil);
            for _ in 0..SCALE {
                a = cons(rng.gen::<usize>(), a);
            }
            assert_eq!(count(a), SCALE)
        });
    }

    #[bench]
    fn long_cons_then_map(bencher: &mut Bencher) {
        bencher.iter(|| {
            let mut rng = rand::thread_rng();
            let mut a = Arc::new(Nil);
            for _ in 0..SCALE {
                a = cons(rng.gen::<usize>(), a);
            }
            map(|x| x + 1, a);
        });
    }

    #[bench]
    fn long_cons_then_count_in_multi_threads(bencher: &mut Bencher) {
        bencher.iter(|| {
            let mut handles = Vec::new();
            for _ in 0..6 {
                handles.push(std::thread::Builder::new()
                    .stack_size(512 * 1024 * 1024)
                    .spawn(|| {
                    let mut rng = rand::thread_rng();
                    let mut a = Arc::new(Nil);
                    for _ in 0..SCALE {
                        a = cons(rng.gen::<usize>(), a);
                    }
                    assert_eq!(count(a), SCALE)
                }).unwrap());
            }
            for i in handles {i.join().unwrap(); }
        });
    }

    #[bench]
    fn long_cons_then_map_across_multi_threads(bencher: &mut Bencher) {
        bencher.iter(|| {
            let mut rng = rand::thread_rng();
            let mut handles = Vec::new();
            let mut a = Arc::new(Nil);
            for _ in 0..SCALE {
                a = cons(rng.gen::<usize>(), a);
            }
            for _ in 0..6 {
                let a = a.clone();
                handles.push(std::thread::Builder::new()
                    .stack_size(512 * 1024 * 1024)
                    .spawn(move || {
                        map(|x| x + 1, a);
                    }).unwrap());
            }
            for i in handles {i.join().unwrap(); }
        });
    }
}

Does not compile on stable nor nightly

Compiling this crate generates build errors due to renamed items in the std allocator and incorrect (deprecated or non-existent) feature flags.

See cargo build output for details

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.