usearch 2.21.1 → 2.21.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -552,7 +552,7 @@ doi = {10.5281/zenodo.7949416},
552
552
  author = {Vardanian, Ash},
553
553
  title = {{USearch by Unum Cloud}},
554
554
  url = {https://github.com/unum-cloud/usearch},
555
- version = {2.21.1},
555
+ version = {2.21.2},
556
556
  year = {2023},
557
557
  month = oct,
558
558
  }
@@ -9,7 +9,7 @@
9
9
 
10
10
  #define USEARCH_VERSION_MAJOR 2
11
11
  #define USEARCH_VERSION_MINOR 21
12
- #define USEARCH_VERSION_PATCH 1
12
+ #define USEARCH_VERSION_PATCH 2
13
13
 
14
14
  // Inferring C++ version
15
15
  // https://stackoverflow.com/a/61552074
@@ -3806,6 +3806,25 @@ class index_gt {
3806
3806
  return {nodes_mutexes_, slot};
3807
3807
  }
3808
3808
 
3809
+ struct optional_node_lock_t {
3810
+ nodes_mutexes_t& mutexes;
3811
+ std::size_t slot;
3812
+ inline ~optional_node_lock_t() noexcept {
3813
+ if (slot != std::numeric_limits<std::size_t>::max())
3814
+ mutexes.atomic_reset(slot);
3815
+ }
3816
+ };
3817
+
3818
+ inline optional_node_lock_t optional_node_lock_(std::size_t slot, bool condition) const noexcept {
3819
+ if (condition) {
3820
+ while (nodes_mutexes_.atomic_set(slot))
3821
+ ;
3822
+ return {nodes_mutexes_, slot};
3823
+ } else {
3824
+ return {nodes_mutexes_, std::numeric_limits<std::size_t>::max()};
3825
+ }
3826
+ }
3827
+
3809
3828
  struct node_conditional_lock_t {
3810
3829
  nodes_mutexes_t& mutexes;
3811
3830
  std::size_t slot;
@@ -4133,6 +4152,8 @@ class index_gt {
4133
4152
  node_try_conditional_lock_(candidate_slot, updated_slot != candidate_slot, failed_to_acquire);
4134
4153
  if (failed_to_acquire)
4135
4154
  continue;
4155
+ auto optional_node_lock =
4156
+ optional_node_lock_(candidate_slot, updated_slot == candidate_slot);
4136
4157
  neighbors_ref_t candidate_neighbors = neighbors_(candidate_ref, level);
4137
4158
 
4138
4159
  // Optional prefetching
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "usearch",
3
- "version": "2.21.1",
3
+ "version": "2.21.2",
4
4
  "description": "Smaller & Faster Single-File Vector Search Engine from Unum",
5
5
  "author": "Ash Vardanian (https://ashvardanian.com/)",
6
6
  "license": "Apache 2.0",
Binary file
Binary file