MOD-15579 Report 0 shared SVS memory until first index attaches#979
Merged
Conversation
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 Security Scan Results✅ No security findings were detected in this PR
Security scan by Jit
|
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
alonre24
approved these changes
Jun 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 viaVecSim_UpdateThreadPoolSize(RediSearch'sworkersThreadPool_CreatePool), so the baseline was reported even on deployments that never create an SVS index.RediSearch folds
VecSim_GetSharedMemory()into theFT.INFOvector_index_sz_mbfield, 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()onhas_attached_index_(read underpool_mutex_) so it reports0until the first SVS index attaches, for both ways the singleton can be touched early:VecSim_UpdateThreadPoolSizenever called), orThread-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 existingpool_mutex_with no nested locking.ThreadPoolLazyInitnow asserts the baseline is exactly0before any SVS index attaches.Which issues this PR fixes
Main objects this PR modified
src/VecSim/algorithms/svs/svs_utils.h—VecSimSVSThreadPoolImpl::getSharedAllocationSize()tests/unit/test_svs.cpp—ThreadPoolLazyInitMark if applicable
🤖 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 RediSearchFT.INFOvector_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 underpool_mutex_), including whenVecSim_UpdateThreadPoolSizeonly constructed the singleton to record a deferred size. Actual pool allocation and thread spawn timing are unchanged—only reporting.ThreadPoolLazyInitexpects shared memory 0 afterresetForTest()clearshas_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.