From 63be3c524578f69419fd79c091a1919e7c4f00e2 Mon Sep 17 00:00:00 2001 From: zeraph6 <74666751+zeraph6@users.noreply.github.com> Date: Fri, 9 Jul 2021 04:40:50 +0100 Subject: [PATCH] Update hnswalg.h Collect_metrics@searchBaseLayer : We should not increment metric_distance_computation with the size of neighbors, since there may be some neighbors already visited. --- hnswlib/hnswalg.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hnswlib/hnswalg.h b/hnswlib/hnswalg.h index f23c17d9..03fac29d 100644 --- a/hnswlib/hnswalg.h +++ b/hnswlib/hnswalg.h @@ -280,10 +280,9 @@ namespace hnswlib { int *data = (int *) get_linklist0(current_node_id); size_t size = getListCount((linklistsizeint*)data); // bool cur_node_deleted = isMarkedDeleted(current_node_id); - if(collect_metrics){ + if(collect_metrics) metric_hops++; - metric_distance_computations+=size; - } + #ifdef USE_SSE _mm_prefetch((char *) (visited_array + *(data + 1)), _MM_HINT_T0); @@ -301,7 +300,8 @@ namespace hnswlib { _MM_HINT_T0);//////////// #endif if (!(visited_array[candidate_id] == visited_array_tag)) { - + if(collect_metrics)metric_distance_computations++; + visited_array[candidate_id] = visited_array_tag; char *currObj1 = (getDataByInternalId(candidate_id));