Skip to content

[8.2] Fix incoming edges ghost memory leak (MOD-13761)#922

Merged
meiravgri merged 1 commit into8.2from
meiravg_backport_920_to_8.2
Mar 25, 2026
Merged

[8.2] Fix incoming edges ghost memory leak (MOD-13761)#922
meiravgri merged 1 commit into8.2from
meiravg_backport_920_to_8.2

Conversation

@meiravgri
Copy link
Collaborator

@meiravgri meiravgri commented Mar 25, 2026

backport #920 to 8.2


Note

Medium Risk
Touches core HNSW graph bookkeeping by adding shrink_to_fit() during incoming-edge removals, which could impact indexing latency and allocation behavior. Also adds new benchmarks and CI wiring, but no API or data-format changes.

Overview
Fixes HNSW incoming-edges ghost memory growth by opportunistically shrinking incomingUnidirectionalEdges after successful removals when capacity is disproportionately larger than size.

Adds a dedicated benchmark (index_internals_incoming_edges_fp32) to reproduce and measure the memory/latency impact of this scenario (async delete, in-place delete, and insert paths), and wires it into the benchmark runner scripts and GitHub Actions benchmark workflow.

Written by Cursor Bugbot for commit eeab33f. This will update automatically on new commits. Configure here.

* Add incoming edges ghost memory benchmarks (MOD-13761)

Add three benchmarks to measure performance and memory impact of the
incoming edges shrink_to_fit fix:

1. DeleteZeroVectorsAsync - async deletion path (production default)
2. DeleteZeroVectorsInPlace - in-place deletion path (worst-case latency)
3. InsertZeroVectorsTimed - insertion path (heuristic pruning cost)

Stress scenario: 40K random + 50K zero vectors with COSINE metric,
which forces hub nodes with large incoming edge vectors. Each benchmark
measures ghost memory (wasted capacity) before and after shrink_to_fit,
with detailed stats (percentiles, top-10, mean).

Run with: make benchmark BM_FILTER=bm-index-internals-incoming-edges

* results before

* shrinking logic

* fix uncoditionally shrink

* add bm-index-internals-incoming-edges

* use 1 thread

* use ratio = 2, remove min

* remove results before

* rename to bm-hnsw-internals-incoming-edges

better output
@meiravgri meiravgri requested a review from alonre24 March 25, 2026 12:14
@jit-ci
Copy link

jit-ci bot commented Mar 25, 2026

🛡️ Jit Security Scan Results

CRITICAL HIGH MEDIUM

✅ No security findings were detected in this PR


Security scan by Jit

@codecov
Copy link

codecov bot commented Mar 25, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.98%. Comparing base (8e80775) to head (eeab33f).
⚠️ Report is 1 commits behind head on 8.2.

Additional details and impacted files
@@            Coverage Diff             @@
##              8.2     #922      +/-   ##
==========================================
- Coverage   97.03%   96.98%   -0.06%     
==========================================
  Files         126      126              
  Lines        7353     7358       +5     
==========================================
+ Hits         7135     7136       +1     
- Misses        218      222       +4     

☔ View full report in Codecov by Sentry.
📢 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.

@meiravgri meiravgri enabled auto-merge March 25, 2026 12:38
@meiravgri meiravgri added this pull request to the merge queue Mar 25, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 25, 2026
@meiravgri meiravgri added this pull request to the merge queue Mar 25, 2026
Merged via the queue into 8.2 with commit 522bdfc Mar 25, 2026
17 checks passed
@meiravgri meiravgri deleted the meiravg_backport_920_to_8.2 branch March 25, 2026 15:19
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