selector: dynamically adjust event count#637
Open
arnetheduck wants to merge 2 commits into
Open
Conversation
When fetching events with epoll/kqueue, we currently use a fixed size array to fetch system events. Taking an idea from [libevent](https://github.com/libevent/libevent/blob/48296514d8fd9c0b3812b11d45ad80b0c002c14e/epoll.c#L568), we can instead dynamically grow the number of events fetched as the system comes under load thus reducing the number of poll calls, allowing more work to be done per batch. The change also has the effect that data that already arrived at the time of the poll call gets processed before timers are fired - this means that timeouts are less likely to be triggered unfairly due to event queueing order and the time it takes to process each event. * increase max events per loop to 4096 (same as libevent) * reduce initial event list allocation to 32 * get rid of `ReadyKey.errorCode` which is unused
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When fetching events with epoll/kqueue, we currently use a fixed size array to fetch system events.
Taking an idea from
libevent, we can instead dynamically grow the number of events fetched as the system comes under load thus reducing the number of poll calls, allowing more work to be done per batch.
The change also has the effect that data that already arrived at the time of the poll call gets processed before timers are fired - this means that timeouts are less likely to be triggered unfairly due to event queueing order and the time it takes to process each event.
ReadyKey.errorCodewhich is unused