On Tue, 2012-04-03 at 17:10 +0200, Bernhard Reutner-Fischer wrote: > On 3 April 2012 16:48, Alexander Komyagin <[email protected]> wrote: > > Hello! > > > > I found out that getaddrinfo() function in uclibc may cause performance > > downgrades for some heavy-loaded services (e.g. squid) due to > > unnecessary calls to __check_pf() (and hence getifaddrs() ). Really > > these calls only needed when AI_ADDRCONFIG hint flag is given. > > > > For example, squid uses getaddrinfo() to convert IP addresses from > > textual to numeric form, providing just AI_NUMERICHOST hint flag. You > > can imagine how many calls there are when you have about 1000 requests > > per second and the overhead from netlink communications to kernel every > > time in getifaddrs(). > > yes, good catch. > > > > Small simple patch to fix this issue is attached. > > You forgot the Signed-Off-By line. See http://uclibc.org/developing#contrib > Please resend (with c89 quotes). > TIA! > > > > > > -- > > Best wishes, > > Alexander Komyagin > > > > _______________________________________________ > > uClibc mailing list > > [email protected] > > http://lists.busybox.net/mailman/listinfo/uclibc
Done. -- Best wishes, Alexander Komyagin
>From 7208ecbcccbafce2a659dcd2d12659519906eba4 Mon Sep 17 00:00:00 2001 From: Alexander Komyagin <[email protected]> Date: Wed, 4 Apr 2012 12:58:37 +0400 Subject: [PATCH] getaddrinfo(): avoid call to __check_pf() when not needed __check_pf() function is called from getaddrinfo() and it calls getifaddrs(), which is too much overhead especially if RSBAC-Net is enabled. So with this patch __check_pf() is being called only when AI_ADDRCONFIG hint flag is specified - just when we really need that check. Signed-off-by: Alexander Komyagin <[email protected]> --- libc/inet/getaddrinfo.c | 9 ++++++++- 1 files changed, 8 insertions(+), 1 deletions(-) diff --git a/libc/inet/getaddrinfo.c b/libc/inet/getaddrinfo.c index e7511f6..4f9d0cd 100644 --- a/libc/inet/getaddrinfo.c +++ b/libc/inet/getaddrinfo.c @@ -401,7 +401,14 @@ gaih_inet(const char *name, const struct gaih_service *service, int rc; int v4mapped = (req->ai_family == PF_UNSPEC || req->ai_family == PF_INET6) && (req->ai_flags & AI_V4MAPPED); - unsigned seen = __check_pf(); + + //"seen" variable won't be used if AI_ADDRCONFIG is + // not specified. So avoid unnecessary call to __check_pf() + // since it can be costly esp. when RSBAC-Net is enabled. + unsigned seen = 0; + if (req->ai_flags & AI_ADDRCONFIG) { + seen = __check_pf(); + } memset(&nullserv, 0, sizeof(nullserv)); -- 1.7.1
_______________________________________________ uClibc mailing list [email protected] http://lists.busybox.net/mailman/listinfo/uclibc
