uvadapter: reduce number of uv_poll_start calls
Internally uv_poll_start iterates over all attached event handlers to update event mask. It's quite expensive operation if there many event handlers attached to a loop. As redisLibuvEvents.events is a copy of what libuv should see, we can rely on it to avoid event mask updates. Signed-off-by: Anton Tiurin <noxiouz@yandex.ru>master
parent
35d398c903
commit
ca4a0e850b
|
@ -30,6 +30,10 @@ static void redisLibuvPoll(uv_poll_t* handle, int status, int events) {
|
||||||
static void redisLibuvAddRead(void *privdata) {
|
static void redisLibuvAddRead(void *privdata) {
|
||||||
redisLibuvEvents* p = (redisLibuvEvents*)privdata;
|
redisLibuvEvents* p = (redisLibuvEvents*)privdata;
|
||||||
|
|
||||||
|
if (p->events & UV_READABLE) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
p->events |= UV_READABLE;
|
p->events |= UV_READABLE;
|
||||||
|
|
||||||
uv_poll_start(&p->handle, p->events, redisLibuvPoll);
|
uv_poll_start(&p->handle, p->events, redisLibuvPoll);
|
||||||
|
@ -52,6 +56,10 @@ static void redisLibuvDelRead(void *privdata) {
|
||||||
static void redisLibuvAddWrite(void *privdata) {
|
static void redisLibuvAddWrite(void *privdata) {
|
||||||
redisLibuvEvents* p = (redisLibuvEvents*)privdata;
|
redisLibuvEvents* p = (redisLibuvEvents*)privdata;
|
||||||
|
|
||||||
|
if (p->events & UV_WRITABLE) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
p->events |= UV_WRITABLE;
|
p->events |= UV_WRITABLE;
|
||||||
|
|
||||||
uv_poll_start(&p->handle, p->events, redisLibuvPoll);
|
uv_poll_start(&p->handle, p->events, redisLibuvPoll);
|
||||||
|
|
Loading…
Reference in New Issue