[C API] Implement custom allocator interface and related functions for memory management - #380
Open
rfsaliev wants to merge 3 commits into
Open
Conversation
rfsaliev
changed the base branch from
main
to
rfsaliev/c-api-estimate-index-size
September 2, 2026 14:21
…r memory management
rfsaliev
force-pushed
the
rfsaliev/c-api-custom-allocator
branch
from
September 3, 2026 09:05
453a7e8 to
4f92555
Compare
…acking and improve memory estimation accuracy
rfsaliev
marked this pull request as ready for review
September 3, 2026 14:55
rfsaliev
requested review from
ahuber21,
ethanglaser and
ibhati
as code owners
September 3, 2026 14:55
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The public allocator interface breaks compatibility, while callback validation, error propagation, and lifetime documentation remain unsafe.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Adds configurable built-in and custom allocators to C API Vamana index construction and loading.
Changes:
- Introduces the C custom allocator interface and builder configuration APIs.
- Propagates allocator handles through static/dynamic graph and data storage.
- Adds allocator accounting tests and improves dynamic memory estimates.
File summaries
| File | Description |
|---|---|
include/svs/orchestrators/dynamic_vamana.h |
Adds allocator-aware dynamic builds. |
include/svs/index/vamana/dynamic_index.h |
Builds dynamic graphs with supplied allocators. |
include/svs/core/graph.h |
Makes graph loading allocator-aware. |
include/svs/core/allocator.h |
Generalizes erased allocator rebinding. |
bindings/c/tests/c_api_test_utils.h |
Adds a tracking test allocator. |
bindings/c/tests/c_api_index.cpp |
Tests static-index allocator configuration. |
bindings/c/tests/c_api_dynamic_index.cpp |
Tests dynamic-index allocator configuration. |
bindings/c/src/svs_c.cpp |
Implements C allocator setters. |
bindings/c/src/index_builder.hpp |
Stores and forwards allocator handles. |
bindings/c/src/dispatcher_vamana.hpp |
Extends static dispatcher declarations. |
bindings/c/src/dispatcher_vamana.cpp |
Applies allocators to static data and graphs. |
bindings/c/src/dispatcher_dynamic_vamana.hpp |
Extends dynamic dispatcher declarations. |
bindings/c/src/dispatcher_dynamic_vamana.cpp |
Applies allocators and updates estimates. |
bindings/c/src/data_builder/sq.hpp |
Uses allocator handles for SQ data. |
bindings/c/src/data_builder/simple.hpp |
Uses allocator handles for simple data. |
bindings/c/src/data_builder/lvq.hpp |
Uses allocator handles for LVQ data. |
bindings/c/src/data_builder/leanvec.hpp |
Uses allocator handles for LeanVec data. |
bindings/c/src/allocator.hpp |
Adapts C callbacks to C++ allocators. |
bindings/c/include/svs/c/svs_c.h |
Exposes the allocator C API. |
Review details
- Files reviewed: 19/19 changed files
- Comments generated: 6
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
No description provided.