Skip to content

Conversation

@meiravgri
Copy link
Collaborator

@meiravgri meiravgri commented Sep 4, 2025

Purpose

This PR introduces a new benchmark UpdateAtBlockSize that reproduces the allocation/deallocation oscillation issue that occurs when repeatedly updating vectors at block size boundaries. This benchmark demonstrates the performance impact of the problem addressed in PR #753:

Problem Being Benchmarked

The benchmark reproduces a scenario where:

  • Index size is set to blockSize + 1 (one element past a block boundary)
  • Repeatedly deleting and re-adding the same vector triggers constant grow-shrink cycles
  • This causes frequent allocation/deallocation of large containers (hash tables, metadata vectors)
  • Results in significant performance overhead due to memory management oscillations

Implementation Details

Test Coverage: Added to both single and multi-index benchmark suites:

  • bm_basics_single_fp32.cpp - Single-index scenarios
  • bm_basics_multi_fp32.cpp - Multi-index scenarios
  • Covers BruteForce, HNSW, and Tiered HNSW algorithms

Additional Changes

Counter Improvements: Enhanced memory-related counters across all benchmarks:

  • Applied consistent benchmark::Counter::OneK::kIs1024 formatting for memory counters to display values in KB units (dividing by 1024 multipliers)

Expected Results

@codecov
Copy link

codecov bot commented Sep 4, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.85%. Comparing base (d60ab7c) to head (bb86b2f).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #768      +/-   ##
==========================================
+ Coverage   96.82%   96.85%   +0.02%     
==========================================
  Files         122      122              
  Lines        7496     7496              
==========================================
+ Hits         7258     7260       +2     
+ Misses        238      236       -2     

☔ 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.

Comment on lines +73 to +75
st.counters["memory"] =
benchmark::Counter((double)VecSimIndex_StatsInfo(index).memory,
benchmark::Counter::kDefaults, benchmark::Counter::OneK::kIs1024);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

@meiravgri meiravgri added this pull request to the merge queue Sep 4, 2025
Merged via the queue into main with commit fd08b55 Sep 4, 2025
51 of 53 checks passed
@meiravgri meiravgri deleted the meiravg_bm_ocsilations branch September 4, 2025 15:19
@github-actions
Copy link

github-actions bot commented Sep 4, 2025

Backport failed for 0.6, because it was unable to cherry-pick the commit(s).

Please cherry-pick the changes locally and resolve any conflicts.

git fetch origin 0.6
git worktree add -d .worktree/backport-768-to-0.6 origin/0.6
cd .worktree/backport-768-to-0.6
git switch --create backport-768-to-0.6
git cherry-pick -x fd08b5521ab3b3bdcbe58b6f919ea46a704ecf44

@github-actions
Copy link

github-actions bot commented Sep 4, 2025

Backport failed for 0.7, because it was unable to cherry-pick the commit(s).

Please cherry-pick the changes locally and resolve any conflicts.

git fetch origin 0.7
git worktree add -d .worktree/backport-768-to-0.7 origin/0.7
cd .worktree/backport-768-to-0.7
git switch --create backport-768-to-0.7
git cherry-pick -x fd08b5521ab3b3bdcbe58b6f919ea46a704ecf44

@github-actions
Copy link

github-actions bot commented Sep 4, 2025

Backport failed for 0.8, because it was unable to cherry-pick the commit(s).

Please cherry-pick the changes locally and resolve any conflicts.

git fetch origin 0.8
git worktree add -d .worktree/backport-768-to-0.8 origin/0.8
cd .worktree/backport-768-to-0.8
git switch --create backport-768-to-0.8
git cherry-pick -x fd08b5521ab3b3bdcbe58b6f919ea46a704ecf44

@github-actions
Copy link

github-actions bot commented Sep 4, 2025

Backport failed for 8.0, because it was unable to cherry-pick the commit(s).

Please cherry-pick the changes locally and resolve any conflicts.

git fetch origin 8.0
git worktree add -d .worktree/backport-768-to-8.0 origin/8.0
cd .worktree/backport-768-to-8.0
git switch --create backport-768-to-8.0
git cherry-pick -x fd08b5521ab3b3bdcbe58b6f919ea46a704ecf44

github-actions bot pushed a commit that referenced this pull request Sep 4, 2025
* imp bemchmar

fix counters

* fix

(cherry picked from commit fd08b55)
@github-actions
Copy link

github-actions bot commented Sep 4, 2025

Successfully created backport PR for 8.2:

meiravgri added a commit that referenced this pull request Sep 4, 2025
* imp bemchmar

fix counters

* fix

(cherry picked from commit fd08b55)
github-merge-queue bot pushed a commit that referenced this pull request Sep 5, 2025
[MOD-11237] Block Size Boundary Oscillation Benchmark (#768)

* imp bemchmar

fix counters

* fix

(cherry picked from commit fd08b55)

Co-authored-by: meiravgri <[email protected]>
meiravgri added a commit that referenced this pull request Sep 8, 2025
* imp bemchmar

fix counters

* fix

(cherry picked from commit
fd08b55)

* add indexCapacity API
github-merge-queue bot pushed a commit that referenced this pull request Sep 9, 2025
)

* [MOD-11237] Block Size Boundary Oscillation Benchmark (#768)

* imp bemchmar

fix counters

* fix

(cherry picked from commit fd08b55)

* fix memory
github-merge-queue bot pushed a commit that referenced this pull request Sep 10, 2025
)

* initial backport

* align with 0.7 api

* move UpdateAtBlockSize_Single to the end
github-merge-queue bot pushed a commit that referenced this pull request Sep 11, 2025
* [MOD-11237] Block Size Boundary Oscillation Benchmark (#768)

* imp bemchmar

fix counters

* fix

(cherry picked from commit
fd08b55)

* add indexCapacity API

* fix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants