All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexandru Copot <alex.mihai.c@gmail.com>
To: netdev@vger.kernel.org
Subject: RFC udp: improve __udp4_lib_lookup performance
Date: Thu, 12 Apr 2012 16:35:03 +0300	[thread overview]
Message-ID: <CAHG7+CAt_YjxUp6+u9J47Ti1HA6hh_UkRMWQsXw4AsbEkvCu7w@mail.gmail.com> (raw)

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

             reply	other threads:[~2012-04-12 13:35 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-12 13:35 Alexandru Copot [this message]
2012-04-12 14:00 ` RFC udp: improve __udp4_lib_lookup performance Eric Dumazet

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAHG7+CAt_YjxUp6+u9J47Ti1HA6hh_UkRMWQsXw4AsbEkvCu7w@mail.gmail.com \
    --to=alex.mihai.c@gmail.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.