Hash lookups during startup
Ted Lemon
Ted.Lemon at nominum.com
Sun Feb 2 20:46:23 UTC 2003
> What I'm looking for is some advice on how best to tackle this issue.
> I can
> see two possible options: find a different hashing algorithm that will
> distribute the above data better, or use insertion sort on the bucket
> chain.
> The problem with finding a different algorithm from my understanding is
> finding one that will work well for many types of data (as is the
> requirement for this case). The issue with the insertion sort is the
> scope
> of the changes required and how that might impact the rest of the
> code. The
> best solution from my perspective is an insertion sort on the chain.
Probably the right thing to do is to hack the hash code to use
different hash functions in different circumstances, and *then* come up
with a better hash function for IP addresses. It should be pretty
easy to do this - just make the hash function a pointer off the hash
table.
Another thing to consider would be inlining a lot of this code to avoid
pipeline stalls - because the code does a lot of function calls, it's
probably stalling the pipeline a lot, particularly on architectures
with pathologically deep pipelines like the Pentium 4. I don't know
how much benefit you can get from this in this section of code, but if
it's really a critical section it's worth considering.
More information about the dhcp-hackers
mailing list