arp(8) performance - use if_nameindex() instead of if_indextoname()
Vladislav Prodan
universite at ukr.net
Thu Mar 27 20:59:25 UTC 2014
> 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 at vm ~/arp]# ifconfig -a | grep vlan | grep interface | wc -l
> 1500
>
> [root at vm ~/arp]# arp -na | wc -l
> 1503
>
> [root at vm ~/arp]# time /usr/sbin/arp.old -na > /dev/null
>
> real 0m5.529s
> user 0m0.813s
> sys 0m4.231s
>
> [root at vm ~/arp]# time /usr/sbin/arp -na > /dev/null
>
> real 0m0.011s
> user 0m0.008s
> sys 0m0.002s
> [root at 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
More information about the freebsd-hackers
mailing list