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

arp: optimize interface name resolution #3133

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

Conversation

dswarbrick
Copy link
Contributor

Go net package's net.InterfaceByIndex fetches the entire interface table behind the scenes, despite us specifying the interface index that we are interested in. This results in an exponential amount of rtnetlink traffic (and thus recvfrom syscalls) as the number of interfaces in a host increases.

Fixes: #3075

Copy link
Member

@discordianfish discordianfish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great find! Thanks!

github.com/jsimonetti/rtnetlink provides a high level rtnl wrapper
around the lower level rtnetlink functions, which essentially does all
that we need. The rtnl.Conn.Neighbors uses an internal cache for
resolving interface indexes to names, so it makes at most one rtnetlink
call per interface to resolve the name.

Using this high level wrapper hugely simplifies our code and makes it
easier to understand and maintain.

Fixes: prometheus#3075

Signed-off-by: Daniel Swarbrick <[email protected]>
@maxime1907
Copy link

Any news regarding this PR?

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.

Bug: collector.arp.netlink is super slow to retrieve metrics
4 participants