improve name lookup performance in corner cases
authorRich Felker <dalias@aerifal.cx>
Mon, 2 Apr 2012 03:22:16 +0000 (23:22 -0400)
committerRich Felker <dalias@aerifal.cx>
Mon, 2 Apr 2012 03:22:16 +0000 (23:22 -0400)
the buffer in getaddrinfo really only matters when /etc/hosts is huge,
but in that case, the huge number of syscalls resulting from a tiny
buffer would seriously impact the performance of every name lookup.

the buffer in __dns.c has also been enlarged a bit so that typical
resolv.conf files will fit fully in the buffer. there's no need to
make it so large as to dominate the syscall overhead for large files,
because resolv.conf should never be large.

src/network/__dns.c
src/network/getaddrinfo.c

index 786c054..1464513 100644 (file)
@@ -29,7 +29,7 @@ int __dns_doqueries(unsigned char *dest, const char *name, int *rr, int rrcnt)
        time_t t0 = time(0);
        int fd;
        FILE *f, _f;
        time_t t0 = time(0);
        int fd;
        FILE *f, _f;
-       unsigned char _buf[64];
+       unsigned char _buf[256];
        char line[64], *s, *z;
        union {
                struct sockaddr_in sin;
        char line[64], *s, *z;
        union {
                struct sockaddr_in sin;
index e5fa519..93c7516 100644 (file)
@@ -61,7 +61,7 @@ int getaddrinfo(const char *host, const char *serv, const struct addrinfo *hint,
        //char hostbuf[256];
        char line[512];
        FILE *f, _f;
        //char hostbuf[256];
        char line[512];
        FILE *f, _f;
-       unsigned char _buf[64];
+       unsigned char _buf[1024];
        char *z;
        int result;
        int cnt;
        char *z;
        int result;
        int cnt;