On 27/03/2012 4:22 a.m., Alexander Komyagin wrote:
On Fri, 2012-03-23 at 19:46 +0100, Henrik Nordström wrote:
fre 2012-03-23 klockan 19:49 +0400 skrev Alexander Komyagin:

It seems I finally figured out where the problem is. Squid 3.2.0.16
performs host verification for each request. And this verification
produces the call to libc getaddrinfo() function (converting IP address
from text to numeric in my case), but uClibc implementation of this
functions looks like not aware of AF_HOSTNUMERIC hint flag, thus
performing full lookup (I haven't checked details yet). With RSBAC-Net
turned on it's too much overhead. (Actually there are two calls for such
conversion per request - one more is in url.cc:urlParseFinish()
function)
Why is the overhead with RSBAC-Net that high in this case?

getaddrinfo() is a quite frequenty used call.

But I agree that getaddrinfo for converting textual ip to addrinfo to
compare with resolved hostname may be a bit overkill. Not even sure why
we are converting textual IP to to addrinfo there, we should already
have it in IpAddress internal representaion form.

After adding a special hack for numeric IP address conversion requests
in Squid (avoiding call to real getaddrinfo() in that case), the
performance problem has gone (workers work fine too!).
Good!



And here is the mentioned patch. I guarded it with "#ifdef __UCLIBC__",
so it can be seamlessly integrated into upstream if needed. But still it
would be better to wait until uClibc is fixed.

Also falling back to bundled functions as Amos suggests, in case uClibc
is used, can't be done without some additional modifications to them
(for example, their declarations conflict with ones in netdb.h file,
which can't be dropped).


Thank you for the patch.

Unfortunately we are trying to get all hacks like this out of the main squid code and into compat/*. So ...

compat/getaddrinfo.* are part of the Squid sources, we are free to edit if necessary. Please adjust them in-place to add what alterations are needed by uClibC, inside the appropriate #if wrappings of course, and add a change entry at the top.
 That removes the need for a special new hack file and __* definitions.

We will also have to figure out some way to make ./configure detect uclibc and link the getaddr* files to compat as needed. In absence of that, #include "compat/getaddrinfo.c" can be done in compat/compat.cc within special case #if wrappings.

Amos

Reply via email to