Skip to content

selector: dynamically adjust event count#637

Open
arnetheduck wants to merge 2 commits into
masterfrom
dyn-event
Open

selector: dynamically adjust event count#637
arnetheduck wants to merge 2 commits into
masterfrom
dyn-event

Conversation

@arnetheduck
Copy link
Copy Markdown
Member

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.

  • 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

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant