[Bug 263604] ifconfig: Low performance with many interface/IP

From: <bugzilla-noreply_at_freebsd.org>
Date: Wed, 27 Apr 2022 09:32:19 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=263604

            Bug ID: 263604
           Summary: ifconfig: Low performance with many interface/IP
           Product: Base System
           Version: Unspecified
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Some People
          Priority: ---
         Component: bin
          Assignee: bugs@FreeBSD.org
          Reporter: dl@CyberPunk.ru

Created attachment 233531
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=233531&action=edit
ifconfig: disabled sort-grouping patch

Colleagues, Good Day.

We have several service routers FreeBSD with thousands of interfaces and
IP-addresses. With more than a thousand interfaces/IP, the command ifconfig
execution speed degrades.

The problem occurred when making the inet/inet6 grouping on each interface. The
change was in:
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=197270
https://svnweb.freebsd.org/base?view=revision&revision=278080
https://cgit.freebsd.org/src/commit/sbin/ifconfig/ifconfig.c?id=35c73e51cc801af670588c3fc7e72dc612d5a746

If you remove the call to the sort-grouping function sortifaddrs() in main(),
then the degradation of performance disappears. See attached patch
ifconfig_sort_disabled.patch .

Judging by the document https://wiki.freebsd.org/BootTime , the development
team is struggling to reduce the system boot time. I assure you, disabling
grouping in ifconfig significantly reduces the system boot time with thousands
of interfaces. I hope the development team will be interested in disabling
grouping in "some cases" to speed up the download. It may be possible to
implement disabling grouping by some ifconfig option used at the time of
loading in scripts rc.d.

Thanks. Peaceful sky.


Example.

Router have 1407 IP-addresses on 3597 interfaces.
ifconfig -a | grep inet | wc -l ; ifconfig -l | wc -w
1407
3597

Execute original ifconfig. Have 1.481 seconds user time.
time ifconfig vlan430
vlan430: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
        description: OPTIC-BBN
        options=600003<RXCSUM,TXCSUM,RXCSUM_IPV6,TXCSUM_IPV6>
        ether a0:36:9f:11:d6:30
        inet 10.250.234.96 netmask 0xffffff00 broadcast 10.250.234.255 
        groups: vlan CoNet 
        vlan: 430 vlanpcp: 0 parent interface: lagg0
        media: Ethernet autoselect
        status: active
1.481u 0.007s 0:01.91 77.4%     144+216k 0+0io 0pf+0w

Execute after patch ifconfig. Have 0.000 seconds user time.
time ifconfig vlan430
vlan430: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
        description: OPTIC-BBN
        options=600003<RXCSUM,TXCSUM,RXCSUM_IPV6,TXCSUM_IPV6>
        ether a0:36:9f:11:d6:30
        inet 10.250.234.96 netmask 0xffffff00 broadcast 10.250.234.255 
        groups: vlan CoNet 
        vlan: 430 vlanpcp: 0 parent interface: lagg0
        media: Ethernet autoselect
        status: active
0.000u 0.010s 0:00.01 100.0%    224+336k 0+0io 0pf+0w

-- 
You are receiving this mail because:
You are the assignee for the bug.