Subject: PCB hashing - performance improvement?
To: None <tech-net@NetBSD.ORG>
From: Dan S. Decasper <dan@tik.ee.ethz.ch>
List: tech-net
Date: 01/15/1997 12:14:32
I've just saw that PCB demultiplexing for incoming IP packets is done now
using hashing in the first place (e.g. in tcp_input call to
in_pcbhashlookup) before the simple linear list traversal (in_pcblookup). 

The in_pcbhashlookup calls the INPCBHASH macro which looks like this:

#define	INPCBHASH(table, faddr, fport, laddr, lport) \
	&(table)->inpt_hashtbl[(ntohl((faddr)->s_addr) + ntohs((fport)) +
ntohs((lport))) & (table->inpt_hash)]

What raised my attention are the 'ntoh' calls. These are implemented as
function calls (assembler thought) on little-endian machines which are
quite expensive on PENTIUMs as far as I know. 

I'm wondering whether somebody (most likely to person who implemented the
hashing) did some testing with real world data on little-endian machines?
If so, I would be very interested in the results. Does the hashing really
provide a performance improvement?

Thanks,

-Dan