Skip to content

Commit 95cc727

Browse files
committed
changed mutex type in size estimation
1 parent cb91c4c commit 95cc727

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/VecSim/algorithms/hnsw/hnsw_factory.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ size_t EstimateInitialSize(const HNSWParams *params) {
6363
est += sizeof(size_t) * params->initialCapacity + sizeof(size_t); // element level
6464
est += sizeof(size_t) * params->initialCapacity +
6565
sizeof(size_t); // Labels lookup hash table buckets.
66-
est += sizeof(std::mutex) * params->initialCapacity + sizeof(size_t); // lock per vector
66+
est += sizeof(vecsim_stl::one_byte_mutex) * params->initialCapacity + sizeof(size_t); // lock per vector
6767
}
6868

6969
// Explicit allocation calls - always allocate a header.
@@ -116,7 +116,7 @@ size_t EstimateElementSize(const HNSWParams *params) {
116116
// lookup hash map.
117117
size_t size_meta_data =
118118
sizeof(tag_t) + sizeof(size_t) + sizeof(size_t) + size_label_lookup_node;
119-
size_t size_lock = sizeof(std::mutex);
119+
size_t size_lock = sizeof(vecsim_stl::one_byte_mutex);
120120

121121
/* Disclaimer: we are neglecting two additional factors that consume memory:
122122
* 1. The overall bucket size in labels_lookup hash table is usually higher than the number of

tests/unit/test_allocator.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ TYPED_TEST(IndexAllocatorTest, test_hnsw_reclaim_memory) {
389389
// except for the bucket count of the labels_lookup hash table that is calculated separately.
390390
size_t size_total_data_per_element = hnswIndex->size_data_per_element_;
391391
expected_mem_delta += (sizeof(tag_t) + sizeof(void *) + sizeof(size_t) +
392-
size_total_data_per_element + sizeof(std::mutex)) *
392+
size_total_data_per_element + sizeof(vecsim_stl::one_byte_mutex)) *
393393
block_size;
394394
expected_mem_delta +=
395395
(hnswIndex->label_lookup_.bucket_count() - prev_bucket_count) * sizeof(size_t);

0 commit comments

Comments
 (0)