Repository navigation
Allow cuvsRMMHostFree on a different thread than cuvsRMMHostAlloc - #2832
Conversation
The pinned host memory resource behind cuvsRMMHostAlloc/cuvsRMMHostFree was a thread_local std::unique_ptr that was only created on the first cuvsRMMHostAlloc call of each thread. Freeing a buffer on any other thread dereferenced a null pointer. pinned_host_memory_resource is stateless, so use a single process-wide instance instead.
|
/ok to test b117ab8 |
|
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
|
Important Review skippedReview was skipped as selected files did not have any reviewable changes.
|
| Layer / File(s) | Summary |
|---|---|
Use a shared pinned host resource c/src/core/c_api.cpp |
The host allocation and free APIs now use a process-wide resource accessor instead of a thread-local resource. |
Test cross-thread frees c/tests/core/host_alloc.cpp, c/tests/CMakeLists.txt |
Tests cover a single cross-thread free and 400 allocations across eight threads, with each thread freeing buffers allocated by another. CMake adds the test target. |
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix
Suggested reviewers: achirkin
Merge Risk: 
Minimal · previous review b117a
-
No concrete merge-blocking issue was identified. The pinned resource’s concurrency guarantee remains unverified.
Pre-merge checks: 
4 · 
1
-
Failed checks (1 warning) Passed checks (4 passed)Full details: Docstring Coverage
-
Explanation
Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 2 files. (1 skipped: 1 unsupported.)
-
Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
ℹ️ Recent review info
-
⚙️ Run configuration
-
- Configuration used: Repository: NVIDIA/cuvs/.coderabbit.yaml
- Review profile: CHILL
- Plan: Enterprise
- Run ID:
3983f779-bcd9-45a1-803f-6e93fbf8fbd3
📒 Files selected for processing (3)
-
c/src/core/c_api.cpp
c/tests/CMakeLists.txt
c/tests/core/host_alloc.cpp
Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review.
ℹ️ Recent review info
-
⚙️ Run configuration
-
- Configuration used: Repository: NVIDIA/cuvs/.coderabbit.yaml
- Review profile: CHILL
- Plan: Enterprise
- Run ID:
3983f779-bcd9-45a1-803f-6e93fbf8fbd3
📒 Files selected for processing (3)
-
c/src/core/c_api.cppc/tests/CMakeLists.txtc/tests/core/host_alloc.cpp
Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review.
-
…st-thread-local-merge
|
/ok to test d27e199 |
|
/merge |
cuvsRMMHostAllocandcuvsRMMHostFreeused athread_local std::unique_ptr<rmm::mr::pinned_host_memory_resource>that was created only on a thread's firstcuvsRMMHostAlloccall. Freeing a buffer on any other thread, for example after a binding moves the owning object to another thread, dereferenced a null pointer.pinned_host_memory_resourceis stateless, so this uses one process-wide instance instead.The new
cuvs_c_host_alloc_testfrees a buffer on a different thread than the one that allocated it, and runs concurrent allocations and frees across 8 threads.This was found while investigating the Rust parallel
cargo testSIGSEGV in #2233, but it has not been shown to cause that report. The crash did not reproduce in about 6,700 parallel iterations (#2818). Part of #2783.The same investigation found a data race on the function-local static prime counter in balanced k-means
adjust_centers(). That counter is removed by #2804, so it is not changed here.