netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Ahern <dsahern@kernel.org>
To: stephen@networkplumber.org
Cc: netdev@vger.kernel.org, David Ahern <dsahern@gmail.com>
Subject: [PATCH iproute2-next v2 0/3] Improve batch and dump times by caching link lookups
Date: Wed, 13 Feb 2019 16:22:46 -0800	[thread overview]
Message-ID: <20190214002249.31866-1-dsahern@kernel.org> (raw)

From: David Ahern <dsahern@gmail.com>

Many commands convert device names to an index using ll_name_to_index and
the reverse from an index to a name using ll_index_to_name.

At the moment both of the ll_ functions use the ioctl based helpers from
glibc which involves opening socket, calling ioctl and then closing the
socket on each device lookup. When using a batch file or dumping large
number of routes this means the same device lookups can be done repeatedly
adding unnecessary overhead to both operations.

This series adds a new function, ll_link_get, to send a netlink based
RTM_GETLINK. If successful, the result is cached in idx_head and name_head
so future lookups can re-use the entry. iproute2's ll_map functions are
updated to use ll_link_get over the glibc functions. The result is a
significant speed up in both batch and dumps with negligible overhead if
ip is invoked for single operations.

The first 2 patches add a means to drop an entry from the cache and updates
iplink_modify to use that new function to drop entries on device changes.
This forces the cache to re-learn device information if a batch file has a
mix of link set operations with other commands - such as adding a route.

v2
- changed the second patch to drop cache entry on any link changes
- added ll_link_get to index to name conversion improving dumps

David Ahern (3):
  ll_map: Add function to remove link cache entry by index
  ip link: Drop cache entry on any changes
  Improve batch and dump times by caching link lookups

 include/ll_map.h |  1 +
 ip/iplink.c      |  3 +++
 lib/ll_map.c     | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 3 files changed, 69 insertions(+), 1 deletion(-)

-- 
2.11.0


             reply	other threads:[~2019-02-14  0:22 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-14  0:22 David Ahern [this message]
2019-02-14  0:22 ` [PATCH iproute2-next v2 1/3] ll_map: Add function to remove link cache entry by index David Ahern
2019-02-14  0:22 ` [PATCH iproute2-next v2 2/3] ip link: Drop cache entry on any changes David Ahern
2019-02-14  0:22 ` [PATCH iproute2-next v2 3/3] Improve batch and dump times by caching link lookups David Ahern

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=20190214002249.31866-1-dsahern@kernel.org \
    --to=dsahern@kernel.org \
    --cc=dsahern@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=stephen@networkplumber.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).