Skip to content

Commit

Permalink
docs: update TODO items
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianWoelki committed Aug 22, 2024
1 parent 4165538 commit 393f7f1
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

## Experiments

- [ ] Having a timeout (5min) that terminates the current run

- [ ] Single-Threaded experiments
- [ ] Using PCA
- [ ] Using t-sne
Expand Down
2 changes: 1 addition & 1 deletion src/benchmark/metrics.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{collections::HashSet, time::Duration};
use std::time::Duration;

use crate::data::SparseVector;

Expand Down
21 changes: 15 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ use rand::{thread_rng, Rng};
use sysinfo::{Pid, System};

use clap::Parser;
use index::{annoy::AnnoyIndex, linscan::LinScanIndex, DistanceMetric, IndexType, SparseIndex};
use index::{
annoy::AnnoyIndex, hnsw::HNSWIndex, linscan::LinScanIndex, DistanceMetric, IndexType,
SparseIndex,
};
use ordered_float::OrderedFloat;
use rayon::iter::{IntoParallelRefIterator, ParallelIterator};

Expand Down Expand Up @@ -156,7 +159,7 @@ async fn main() {
let distance_metric = DistanceMetric::Cosine;
let benchmark_config = BenchmarkConfig::new(
(dimensions, 10000, dimensions),
(amount, 1000, amount),
(amount, 2000, amount),
(0.0, 1.0),
0.90,
distance_metric,
Expand All @@ -177,8 +180,10 @@ async fn main() {
println!("...finished generating data");

let total_index_start = Instant::now();
let seed = thread_rng().gen_range(0..10000);
let mut index = HNSWIndex::new(0.5, 16, 200, 200, distance_metric, seed);
// let mut index = LinScanIndex::new(distance_metric);
let mut index = AnnoyIndex::new(20, 20, 40, distance_metric);
// let mut index = AnnoyIndex::new(20, 20, 40, distance_metric);

for vector in &vectors {
index.add_vector_before_build(&vector);
Expand Down Expand Up @@ -256,7 +261,7 @@ async fn main() {
println!("...finished\n");

// Benchmark for measuring removing a vector from the index.
println!("Measuring the removal of vectors to the index...");
println!("Measuring the removal of vectors from the index...");
let mut total_remove_duration = Duration::new(0, 0);
for _ in 0..added_vectors.len() {
let remove_vector_start = Instant::now();
Expand All @@ -277,7 +282,7 @@ async fn main() {
save_index(
&dir_path,
format!("annoy_serial_{}", amount), // TODO: Modify to support parallel
IndexType::Annoy(index),
IndexType::HNSW(index),
)
});

Expand All @@ -289,7 +294,7 @@ async fn main() {

// Benchmark loading time for index.
let (_, total_load_duration) = measure_time!({
AnnoyIndex::load_index(&saved_file);
HNSWIndex::load_index(&saved_file);
});

let queries_per_second = calculate_queries_per_second(search_report.execution_time);
Expand All @@ -316,6 +321,10 @@ async fn main() {
index_logger.add_record(new_index_benchmark_result);
}

index_logger
.write_to_csv(format!("{}/annoy.csv", dir_path))
.expect("Something went wrong while writing to csv");

build_logger
.write_to_csv(format!("{}/annoy_build.csv", dir_path))
.expect("Something went wrong while writing to csv");
Expand Down

0 comments on commit 393f7f1

Please sign in to comment.