Selon "Valter Douglas Lisbôa Jr." <[EMAIL PROTECTED]>:

> Em Tuesday 07 October 2008 13:05:44 Dan Nicholson escreveu:
> >
> > Whenever you do a getservbyname(), the glibc resolver has to parse out
> > /etc/services. This happens when you use "http", and the resolver has
> > to decide what port number to use. Likewise, when some program
> > specifies "tcp", the glibc resolver has to parse /etc/protocols to
> > decide what protocol number that corresponds to. So, cutting out the
> > comments just makes the parsing faster. I saw a discussion of this a
> > while ago on a fedora list, but I can't find the link now.
> I follow the thread and found this forums before too.
>
> >
> > You can test this yourself with getent and then try again with a
> > stripped down /etc/services (I didn't bother).
> >
> > $ time { for ((n = 0; n < 100; n++)); do getent services http
> >
> > >/dev/null; done; }
> >
> > real    0m0.098s
> > user    0m0.033s
> > sys     0m0.065s
> >
> > I happen to think the comments are more beneficial than any speedup,
> > but that's just my preference.
> >
> > --
> > Dan
>
> I load the file on cache before the tests!
>
> No Stripped
> time { for ((n = 0; n < 100; n++)); do getent services http > /dev/null;
> done }
>
> real    0m0.110s
> user    0m0.024s
> sys     0m0.084s
>
> Stripped
> time { for ((n = 0; n < 100; n++)); do getent services http > /dev/null;
> done }
>
> real    0m0.106s
> user    0m0.020s
> sys     0m0.084s
>
> Low difference! :(
>
Port 80 is not a good sample for testing, as it should be very near the
beginning of the file, so the most favorable case.

Try with a protocol near the end of the file, difference should be much bigger.

Worst case for the search is with a protocol that is not in the file.
I don't know what happen when resolution fail. Any idea?

Gilles
-- 
http://linuxfromscratch.org/mailman/listinfo/lfs-dev
FAQ: http://www.linuxfromscratch.org/faq/
Unsubscribe: See the above information page

Reply via email to