From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 89F5AC43381 for ; Thu, 14 Feb 2019 00:22:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 50320222D5 for ; Thu, 14 Feb 2019 00:22:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550103776; bh=FG+6znBJuel/+rLdBwHzb7brzMEGyo36Ocq3E9HlFs8=; h=From:To:Cc:Subject:Date:List-ID:From; b=1Q2vZG6mpHXPKTP4v/hMCYq+cngKT+lMehseh1F0uesrx6liMCn9src53xUqNNaS5 av7+q4aS4DKqXSnmqNu994G9FidY4Geo0pNkh02Itl11H8uDRw8G+h9P08TDKu/lmm auK4E+TetcdAMLuAmC/35K9/Tu4B8xfjg5QFMEcY= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388068AbfBNAWv (ORCPT ); Wed, 13 Feb 2019 19:22:51 -0500 Received: from mail.kernel.org ([198.145.29.99]:44072 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726030AbfBNAWv (ORCPT ); Wed, 13 Feb 2019 19:22:51 -0500 Received: from kenny.it.cumulusnetworks.com. (fw.cumulusnetworks.com [216.129.126.126]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 87797222A1; Thu, 14 Feb 2019 00:22:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550103770; bh=FG+6znBJuel/+rLdBwHzb7brzMEGyo36Ocq3E9HlFs8=; h=From:To:Cc:Subject:Date:From; b=YGrxyHeS66VwNYXtvhOXv81+0gjHhlB7f6msuGwtafDOyZ10Cwcx6eI64tJ6CdnmN Gb+Pm/7sgma626aXXBG2brV3pM0hrIcYRoGd/XCSbmQ1xuttSP6JOQyKYug5v80EuG BEXxdKA8q1lcEpCwNP1wyHwSdYaKXIxuV/XWpkKY= From: David Ahern To: stephen@networkplumber.org Cc: netdev@vger.kernel.org, David Ahern 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 Message-Id: <20190214002249.31866-1-dsahern@kernel.org> X-Mailer: git-send-email 2.11.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: David Ahern 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