Date: Thu, 27 Mar 2014 22:59:12 +0200 From: Vladislav Prodan <universite@ukr.net> To: Nick Rogers <ncrogers@gmail.com> Cc: freebsd-hackers@freebsd.org Subject: Re: arp(8) performance - use if_nameindex() instead of if_indextoname() Message-ID: <1395953784.953193393.sslrpyfe@frv35.fwdcdn.com> In-Reply-To: <CAKOb=YaNqG3GBAomp%2Bm6ab%2B8vrdJ2s%2BApGXYM3GHHTYz83_XqA@mail.gmail.com> References: <CAKOb=YaNqG3GBAomp%2Bm6ab%2B8vrdJ2s%2BApGXYM3GHHTYz83_XqA@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
> 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. Can set separate file somewhere? And then somewhere mailing list spoiled formatting patch ... # ngctl list | grep ngeth | wc -l 12003 # ifconfig -a | egrep -e 'inet ' | wc -l 12007 # time /usr/sbin/arp.old -na > /dev/null 150.661u 551.002s 11:53.71 98.3% 20+172k 1+0io 0pf+0w # time /usr/sbin/arp -na > /dev/null 0.114u 0.090s 0:00.14 142.8% 20+170k 0+0io 0pf+0w -- Vladislav V. Prodan System & Network Administrator http://support.od.ua +380 67 4584408, +380 99 4060508 VVP88-RIPE
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1395953784.953193393.sslrpyfe>