Skip to content

MOD-15579 Report 0 shared SVS memory until first index attaches#979

Merged
dor-forer merged 1 commit into
mainfrom
dor-forer-svs-shared-mem-no-index
Jun 11, 2026
Merged

MOD-15579 Report 0 shared SVS memory until first index attaches#979
dor-forer merged 1 commit into
mainfrom
dor-forer-svs-shared-mem-no-index

Conversation

@dor-forer

@dor-forer dor-forer commented Jun 11, 2026

Copy link
Copy Markdown
Collaborator

Describe the changes in the pull request

VecSim_GetSharedMemory() returned the shared SVS thread-pool allocator's self-accounting baseline (~8 bytes) as soon as the singleton was constructed. The singleton is constructed at module init via VecSim_UpdateThreadPoolSize (RediSearch's workersThreadPool_CreatePool), so the baseline was reported even on deployments that never create an SVS index.

RediSearch folds VecSim_GetSharedMemory() into the FT.INFO vector_index_sz_mb field, so this surfaced as a nonzero vector-memory figure on indexes (or whole servers) with no vector index at all — see the discussion on RediSearch#9859.

This gates VecSimSVSThreadPoolImpl::getSharedAllocationSize() on has_attached_index_ (read under pool_mutex_) so it reports 0 until the first SVS index attaches, for both ways the singleton can be touched early:

  • never constructed (no SVS index created, VecSim_UpdateThreadPoolSize never called), or
  • constructed only to record a requested pool size at module init, with no SVS index attached yet.

Thread-spawn timing is unchanged — only the reported size changes — so there is no CONFIG SET WORKERS-vs-first-attach race. getAllocationSize() is a lockless atomic read, called under the existing pool_mutex_ with no nested locking.

ThreadPoolLazyInit now asserts the baseline is exactly 0 before any SVS index attaches.

Which issues this PR fixes

  1. MOD-15579

Main objects this PR modified

  1. src/VecSim/algorithms/svs/svs_utils.hVecSimSVSThreadPoolImpl::getSharedAllocationSize()
  2. tests/unit/test_svs.cppThreadPoolLazyInit

Mark if applicable

  • This PR introduces API changes
  • This PR introduces serialization changes

🤖 Generated with Claude Code


Note

Low Risk
Reporting-only change to shared memory accounting; thread-pool behavior and allocation timing are unchanged.

Overview
VecSim_GetSharedMemory() (and RediSearch FT.INFO vector_index_sz_mb) no longer reports the shared SVS thread-pool allocator’s tiny baseline as soon as the pool singleton exists at module init.

VecSimSVSThreadPoolImpl::getSharedAllocationSize() now returns 0 until the first SVS index attaches (has_attached_index_, read under pool_mutex_), including when VecSim_UpdateThreadPoolSize only constructed the singleton to record a deferred size. Actual pool allocation and thread spawn timing are unchanged—only reporting.

ThreadPoolLazyInit expects shared memory 0 after resetForTest() clears has_attached_index_, before any index attaches.

Reviewed by Cursor Bugbot for commit d58302a. Bugbot is set up for automated code reviews on this repo. Configure here.

VecSim_GetSharedMemory() previously returned the shared SVS thread pool
allocator's self-accounting baseline (~8 bytes) as soon as the singleton
was constructed. The singleton is constructed at module init via
VecSim_UpdateThreadPoolSize (RediSearch's workersThreadPool_CreatePool),
so the baseline was reported even on deployments with no SVS index — and
RediSearch folds VecSim_GetSharedMemory() into FT.INFO vector_index_sz_mb,
making that field nonzero with no vector index.

Gate getSharedAllocationSize() on has_attached_index_ (read under
pool_mutex_) so it reports 0 until the first SVS index attaches, for both
reasons it might be touched early: never-constructed, or constructed only
to record a requested pool size. Thread-spawn timing is unchanged; only
the reported size changes, so there is no CONFIG-SET-vs-attach race.

Update ThreadPoolLazyInit to assert the baseline is exactly 0 before any
SVS index attaches.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@jit-ci

jit-ci Bot commented Jun 11, 2026

Copy link
Copy Markdown

🛡️ Jit Security Scan Results

CRITICAL HIGH MEDIUM

✅ No security findings were detected in this PR


Security scan by Jit

@codecov

codecov Bot commented Jun 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.09%. Comparing base (6468271) to head (d58302a).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #979   +/-   ##
=======================================
  Coverage   97.09%   97.09%           
=======================================
  Files         141      141           
  Lines        8160     8164    +4     
=======================================
+ Hits         7923     7927    +4     
  Misses        237      237           

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

@dor-forer dor-forer requested a review from alonre24 June 11, 2026 10:25
@dor-forer dor-forer added this pull request to the merge queue Jun 11, 2026
Merged via the queue into main with commit 45daaf3 Jun 11, 2026
17 checks passed
@dor-forer dor-forer deleted the dor-forer-svs-shared-mem-no-index branch June 11, 2026 12:56
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