Skip to content

perf(hnsw): reuse visited workspaces - #22

Merged
zhenghaoz merged 1 commit into
mainfrom
optimize/hnsw-visited-workspace
Aug 12, 2026
Merged

perf(hnsw): reuse visited workspaces#22
zhenghaoz merged 1 commit into
mainfrom
optimize/hnsw-visited-workspace

Conversation

@zhangzhenghao

Copy link
Copy Markdown
Collaborator

Summary

  • reuse a pooled generation-marked visited workspace for HNSW traversals
  • share one workspace across the layers of each query or graph insertion
  • cover dense, sparse, scalar-quantized, RaBitQ, parallel-build, and group-by traversal paths
  • add reset, resize, generation-wrap, shrink/grow, and allocation tests

Benchmark

BenchmarkHNSWSearch on linux/amd64:

main this PR
B/op 51,440 10,481
allocs/op 42 38

This reduces allocated bytes per search by 79.62% in the benchmark.

Verification

  • go test ./... -count=1
  • go vet ./...
  • go test -race ./... -count=1
  • Windows amd64 cross-compilation of internal/core
  • independent code-quality and concurrency review: PASS

@codecov

codecov Bot commented Aug 12, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.65217% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 61.42%. Comparing base (94d233b) to head (6fd5b2f).

Files with missing lines Patch % Lines
internal/core/group_by_hnsw.go 80.00% 0 Missing and 1 partial ⚠️
internal/core/hnsw.go 95.83% 0 Missing and 1 partial ⚠️
internal/core/hnsw_parallel.go 88.88% 0 Missing and 1 partial ⚠️
internal/core/hnsw_quantized.go 94.44% 0 Missing and 1 partial ⚠️
internal/core/hnsw_sparse.go 95.83% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #22      +/-   ##
==========================================
+ Coverage   61.35%   61.42%   +0.06%     
==========================================
  Files         149      150       +1     
  Lines       40240    40285      +45     
==========================================
+ Hits        24689    24744      +55     
+ Misses      12340    12335       -5     
+ Partials     3211     3206       -5     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@zhenghaoz
zhenghaoz merged commit 7f1ddea into main Aug 12, 2026
7 checks passed
@zhenghaoz
zhenghaoz deleted the optimize/hnsw-visited-workspace branch August 12, 2026 05:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants