Skip to content

[C API] Implement custom allocator interface and related functions for memory management - #380

Open
rfsaliev wants to merge 3 commits into
rfsaliev/c-api-estimate-index-sizefrom
rfsaliev/c-api-custom-allocator
Open

[C API] Implement custom allocator interface and related functions for memory management#380
rfsaliev wants to merge 3 commits into
rfsaliev/c-api-estimate-index-sizefrom
rfsaliev/c-api-custom-allocator

Conversation

@rfsaliev

@rfsaliev rfsaliev commented Sep 2, 2026

Copy link
Copy Markdown
Member

No description provided.

@rfsaliev
rfsaliev changed the base branch from main to rfsaliev/c-api-estimate-index-size September 2, 2026 14:21
@rfsaliev
rfsaliev force-pushed the rfsaliev/c-api-custom-allocator branch from 453a7e8 to 4f92555 Compare September 3, 2026 09:05
…acking and improve memory estimation accuracy
@rfsaliev
rfsaliev requested a balanced review from Copilot September 3, 2026 14:54
@rfsaliev
rfsaliev marked this pull request as ready for review September 3, 2026 14:55
@rfsaliev rfsaliev linked an issue Sep 3, 2026 that may be closed by this pull request

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

Comment thread bindings/c/src/allocator.hpp
Comment thread include/svs/core/allocator.h
Comment thread bindings/c/src/allocator.hpp
Comment thread bindings/c/include/svs/c/svs_c.h Outdated
Comment thread bindings/c/tests/c_api_dynamic_index.cpp Outdated
Comment thread include/svs/core/allocator.h
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.

[C API] SVS custom allocator api support

2 participants