diff options
author | Eric Wong <sleepy-penguin@bogomips.org> | 2017-03-18 00:56:37 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2017-03-18 00:56:54 +0000 |
commit | 67217af099363633adf16a15fb0bddbd9d015176 (patch) | |
tree | ebce2e0cea79804149ef4966ca2cb0c76d50adcb | |
parent | a4c4165539c01a2ade5cd7f123295d77733f6624 (diff) | |
download | sleepy_penguin-67217af099363633adf16a15fb0bddbd9d015176.tar.gz |
I'm still not convinced this is necessary, but it's in Linux, now, and maybe some folks will want it. My position remains: Never put listen sockets in epoll if you're using threads; instead, dedicate a thread to doing nothing but _blocking_ accept4 + epoll_ctl(.. EPOLL_CTL_ADD). Of course, if you're using something which does not have native thread support but using multiple processes, then yes, EPOLLEXCLUSIVE will prevent multiple processes from turning into a thundering herd. In other words: I would use this with Perl5, but not with Ruby 1.9+ :P
-rw-r--r-- | ext/sleepy_penguin/epoll.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/ext/sleepy_penguin/epoll.c b/ext/sleepy_penguin/epoll.c index 8155c4a..09c4bf7 100644 --- a/ext/sleepy_penguin/epoll.c +++ b/ext/sleepy_penguin/epoll.c @@ -306,6 +306,17 @@ void sleepy_penguin_init_epoll(void) rb_define_const(cEpoll, "WAKEUP", UINT2NUM(EPOLLWAKEUP)); #endif +#ifdef EPOLLEXCLUSIVE + /* + * Sets an exclusive wakeup mode for the epoll object + * that is being attached to the target IO. This + * avoids thundering herd scenarios when the same + * target IO is shared among multiple epoll objects. + * Available since Linux 4.5 + */ + rb_define_const(cEpoll, "EXCLUSIVE", UINT2NUM(EPOLLEXCLUSIVE)); +#endif + /* watch for urgent read(2) data */ rb_define_const(cEpoll, "PRI", UINT2NUM(EPOLLPRI)); |