Skip to content

Commit 4f02166

Browse files
Improve: Fewer conditional locks for immutable index views (#689)
Co-authored-by: Ash Vardanian <[email protected]>
1 parent 68c23b0 commit 4f02166

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

include/usearch/index.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3999,12 +3999,13 @@ class index_gt {
39993999
if (!is_dummy<prefetch_at>())
40004000
prefetch(citerator_at(closest_slot), citerator_at(closest_slot) + 1);
40014001

4002+
bool const need_lock = !is_immutable();
40024003
distance_t closest_dist = context.measure(query, citerator_at(closest_slot), metric);
40034004
for (level_t level = begin_level; level > end_level; --level) {
40044005
bool changed;
40054006
do {
40064007
changed = false;
4007-
node_lock_t closest_lock = node_lock_(closest_slot);
4008+
optional_node_lock_t closest_lock = optional_node_lock_(closest_slot, need_lock);
40084009
neighbors_ref_t closest_neighbors = neighbors_non_base_(node_at_(closest_slot), level);
40094010

40104011
// Optional prefetching

0 commit comments

Comments
 (0)