Re: [PATCH] hashed device lookup (Does NOT meet Linus' sumission policy!)

Andi Kleen
2001-01-07T05:28:17Z

On Sat, Jan 06, 2001 at 11:22:41PM -0700, Ben Greear wrote:
> At the time I was doing this, I downloaded the latest nettools version.
> The hashing made a very noticable difference on 4000 interfaces, but
> I haven't run any real solid benchmarkings at other levels. Can
> you tell me some distinguishing mark (version?) on ifconfig that I
> can look for?

Just get the latest release.

>
> I'm willing to run such benchmarks, but what would make a good benchmark,
> other than ifconfig -a?

ifconfig -a is fine IMHO. Everything else I know is just a single pass through
the lists (which even at 4000 is not very significant)

> Suppose I bind a raw socket to device vlan4001 (ie I have 4k in the list
> before that one!!). Currently, that means a linear search on all devices,
> right? In that extreme example, I would expect the hash to be very
> useful.

Nope, it doesn't. Raw binding works via IP addresses, and the IP address resolution
works via the routing table, which is extensively hashed.

Packet socket binding or SO_BINDTODEVICE will search the list, but it is unlikely
that these paths are worth optimizing for.

> Binding to IP addresses have the same issue??

No, uses the fib.

> Also, though hashing by name is not horribly exact, hashing on the device
> index should be nearly perfect, so finding device 666 might take a search
> through only 5 or so devices (find the hash-bucket, walk down the list in
> that bucket).

Just why? It is not in any critical path I can see at all.

-Andi