[libdispatch-dev] Why polling event sources with a kevent receiving queue of size 1?
zarzycki at apple.com
Mon Jul 19 11:57:35 PDT 2010
In earlier versions of libdispatch, we had actually configured kevent() to drain more than one event, but in an effort to rule out some bugs (like what Kevin alluded to and other bugs), we switched kevent() to drain only one event.
In practice, this isn't a performance problem, because the handlers that act upon fired events do _so_ much work, that the overhead of draining events drops into the noise. A callback would have to do almost no work for "one kevent at a time" to be a performance problem.
On Jul 19, 2010, at 11:40 AM, Kevin Van Vechten wrote:
> On Jul 19, 2010, at 3:52 AM, cee1 wrote:
>> I've noticed libdispatch will poll event sources with an one-entry kevent receiving queue(queue_kevent.c:162, in function " _dispatch_mgr_invoke"). This will incurs more system calls and hence poorer performance. Why not poll event sources with a larger kevent receiving queue?
> No specific reason other than being an optimization which has not been done yet. While it should be a pretty straightforward optimization, I think there are a couple edge cases we need to consider first to ensure that an incoming kevent can't "resurrect" a dispatch source object already scheduled for disposal on the manager queue.
> libdispatch-dev mailing list
> libdispatch-dev at lists.macosforge.org
More information about the libdispatch-dev