wip
This commit is contained in:
parent
b1bd3525a1
commit
a2b1b7b726
|
@ -1,5 +1,2 @@
|
||||||
[workspace]
|
[workspace]
|
||||||
members = ["instant-distance", "instant-distance-py"]
|
members = ["instant-distance", "instant-distance-py"]
|
||||||
|
|
||||||
[profile.bench]
|
|
||||||
debug = true
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ num_cpus = "1.13"
|
||||||
ordered-float = "2.0"
|
ordered-float = "2.0"
|
||||||
parking_lot = "0.11"
|
parking_lot = "0.11"
|
||||||
rand = { version = "0.8", features = ["small_rng"] }
|
rand = { version = "0.8", features = ["small_rng"] }
|
||||||
rayon = "1.5"
|
#rayon = "1.5"
|
||||||
serde = { version = "1.0.118", features = ["derive"], optional = true }
|
serde = { version = "1.0.118", features = ["derive"], optional = true }
|
||||||
serde-big-array = { version = "0.3.1", optional = true }
|
serde-big-array = { version = "0.3.1", optional = true }
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use bencher::{benchmark_group, benchmark_main, Bencher};
|
use bencher::{benchmark_group, benchmark_main, Bencher};
|
||||||
use rand::rngs::{StdRng, ThreadRng};
|
use rand::rngs::StdRng; //, ThreadRng};
|
||||||
use rand::{Rng, SeedableRng};
|
use rand::{Rng, SeedableRng};
|
||||||
|
|
||||||
use instant_distance::Builder;
|
use instant_distance::Builder;
|
||||||
|
@ -8,14 +8,18 @@ benchmark_main!(benches);
|
||||||
benchmark_group!(benches, build_heuristic);
|
benchmark_group!(benches, build_heuristic);
|
||||||
|
|
||||||
fn build_heuristic(bench: &mut Bencher) {
|
fn build_heuristic(bench: &mut Bencher) {
|
||||||
let seed = ThreadRng::default().gen::<u64>();
|
//let seed = dbg!(ThreadRng::default().gen::<u64>());
|
||||||
let mut rng = StdRng::seed_from_u64(seed);
|
let mut rng = StdRng::seed_from_u64(11823281459843198809); //seed);
|
||||||
let points = (0..1024)
|
let points = (0..512)
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|_| Point(rng.gen(), rng.gen()))
|
.map(|_| Point(rng.gen(), rng.gen()))
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
bench.iter(|| Builder::default().seed(seed).build_hnsw(points.clone()))
|
bench.iter(|| {
|
||||||
|
Builder::default()
|
||||||
|
.seed(11823281459843198809)
|
||||||
|
.build_hnsw(points.clone())
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -10,7 +10,7 @@ use ordered_float::OrderedFloat;
|
||||||
use parking_lot::{Mutex, RwLock};
|
use parking_lot::{Mutex, RwLock};
|
||||||
use rand::rngs::SmallRng;
|
use rand::rngs::SmallRng;
|
||||||
use rand::{Rng, SeedableRng};
|
use rand::{Rng, SeedableRng};
|
||||||
use rayon::iter::{IndexedParallelIterator, IntoParallelIterator, ParallelIterator};
|
//use rayon::iter::{IndexedParallelIterator, IntoParallelIterator, ParallelIterator};
|
||||||
#[cfg(feature = "serde")]
|
#[cfg(feature = "serde")]
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
@ -291,7 +291,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
let end = range.end;
|
let end = range.end;
|
||||||
nodes[range].into_par_iter().for_each(|(_, pid)| {
|
nodes[range].into_iter().for_each(|(_, pid)| {
|
||||||
let node = zero.as_slice()[*pid].write();
|
let node = zero.as_slice()[*pid].write();
|
||||||
let (mut search, mut insertion) = pool.pop();
|
let (mut search, mut insertion) = pool.pop();
|
||||||
let point = &points.as_slice()[*pid];
|
let point = &points.as_slice()[*pid];
|
||||||
|
@ -337,11 +337,10 @@ where
|
||||||
// For layers above the zero layer, make a copy of the current state of the zero layer
|
// For layers above the zero layer, make a copy of the current state of the zero layer
|
||||||
// with `nearest` truncated to `M` elements.
|
// with `nearest` truncated to `M` elements.
|
||||||
if !layer.is_zero() {
|
if !layer.is_zero() {
|
||||||
let mut upper = Vec::new();
|
let upper = (&zero[..end])
|
||||||
(&zero[..end])
|
.into_iter()
|
||||||
.into_par_iter()
|
|
||||||
.map(|zero| UpperNode::from_zero(&zero.read()))
|
.map(|zero| UpperNode::from_zero(&zero.read()))
|
||||||
.collect_into_vec(&mut upper);
|
.collect();
|
||||||
layers[layer.0 - 1] = upper;
|
layers[layer.0 - 1] = upper;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue