`set_up_kvikio()` silently overrides kvikio thread pool configuration set by callers
- Dominant language
- C++
- Stars
- 9.8k
- Forks
- 1.1k
- Avg merge
- 3d 6m
- Merged PRs (30d)
- 278
Description
`set_up_kvikio()` in libcudf is called lazily on the first IO operation via `std::call_once`. It does two things:
1. One-time initialization: warms the CUDA context (`cudaFree(nullptr)`) and sets compat mode from `KVIKIO_COMPAT_MODE`.
2. Sets the kvikio thread pool size from `KVIKIO_NTHREADS`, defaulting to 4 if unset.
Any caller that sets the thread pool size via the kvikio API before the first IO (say, `kvikio.defaults.set(num_threads=256)`) will have that setting silently overridden when \`set_up_kvikio()\` fires. Note that setting `KVIKIO_NTHREADS` in the environment does work, since `set_up_kvikio()` reads it. But callers should not have to rely on env vars to make their configuration stick.
This is the root cause of the hack in #23683, where cudf-polars has to call `set_up_kvikio()` eagerly (and pass its own thread count) to prevent libcudf from undoing its configuration later.
Contributor guide
Assessment
This issue has not been assessed yet.