[FEA] Lazy initialization of a non-empty thread pool resource

Open
#3,022 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
48/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Quiet
Tech stack
cpp
Domain
backend

Research direction

Start with cpp/include/raft/core/resource/cuda_stream_pool.hpp and read raft::resource::is_stream_pool_initialized and set_cuda_stream_pool, then trace how raft::resources stores the pool. Define the lazy-initialization behavior for a const raft::resources& and verify that an existing pool reports whether it has at least n streams without requiring a handle copy.

Written by the indexing model from the issue text.

Description

feature request

Currently, raft::resources by default initializes an empty thread pool, so the user normally has to check if the pool is present using something like raft::resource::is_stream_pool_initialized and then use set_cuda_stream_pool function if necessary. The latter replaces the resource (that is, modifies the state of the raft::resources handle).
After https://github.com/rapidsai/raft/pull/3005 , this requires a non-const reference to the raft::resources handle, so setting the stream pool within a library function accepting const raft::resources& means copying the raft::resources handle (see https://github.com/rapidsai/cuvs/pull/2103).

To avoid this extra copy, I propose we add something like bool stream_pool_has_streams(const raft::resources& res, int n), which lazily initializes the pool with the size n; if the pool is already initialized, returns whether it has n or more threads.

Dominant language
Cuda
Stars
1.1k
Forks
260
Avg merge
1d 18h
Merged PRs (30d)
21

Getting set up

  • No Dockerfile or Docker Compose file
  • Has a pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from NVIDIA/raft

All issues in NVIDIA/raft

Similar issues

More Backend & API Design issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.