|
|
|
|
|
by edwintorok
3730 days ago
|
|
In fact wouldn't it be simpler to just use an array with all 64k destination ports for the 1st level, and a hash based on destination IP for the 2nd level?
This would only need 64k*sizeof(pointer) memory globally for the 1st level, which sounds reasonable for everything except low-memory embedded devices. Or does cache-locality matter here so much that its worth taking the hash-collision penalty on the 1st level? For the 2nd level you could size the hash table appropriately since you always know the maximum number of IP addresses a host has. Would be nice if this 2level array/hash was tunable from /proc or /sys. |
|
Using a binary tree at each bucket could also work well but you would have to rebalance the tree periodically if listeners were inserted in sorted order. A self balancing tree could be used instead but then again this adds complexity.