sleepy_penguin RubyGem user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
* [PATCH] epoll: add EPOLLEXCLUSIVE constant and documentation
@ 2017-03-18  0:56 Eric Wong
  0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2017-03-18  0:56 UTC (permalink / raw)
  To: sleepy-penguin

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
---
 ext/sleepy_penguin/epoll.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

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));
 
-- 
EW


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2017-03-18  0:56 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-18  0:56 [PATCH] epoll: add EPOLLEXCLUSIVE constant and documentation Eric Wong

Code repositories for project(s) associated with this public inbox

	https://yhbt.net/sleepy_penguin.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).