-
Notifications
You must be signed in to change notification settings - Fork 22
Bind epoll_loop to last online CPU
#73
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds CPU affinity binding for the epoll_loop thread to prevent it from being scheduled on CPU0, which typically handles interrupts and critical system tasks. The implementation determines the last available CPU using sched_getaffinity and binds the event monitor thread to that CPU using pthread_setaffinity_np.
Changes:
- Added
_GNU_SOURCEdefinition andsched.hinclude for CPU affinity functions - Implemented CPU affinity logic in
initialize_event_monitorto bind the epoll_loop thread to the last online CPU - Added logging for CPU affinity operations (success and failure cases)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
agicy
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
Currently, the
epoll_loopis created without CPU affinity, whichcan result in it being scheduled on CPU0. Since CPU0 is often handling
interrupts and other critical system tasks (
zone0), this can interferewith system responsiveness.
This PR changes the
initialize_event_monitorto bindepoll_looptothe last online CPU available to the process. The thread affinity is
set using
pthread_setaffinity_npafter determining the last CPU fromsched_getaffinity.