bastion-rs / numanji Goto Github PK
View Code? Open in Web Editor NEWLocal-affinity first NUMA-aware allocator with optional fallback.
Local-affinity first NUMA-aware allocator with optional fallback.
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.
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(); }
});
}
}
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.