`CREATE INDEX` keeps its build memory while the vamana worker loads a second copy of the index, which can OOM large builds
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 66/100
Research direction
Start by reading vamanabuild(), its cleanup: block, SerializeIndexToPages(), and FreeBuildState() to trace when the index handle and raw vector buffer are released. Confirm which values are still needed after serialization and warm-up, then check the relevant build and serialization tests. Done means both allocations are freed as soon as the issue describes and the resulting index build still passes those tests.
Written by the indexing model from the issue text.
Description
Problem
At the end of a vamana CREATE INDEX, the backend serializes the index to disk and then waits for the vamana worker to load it (the synchronous warm-up in vamanabuild()). For the whole of that load, the backend still holds its two large build allocations:
- its own in-memory copy of the index, freed only after the warm-up (
SVSFreeIndexin thecleanup:block); - the raw float vector buffer (rows × dims × 4 bytes), freed later still in
FreeBuildState().
Neither is needed once the index is on disk. While the worker loads its own copy, though, the machine holds the full build footprint plus a second copy of the index. The peak memory of CREATE INDEX is therefore build + residency rather than max(build, residency).
This memory isn't accounted for either: SvsMemoryConfirmBuild() releases the build's reservation before serialization, so from then on nothing is reserved against the memory the backend still holds.
For large indexes this handoff is the highest-memory point of the build. Peak machine-wide memory usage during the handoff can noticeably exceed the peak observed during the build phase itself. In some cases, a build that completes successfully within available memory is then OOM-killed while the worker loads the resulting index.
Steps to reproduce
- Build a large vamana index with
svs.max_build_memoryhigh enough that the gate admits it. - During
CREATE INDEX, sample the RSS of both the build backend and thevamana workerprocess every second. - After
SVS index built successfully, both processes hold their full footprint at the same time until the worker finishes loading. If the build footprint and the index together exceed available memory, the OOM killer fires during this window.
Recommendations
- Free the raw vector buffer as soon as the SVS build returns. The SVS dynamic build copies its input into the index's own dataset, so the buffer isn't needed afterwards. Keep
vectors.count, which serialization and the build result still read. - Free the backend's index handle right after
SerializeIndexToPages(), before the warm-up. The worker loads its own copy from disk, and nothing after serialization uses the backend's copy.
With both changes the peak becomes max(build, residency), and releasing the reservation at confirm time becomes accurate.
- Dominant language
- Perl
- Stars
- 3
- Forks
- 3
- Avg merge
- 4d 19h
- Merged PRs (30d)
- 5
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from intel/SVS-Extension-for-PostgreSQL
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
-
Difficulty 4/5 3-5 days Newbie friendliness 55/100
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 46/100
-
PostgreSQL 18.6+ requires `svs` in `output_plugin_libraries`, but this isn't documented or checkedOpen
Difficulty 4/5 3-5 days Newbie friendliness 48/100
All issues in intel/SVS-Extension-for-PostgreSQL
Similar issues
-
fix(rodex): sent mail loses the last character of title and bodyPossibly taken @baphomello claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
owasp-modsecurity/ModSecurity-nginx#418 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
inverse-inc/packetfence#9768 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
metacpan/metacpan-api#1534 ·