From 97f15cba3e49e3f8c4d68dfe1f304342ac5f4350 Mon Sep 17 00:00:00 2001 From: Thejas-bhat Date: Wed, 10 Apr 2024 10:15:20 +0530 Subject: [PATCH] removing the unnecessary mutex --- faiss_vector_cache.go | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/faiss_vector_cache.go b/faiss_vector_cache.go index 5c063984..e22378ba 100644 --- a/faiss_vector_cache.go +++ b/faiss_vector_cache.go @@ -40,9 +40,7 @@ type ewma struct { type cacheEntry struct { tracker *ewma refs int64 - - m sync.RWMutex - index *faiss.IndexImpl + index *faiss.IndexImpl } func newVectorIndexCache() *vecIndexCache { @@ -82,10 +80,8 @@ func (vc *vecIndexCache) createAndCacheVectorIndex(fieldID uint16, // cached. entry, present := vc.cache[fieldID] if present { - entry.m.RLock() rv := entry.index entry.incHit() - entry.m.RUnlock() return rv, nil } @@ -121,10 +117,7 @@ func (vc *vecIndexCache) isIndexCached(fieldID uint16) (*faiss.IndexImpl, bool) return nil, false } - entry.m.RLock() rv := entry.index - entry.m.RUnlock() - return rv, present && (rv != nil) } @@ -230,8 +223,6 @@ func (vc *cacheEntry) decRef() { } func (vc *cacheEntry) closeIndex() { - vc.m.Lock() vc.index.Close() vc.index = nil - vc.m.Unlock() }