Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Linux performance of GetAllInterfaces #47

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

wjordan
Copy link

@wjordan wjordan commented Jan 30, 2023

This Linux-specific optimization avoids a separate Netlink dump of addresses for each individual interface, which is prohibitively slow on servers with a large number (thousands) of network interfaces.

Here are some example test results on a sample server using the sockaddr eval command (which provides sockaddr.GetAllInterfaces() as template data), showing a ~100x performance improvement:

$ ls /sys/class/net | wc -l
3202

$ time ./sockaddr-orig eval 0
0

real	1m3.956s
user	0m36.514s
sys	0m55.716s

$ time ./sockaddr-opt eval 0
0

real	0m0.457s
user	0m0.096s
sys	0m0.443s

See golang/go#53660 for further discussion of this Linux performance issue with net.Interface.

This Linux optimization avoids a separate Netlink dump of addresses for each individual interface,
which is prohibitively slow on servers with large numbers of interfaces.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants