Skip to content

Commit 01311e3

Browse files
authored
fix(core): fix visited uids bitset memory (#9221) (#9226)
Remove visited uids from the vector hnsw index. It might hurt performance for now, but it fixes a oom error for now.
1 parent e7ae821 commit 01311e3

File tree

1 file changed

+0
-10
lines changed

1 file changed

+0
-10
lines changed

tok/hnsw/persistent_hnsw.go

-10
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import (
2424
"strings"
2525
"time"
2626

27-
"github.com/bits-and-blooms/bitset"
2827
c "github.com/dgraph-io/dgraph/v24/tok/constraints"
2928
"github.com/dgraph-io/dgraph/v24/tok/index"
3029
opt "github.com/dgraph-io/dgraph/v24/tok/options"
@@ -45,7 +44,6 @@ type persistentHNSW[T c.Float] struct {
4544
// nodeAllEdges[65443][1][3] indicates the 3rd neighbor in the first
4645
// layer for uuid 65443. The result will be a neighboring uuid.
4746
nodeAllEdges map[uint64][][]uint64
48-
visitedUids bitset.BitSet
4947
deadNodes map[uint64]struct{}
5048
}
5149

@@ -215,9 +213,6 @@ func (ph *persistentHNSW[T]) searchPersistentLayer(
215213
var eVec []T
216214
improved := false
217215
for _, currUid := range allLayerEdges[level] {
218-
if ph.visitedUids.Test(uint(currUid)) {
219-
continue
220-
}
221216
if r.indexVisited(currUid) {
222217
continue
223218
}
@@ -238,7 +233,6 @@ func (ph *persistentHNSW[T]) searchPersistentLayer(
238233
currDist, currUid, filteredOut)
239234
r.addToVisited(*currElement)
240235
r.incrementDistanceComputations()
241-
ph.visitedUids.Set(uint(currUid))
242236

243237
// If we have not yet found k candidates, we can consider
244238
// any candidate. Otherwise, only consider those that
@@ -366,8 +360,6 @@ func (ph *persistentHNSW[T]) SearchWithPath(
366360
start := time.Now().UnixMilli()
367361
r = index.NewSearchPathResult()
368362

369-
ph.visitedUids.ClearAll()
370-
371363
// 0-profile_vector_entry
372364
var startVec []T
373365
entry, err := ph.PickStartNode(ctx, c, &startVec)
@@ -451,8 +443,6 @@ func (ph *persistentHNSW[T]) insertHelper(ctx context.Context, tc *TxnCache,
451443
inLevel := getInsertLayer(ph.maxLevels) // calculate layer to insert node at (randomized every time)
452444
var layerErr error
453445

454-
ph.visitedUids.ClearAll()
455-
456446
for level := range inLevel {
457447
// perform insertion for layers [level, max_level) only, when level < inLevel just find better start
458448
err := ph.getVecFromUid(entry, tc, &startVec)

0 commit comments

Comments
 (0)