Skip to content

Version v1.1.0

Latest

Choose a tag to compare

@sunhailin-Leo sunhailin-Leo released this 31 Mar 07:16

What's Changed

Added

  • Synced hnswlib C++ headers to latest nmslib/hnswlib master
  • New hnswlib/stop_condition.h header from upstream
  • NewWithReplaceDeleted() — create index with replace-deleted support
  • AddPointWithReplace() — add vector reusing deleted slots
  • Free() — explicit memory release for HNSW index
  • Nil-safety checks for all public methods (return zero values instead of panicking)
  • Comprehensive unit tests: 19 test functions covering all space types (L2, IP, Cosine)
  • Performance benchmarks: 7 benchmark functions (AddPoint, SearchKNN, BatchOps, SaveLoad)
  • Multi-platform Makefile with portable, opt, bench, lint targets
  • Cross-compilation targets: build-linux-amd64, build-linux-arm64, build-darwin-amd64, build-darwin-arm64, build-windows-amd64
  • Windows support via MinGW-w64 (conditional CGO LDFLAGS, uint64_t types)
  • GitHub Actions CI: Linux, macOS, Windows matrix with Go 1.21–1.26
  • CHANGELOG.md with full version history

Changed

  • Upgraded hnswlib from v0.7.0 to latest master
  • All C bridge types changed from unsigned long int to uint64_t for cross-platform safety (Windows LLP64 compatibility)
  • SearchKNN now uses sync.Pool to reuse C-type buffers — allocs reduced 50% (4 → 2), L2 search ~12% faster
  • SearchBatchKNN uses lock-free per-index writes instead of mutex — allocs reduced 49% (412 → 211)
  • normalizeVector optimized to in-place modification (no slice return/copy)
  • Removed unnecessary runtime.GC() call from Free()
  • go.mod bumped to Go 1.21

Fixed

  • Fixed 3 upstream bugs in hnswalg.h: internal_idinternalId variable name
  • Fixed UpdateBatchPoints condition bug (&&|| for parameter validation)
  • Fixed errcheck lint warnings in test files

Benchmarks (Apple M3 Pro, Go 1.23, -O3 -march=native)

Benchmark ns/op B/op allocs/op
AddPoint (L2) 1,805,974 512 1
AddPoint (Cosine) 1,476,631 512 1
SearchKNN (L2, top-10) 119,831 96 2
SearchKNN (Cosine, top-10) 89,467 96 2
SearchBatchKNN (100×4) 4,231,052 15,650 211
SaveLoad (5000 vectors) 16,149,372 50 1

Full Changelog: https://github.com/sunhailin-Leo/hnswlib-to-go/blob/v1.1.0/CHANGELOG.md