Skip to content

Add runtime setters for MULTI_POLL reactor count, dispatch, and request ceiling - #1049

Open
Matt711 wants to merge 3 commits into
rapidsai:mainfrom
Matt711:fea/add-set-get-apis
Open

Add runtime setters for MULTI_POLL reactor count, dispatch, and request ceiling#1049
Matt711 wants to merge 3 commits into
rapidsai:mainfrom
Matt711:fea/add-set-get-apis

Conversation

@Matt711

@Matt711 Matt711 commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Adds setters for remote_io_num_reactors, remote_io_reactor_dispatch, and remote_io_max_concurrent_requests

@Matt711
Matt711 requested review from a team as code owners August 27, 2026 21:50
@Matt711 Matt711 added feature request New feature or request non-breaking Introduces a non-breaking change labels Aug 27, 2026

@madsbk madsbk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Overall looks good.

  • update the stale sentence at runtime_settings.rst:82
  • add missing docs for three newly user-facing settings

Comment thread cpp/src/defaults.cpp
Comment on lines +307 to +313
void defaults::set_remote_io_num_reactors(unsigned int num_reactors)
{
KVIKIO_EXPECT(
num_reactors > 0, "remote_io_num_reactors must be a positive integer", std::invalid_argument);
instance()->_remote_io_num_reactors = num_reactors;
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think it would be helpful if we could throw if the reactor pool has already been started?
Maybe add something like:

// multi_poll_reactor.hpp
static bool is_instantiated() noexcept;

// multi_poll_reactor.cpp
namespace { std::atomic<bool> _pool_instantiated{false}; }

bool MultiReactorPool::is_instantiated() noexcept
{
  return _pool_instantiated.load(std::memory_order_acquire);
}

MultiReactorPool::MultiReactorPool() : _dispatch{defaults::remote_io_reactor_dispatch()}
{
  ...
  _pool_instantiated.store(true, std::memory_order_release);  // end of ctor
}

Comment thread cpp/include/kvikio/defaults.hpp Outdated
Comment on lines +494 to +495
* Takes effect only if set before the `MULTI_POLL` reactor pool is first used (the pool, like
* the default thread pool, is created lazily on first use and is never rebuilt).

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.

nit: Like Mads, I think we should throw if this set call would not take effect.

Comment thread cpp/include/kvikio/defaults.hpp Outdated
Comment on lines +518 to +519
* Takes effect only if set before the `MULTI_POLL` reactor pool is first used (the pool, like
* the default thread pool, is created lazily on first use and is never rebuilt).

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.

Same here.

Comment thread cpp/include/kvikio/defaults.hpp Outdated
Comment on lines +550 to +551
* Takes effect only if set before the `MULTI_POLL` reactor pool is first used (the pool, like
* the default thread pool, is created lazily on first use and is never rebuilt).

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.

And here.

Comment thread cpp/src/defaults.cpp

void defaults::set_remote_io_reactor_dispatch(RemoteReactorDispatch dispatch)
{
instance()->_remote_io_reactor_dispatch = dispatch;

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.

Yeah, I think especially because the getters will return this value (even if it was not the one used for setting up the multi-poll instance), we should throw. Otherwise inspecting the defaults later to report behaviour will be misleading.

Comment thread cpp/include/kvikio/defaults.hpp Outdated
* runtime, overriding `KVIKIO_REMOTE_IO_NUM_REACTORS`.
*
* Takes effect only if set before the `MULTI_POLL` reactor pool is first used (the pool, like
* the default thread pool, is created lazily on first use and is never rebuilt).

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.

I agree with the suggestion. Just want to point out that for the BS thread pool used for local I/O and easy backend, we do support changing the number of threads midway at runtime, which would block the calling thread, drain the task queue, destroy the worker threads, and then recreate a new set of worker threads. So I think the phrasing "like the default thread pool" should be removed from the doc string here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature request New feature or request non-breaking Introduces a non-breaking change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants