lots of useless recvfrom() calls

Lennert Buytenhek buytenh at wantstofly.org
Mon May 21 09:41:11 MSK 2018


On Tue, May 08, 2018 at 12:12:54PM +0300, Lennert Buytenhek wrote:

> > > I am using the patch below to avoid one useless recvfrom() call (that
> > > returns EAGAIN) for every call to dns_ioevent().  Under low load, where
> > > every call to dns_ioevent() processes one DNS reply, this saves half of
> > > the total number of recvfrom() calls.
> > 
> > Is it really a problem under low load? If the load is low, it doesn't
> > really matter how many recvfrom() system calls are made, I think.
> 
> 'low load' here is 'a low expected number of reply packets per POLLIN
> cycle', but even for a large number of queries per second and multiple
> parallel queries, I would not expect there to be more than one reply
> packet per POLLIN cycle very often.

Another option is to try to recv() a packet up to as many times as we
have an outstanding DNS query on this context.  So if there is one
outstanding DNS query, always return after one recv() call, if there
are five, then try up to five times (but return as soon as we get
EAGAIN), etc.


More information about the udns mailing list