Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 9 Nov 2014 13:17:52 -0800
From:      Adrian Chadd <adrian@freebsd.org>
To:        J David <j.david.lists@gmail.com>
Cc:        "freebsd-hackers@freebsd.org" <freebsd-hackers@freebsd.org>, "freebsd-questions@freebsd.org" <freebsd-questions@freebsd.org>
Subject:   Re: How thread-friendly is kevent?
Message-ID:  <CAJ-Vmon3+ev0wq9sATbdgPKHXLF+Q+R=hX8dbBPJvH-uJD6NqQ@mail.gmail.com>
In-Reply-To: <CABXB=RQWxu-d30raZ+FcrnrGsr5gG2Za_=cx8-jCnLSgJDSF=Q@mail.gmail.com>
References:  <CABXB=RQWxu-d30raZ+FcrnrGsr5gG2Za_=cx8-jCnLSgJDSF=Q@mail.gmail.com>

Next in thread | Previous in thread | Raw E-Mail | Index | Archive | Help
Hi!

Are you putting the same FD into multiple threads and hoping that only
one note will wake up on one listening kqueue?



-adrian


On 9 November 2014 11:57, J David <j.david.lists@gmail.com> wrote:
> How thread-friendly is kevent()?
>
> In most cases, a dedicated thread does the kevent()-ing and
> dispatching work to the thread pool, but at extremely high rates that
> thread becomes a significant bottleneck.
>
> As an example, consider a pool of, say, 17 threads on a 16 core
> machine all in kevent() waiting for one of 32000 open TCP connections
> to be read-ready.  One connection becomes read-ready.  How many
> threads will have kevent() return with that event in eventlist?  Is
> there potential for a thundering herd problem?
>
> Limited small-scale experimentation suggests that only one thread
> returns per event, but it's not documented that way, so it's not clear
> if that behavior is intended, an implementation detail, or a
> coincidence that won't hold up at scale.
>
> Is this behavior at all guaranteed / by design / intentional?
>
> Although it would be ideal if so, it would also make sense to have to
> rely on EV_DISPATCH in multithreaded applications to prevent events
> from being delivered more than once, or to use EV_ONESHOT and re-add
> the event entirely, depending on which approach better suits the
> internal data structure the kernel uses for kqueue.
>
> Thanks for any advice!
> _______________________________________________
> freebsd-questions@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.org"



Want to link to this message? Use this URL: <http://docs.FreeBSD.org/cgi/mid.cgi?CAJ-Vmon3+ev0wq9sATbdgPKHXLF+Q+R=hX8dbBPJvH-uJD6NqQ>