Skip to content

Apparent deadlock when Heuristic option enabled #49

@dwerner

Description

@dwerner

Description

While debugging another issue, I found a deadlock when a extend_candidates is set to true in the Heuristic:

Reproduce

  1. Change the map test in tests/all.rs as below (set the Heuristic in the builder).
  2. cargo test map
  3. Note that the test won't complete.

Test code

diff --git a/instant-distance/tests/all.rs b/instant-distance/tests/all.rs
index b9fa973..8e916c6 100644
--- a/instant-distance/tests/all.rs
+++ b/instant-distance/tests/all.rs
@@ -4,7 +4,7 @@ use ordered_float::OrderedFloat;
 use rand::rngs::{StdRng, ThreadRng};
 use rand::{Rng, SeedableRng};
 
-use instant_distance::{Builder, Point as _, Search};
+use instant_distance::{Builder, Heuristic, Point as _, Search};
 
 #[test]
 #[allow(clippy::float_cmp, clippy::approx_constant)]
@@ -16,7 +16,13 @@ fn map() {
 
     let seed = ThreadRng::default().gen::<u64>();
     println!("map (seed = {seed})");
-    let map = Builder::default().seed(seed).build(points, values);
+    let map = Builder::default()
+        .seed(seed)
+        .select_heuristic(Some(Heuristic {
+            extend_candidates: true,
+            ..Default::default()
+        }))
+        .build(points, values);
     let mut search = Search::default();
 
     for (i, item) in map.search(&Point(2.0, 2.0), &mut search).enumerate() {

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions