Date: Tue, 22 Apr 2014 17:03:01 -0700 From: Nick Rogers <ncrogers@gmail.com> To: George Neville-Neil <gnn@neville-neil.com> Cc: freebsd-hackers@freebsd.org, Vladislav Prodan <universite@ukr.net> Subject: Re: arp(8) performance - use if_nameindex() instead of if_indextoname() Message-ID: <CAKOb=YZ9HFRwVnhDGW-JJu9LEmjJBJTFC74jAhQFPAx65-Ka-w@mail.gmail.com> In-Reply-To: <EC798989-5D80-425D-A97D-4230BC70CF27@neville-neil.com> References: <CAKOb=YaNqG3GBAomp%2Bm6ab%2B8vrdJ2s%2BApGXYM3GHHTYz83_XqA@mail.gmail.com> <1395953784.953193393.sslrpyfe@frv35.fwdcdn.com> <EC798989-5D80-425D-A97D-4230BC70CF27@neville-neil.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, Apr 5, 2014 at 1:44 PM, George Neville-Neil <gnn@neville-neil.com> wrote: > > On Mar 27, 2014, at 16:59 , Vladislav Prodan <universite@ukr.net> wrote: > >> >>> I propose that instead of calling if_indextoname() for every entry, >>> we leverage if_nameindex() to obtain a cache of if_index to if_name >>> mappings, before printing all the entries. This results in a >>> considerable performance improvement for my situation, and also >>> handles the case that was "fixed" in the commit I just mentioned. >>> >>> I took a shot at this and came up with the following diff against >>> HEAD. I used routed's route6d.c as a reference, which is the only >>> thing I could find utilizing if_nameindex(). I am currently using this >>> in production environments with great success. >>> >> >>> The following illustrates the performance improvement: >>> >>> [root@vm ~/arp]# ifconfig -a | grep vlan | grep interface | wc -l >>> 1500 >>> >>> [root@vm ~/arp]# arp -na | wc -l >>> 1503 >>> >>> [root@vm ~/arp]# time /usr/sbin/arp.old -na > /dev/null >>> >>> real 0m5.529s >>> user 0m0.813s >>> sys 0m4.231s >>> >>> [root@vm ~/arp]# time /usr/sbin/arp -na > /dev/null >>> >>> real 0m0.011s >>> user 0m0.008s >>> sys 0m0.002s >>> [root@vm ~/arp]# >>> >>> >>> I realize this may not be the cleanest way of implementing >>> if_nameindex within arp.c. I'm hoping Max Laier or someone else can >>> help me out (again) and get an adequate fix committed. Thanks! >>> >> >> >> Thanks, it works. >> > > I=E2=80=99ll look at this patch and either update or commit it after some= private testing. I noticed you committed it. Thanks! > > Best > George > >
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAKOb=YZ9HFRwVnhDGW-JJu9LEmjJBJTFC74jAhQFPAx65-Ka-w>