[FEA]Expose a pooled pinned host memory resource in the C API

未关闭
#3,118 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
32/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
活跃
技术栈
c, rust
领域
api

调研方向

Start from the existing host allocation pair cuvsRMMHostAlloc / cuvsRMMHostFree in the C API and from the device-side cuvsRMMPoolMemoryResourceEnable, which is the pattern to copy for the new Enable/Disable functions. Then read the regenerated Rust bindings in cuvs-sys (bindings.rs). Done means the two new functions exist, the alloc/free calls route through a mutex-protected process-wide pinned pool when enabled, and the default path is unchanged.

由索引模型根据 Issue 内容生成。

描述

feature request

Is your feature request related to a problem? Please describe.
In C++, pinned host memory can be pooled by composing RMM resources
(pool_memory_resource over pinned_host_memory_resource). The C API has no equivalent. It only
offers cuvsRMMHostAlloc / cuvsRMMHostFree, which bypass any pool and perform one cudaMallocHost /
cudaFreeHost per call. Callers that reach cuVS through the C API, including the language bindings
(Rust, Python, Go, Java), cannot get a pinned host pool, and must register memory themselves or write
their own allocator.

The device side already exposes a pooled resource through cuvsRMMPoolMemoryResourceEnable. This
proposes the host-side counterpart.

Describe the solution you'd like
Add a process-wide pinned host pool to the C API:

cuvsError_t cuvsRMMPinnedHostPoolEnable(size_t pool_size_bytes);
cuvsError_t cuvsRMMPinnedHostPoolDisable();
  • cuvsRMMPinnedHostPoolEnable(pool_size_bytes) creates one pool_memory_resource over
    pinned_host_memory_resource, with initial size == maximum size, so the pinning cost is paid once, up
    front.
  • While the pool is enabled, cuvsRMMHostAlloc / cuvsRMMHostFree use it. If the pool is exhausted,
    cuvsRMMHostAlloc returns an error and does not fall back silently, so the caller decides what to do.
  • The pool is held process-wide (mutex-protected) rather than thread_local. A pool is stateful, so a
    per-thread pool would multiply the pinned memory by the number of threads, and memory freed on a
    different thread than the one that allocated it would be returned to the wrong pool.
  • With the pool disabled (the default), behaviour is unchanged: one cudaMallocHost per call.

Regenerated Rust bindings in cuvs-sys (bindings.rs).

Because the pool is opt-in, these costs only apply to callers that enable it:

  • Pinning cost. Enable pins the whole pool up front, which we measured at about 0.3 s per GiB, so the
    pool should be sized to the peak amount in use at once.

Describe alternatives you've considered

  • Change cuvsRMMHostAlloc internally, with no new function. The caller then cannot choose the pool
    size, and existing callers would start holding pinned memory for the life of the process. We prefer an
    explicit opt-in function.
  • Expose the C++ API only. C API users and the bindings still cannot reach it.

Additional context
We have a working patch (C API + Rust bindings) and will open a new PR.

主要语言
Cuda
星标
902
派生
267
平均合并
2 天 21 小时
30 天内合并 PR
57

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

NVIDIA/cuvs 的其他 Issue

查看 NVIDIA/cuvs 的全部 Issue

相似的 Issue

更多 Backend & API Design Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。