You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
macos get_interfaces is extremly slow with larger amount of interfaces (sometimes) #143
One clarification from the current codebase: on macOS, interfaces() already uses getifaddrs via unix_interfaces() to enumerate interfaces. However, we also call get_if_type_map() to enrich the data (interface type and display name), and get_if_type_map() internally uses system_configuration::network_configuration::get_interfaces().
So even though the base interface listing itself is fast, the SystemConfiguration lookup still runs each time and may block depending on the environment (for example, configd state, VPNs, or Network Extensions).
I also measured a detailed breakdown on my machines (24 interfaces present), which makes the bottleneck very clear:
Time taken to build SCInterface map (SystemConfiguration): ~13.7 ms
Time taken to enumerate unix interfaces via getifaddrs: ~0.8 ms
Total time for interfaces() (24 interfaces): ~15.5 ms
So the vast majority of the time is spent inside the SystemConfiguration-based lookup. And it’s clear that if network_configuration::get_interfaces() blocks, the total call time will scale accordingly.
We’ll next look into how to avoid this slow path by default while keeping interface type/name information available when possible.
Activity
shellrow commentedon Dec 13, 2025
Thanks for the report and the investigation!
One clarification from the current codebase: on macOS,
interfaces()already usesgetifaddrsviaunix_interfaces()to enumerate interfaces. However, we also callget_if_type_map()to enrich the data (interface type and display name), andget_if_type_map()internally usessystem_configuration::network_configuration::get_interfaces().So even though the base interface listing itself is fast, the
SystemConfigurationlookup still runs each time and may block depending on the environment (for example, configd state, VPNs, or Network Extensions).I also measured a detailed breakdown on my machines (24 interfaces present), which makes the bottleneck very clear:
SystemConfiguration): ~13.7 msgetifaddrs: ~0.8 msinterfaces()(24 interfaces): ~15.5 msSo the vast majority of the time is spent inside the SystemConfiguration-based lookup. And it’s clear that if
network_configuration::get_interfaces()blocks, the total call time will scale accordingly.We’ll next look into how to avoid this slow path by default while keeping interface type/name information available when possible.
dignifiedquire commentedon Dec 13, 2025
Thanks for the quick reply. Following up I did some measurements on my machine, and can confirm your numbers
(funny enough, today it got a bit faster again)
shellrow commentedon Dec 14, 2025
Thanks for running the measurements!
I've implemented a performance improvement on the perf(macos): speed up interface enumeration #144 .
Benchmark results on my machine (22 interfaces):
Before (release):
After (release):
This is 7x speed improvement, with the interface-type and friendly-name resolution itself becoming ~40x faster.
Thanks again!