All of lore.kernel.org
 help / color / mirror / Atom feed
* RFC udp: improve __udp4_lib_lookup performance
@ 2012-04-12 13:35 Alexandru Copot
  2012-04-12 14:00 ` Eric Dumazet
  0 siblings, 1 reply; 2+ messages in thread
From: Alexandru Copot @ 2012-04-12 13:35 UTC (permalink / raw)
  To: netdev

UDP uses 2 hashtables for fast socket lookup. First hash uses port as
a lookup key and the second one uses (port, addr).

When an UDP packet is received, the destination socket must be found to
deliver it. If there are many UDP sockets bound to INADDR_ANY, 2 hash
searches are made in the second hash: first one looks for the pair
(dest address, dest port) but doesn't find the socket; the second search
finds the socket by hashing (INADDR_ANY, dest port).

Those 2 searches can be avoided and a lot of time saved if instead we
searched directly in the first hash.

We could count the number of INADDR_ANY bound UDP sockets and
make only one search when that value is above a certain threshold. However,
if there are also sockets bound on a specific address, the second hash
won't be used and that might hurt performance for this case.

What is your opinion on this ? Would the performance gained by
counting INADDR_ANY bound sockets outweigh the loss in performance
for the case of mixed INADDR_ANY/specific address bound sockets ?

Alexandru Copot

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: RFC udp: improve __udp4_lib_lookup performance
  2012-04-12 13:35 RFC udp: improve __udp4_lib_lookup performance Alexandru Copot
@ 2012-04-12 14:00 ` Eric Dumazet
  0 siblings, 0 replies; 2+ messages in thread
From: Eric Dumazet @ 2012-04-12 14:00 UTC (permalink / raw)
  To: Alexandru Copot; +Cc: netdev

On Thu, 2012-04-12 at 16:35 +0300, Alexandru Copot wrote:
> UDP uses 2 hashtables for fast socket lookup. First hash uses port as
> a lookup key and the second one uses (port, addr).
> 
> When an UDP packet is received, the destination socket must be found to
> deliver it. If there are many UDP sockets bound to INADDR_ANY, 2 hash
> searches are made in the second hash: first one looks for the pair
> (dest address, dest port) but doesn't find the socket; the second search
> finds the socket by hashing (INADDR_ANY, dest port).
> 
> Those 2 searches can be avoided and a lot of time saved if instead we
> searched directly in the first hash.
> 
> We could count the number of INADDR_ANY bound UDP sockets and
> make only one search when that value is above a certain threshold. However,
> if there are also sockets bound on a specific address, the second hash
> won't be used and that might hurt performance for this case.
> 
> What is your opinion on this ? Would the performance gained by
> counting INADDR_ANY bound sockets outweigh the loss in performance
> for the case of mixed INADDR_ANY/specific address bound sockets ?

I have no idea of your workload, but existing code is already very
optimized.

udp4_lib_lookup2() variants are only called when (hslot->count > 10)

If your workload have one 60000 UDP sockets bound on INADDR_ANY, I
suggest you check udp hash size and eventually increase it to the max ?

dmesg | grep "UDP hash"

Boot command : uhash_entries=65536

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-04-12 14:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-12 13:35 RFC udp: improve __udp4_lib_lookup performance Alexandru Copot
2012-04-12 14:00 ` Eric Dumazet

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.