Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move general handler work processing to a dedicated pthread #1604

Open
kgiusti opened this issue Aug 27, 2024 · 0 comments
Open

Move general handler work processing to a dedicated pthread #1604

kgiusti opened this issue Aug 27, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@kgiusti
Copy link
Contributor

kgiusti commented Aug 27, 2024

The router has functionality for scheduling work to run in the background. This functionality is called the general work handler. It allows code to schedule a function to run on a thread as soon as possible. (Note: this means when the CPU can get around to scheduling a thread to run the function as opposed to a timer that will execute the function after a given delay).

This feature is used to offload work from the calling thread. A good example is when an incoming management request is serviced: the message containing the management request is received by a Proactor I/O thread. Rather than hold the I/O thread while the management operation is executed it is instead scheduled to run outside of the I/O thread via the work handler. This allows the I/O thread to quickly become available to service pending I/O work rather than execute a potentially long-running management operation.

Currently the background work is implemented using a zero-duration timer. This means the background work is executed by the Proactor timer thread. This is undesireable for a couple of reasons: first, zero-length timer durations are inefficient with respect to Proactor scheduling. Second the Proactor timer will use one of the worker threads owned by the Proactor, which effectively prevents that thread from being used for I/O while the background work is running. And lastly these background work handlers can take a long time to run, which blocks all pending timer events from executing in a timely manner (See Issue #1572 for an example).

This issue proposes moving the background work handling from the timer context to its own dedicated pthread.

@kgiusti kgiusti self-assigned this Aug 27, 2024
@kgiusti kgiusti added the enhancement New feature or request label Aug 27, 2024
@kgiusti kgiusti added this to the 3.0.0 milestone Aug 27, 2024
@ganeshmurthy ganeshmurthy removed this from the 3.0.0 milestone Sep 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants