Skip to content

Commit 114820a

Browse files
committed
test: add memory footprint note for seenKeys per review
Signed-off-by: Abhinav Singh <abhinavsingh717073@gmail.com>
1 parent 3b2834a commit 114820a

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

pkg/store/store_redis.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,10 @@ func (rs *redisStore) ListSandboxesByKind(ctx context.Context, kind string) ([]*
149149
allSandboxes := make([]*types.SandboxInfo, 0) // Initialize as empty array, not nil
150150
var cursor uint64
151151
matchPattern := rs.sessionPrefix + "*"
152+
// Note: seenKeys holds all scanned keys in memory to deduplicate results across all SCAN pages,
153+
// as SCAN can return the same key multiple times. For extremely large datasets, this could
154+
// have a memory impact, and a dedicated secondary index (e.g. Redis SET per kind) is recommended
155+
// as a follow-up optimization.
152156
seenKeys := make(map[string]bool)
153157

154158
for {

pkg/store/store_valkey.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,10 @@ func (vs *valkeyStore) ListSandboxesByKind(ctx context.Context, kind string) ([]
181181
allSandboxes := make([]*types.SandboxInfo, 0) // Initialize as empty array, not nil
182182
cursor := uint64(0)
183183
matchPattern := vs.sessionPrefix + "*"
184+
// Note: seenKeys holds all scanned keys in memory to deduplicate results across all SCAN pages,
185+
// as SCAN can return the same key multiple times. For extremely large datasets, this could
186+
// have a memory impact, and a dedicated secondary index (e.g. Valkey SET per kind) is recommended
187+
// as a follow-up optimization.
184188
seenKeys := make(map[string]bool)
185189

186190
for {

0 commit comments

Comments
 (0)