From: Eric Dumazet Subject: Re: [PATCH iproute2-next] Improve batch times by caching link lookups Date: Mon, 7 Jan 2019 13:06:14 -0800 Message-ID: <0501c779-1443-702c-af7f-258e1cb05d17@gmail.com> References: <20190107204130.32144-1-dsahern@kernel.org> <9f8a0935-2f4c-74e8-038d-61e3b5049f12@gmail.com> <89099221-ca87-3298-47bf-b8e68403c2b2@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Cc: netdev@vger.kernel.org To: David Ahern , David Ahern , stephen@networkplumber.org Return-path: Received: from mail-ed1-f67.google.com ([209.85.208.67]:37285 "EHLO mail-ed1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726767AbfAGVGS (ORCPT ); Mon, 7 Jan 2019 16:06:18 -0500 Received: by mail-ed1-f67.google.com with SMTP id h15so2241240edb.4 for ; Mon, 07 Jan 2019 13:06:17 -0800 (PST) In-Reply-To: <89099221-ca87-3298-47bf-b8e68403c2b2@gmail.com> Content-Language: en-US Sender: netdev-owner@vger.kernel.org List-ID: On 01/07/2019 12:58 PM, David Ahern wrote: > On 1/7/19 1:57 PM, Eric Dumazet wrote: >> >> >> On 01/07/2019 12:41 PM, David Ahern wrote: >>> From: David Ahern >>> >>> ip route uses ll_name_to_index to convert the user given device name to an >>> index. At the moment ll_name_to_index uses if_nametoindex which is ioctl >>> based and does not cache the result. When using a batch file this means >>> the same device lookups can be done repeatedly adding unnecessary overhead >>> (socket + ioctl call for each device lookup). >>> >>> Add a new function, ll_link_get, to send a netlink based RTM_GETLINK. If >>> successful, cache the result in idx_head and name_head so future lookups >>> can re-use the entry. >>> >>> With this change the time to install routes via a batch file is reduced >>> from 30.7 seconds to 17.6 seconds (720,022 routes with 2 ecmp nexthops >>> where the nexthop device is given). >>> >> >> What time increase if we have 10,000 devices, and install one route ? >> >> Caching 10,000 devices would be quite a waste. >> > > It only lookups up the device if ll_name_to_index is invoked for the > device. > > This is NOT a link dump and cache; it only adds lookups to the cache. > I see, maybe split this in two patches to avoid the confusion. Why is the RTNETLINK approach better than ioctl() ? If this is the case, maybe if_nametoindex() should be fixed, instead of carrying this locally in iproute2.