On Jul 7, 2004, at 2:13 PM, Matthew D. Fuller wrote: > On Wed, Jul 07, 2004 at 10:25:58AM -0700 I heard the voice of > Brooks Davis, and lo! it spake thus: [ ...with regard to Colin's proposal to make /etc/services much larger... ] >> Can you check how much this change slows down inetd startup with a >> few services enabled? The traditional argument against this is that >> reading the whole IANA service file takes too long. If the >> difference isn't measurable, the the argument is bogus, but I'm not >> sure that's the case. Oh, the difference is easy to measure: a trivial program which calls getservbyport() for the first 1000 ports takes 2.17 seconds to run with the 73K /etc/services file. Using a 106K services file from nmap-3.51 takes 2.95 seconds. Using a 587K /etc/services file from http://www.iana.org/assignments/port-numbers gives a time of 16.85 seconds, so the lookup time seems to be closely linear to the file size, about 2.8 ms per lookup per 100K worth of /etc/services file, at least on the machine I was using to test. :-) >> The alternative solution would be to add >> optional database backing. That shouldn't be too hard to do, and >> there are several examples to work from. > > In theory, any program reading the data should be using > getservby{name,port}() and friends, since it avoids code duplication > and handles NIS and such already. So, hashing it into a DB and fixing > those functions to match would probably work. Matthew is exactly correct, programs should be using getservby*(). Lots of systems implement some external caching system (nscd, lookupd, etc) which those library calls access rather than iterating through the /etc/services file and related sources directly within each process which calls getservby*(). I'm not sure whether the sources for Solaris' nscd are handy, but I believe the sources for lookupd and friends are at: http://developer.apple.com/darwin/projects/opendirectory/ -- -Chuck PS: Sources for the trivial program mentioned above: #include <netdb.h> int main(int argc, char *argv[]) { int port; struct servent *se; for (port = 1; port <= 1000; port++) { se = getservbyport(port, "tcp"); } }Received on Wed Jul 07 2004 - 18:49:19 UTC
This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:00 UTC