[feature] Remove expensive net.Interface lookups upon link initialization #51
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This should alleviate the performance issues encountered on hosts with lots of interfaces. The existing call via
net.Interface
causes a full routing table lookup upon each interface initialization (which is of course especially large on hosts with many interfaces, causing a mean amplification effect). Since we do not require the information therein to setup the ring buffer I've simply replaced the existing implementation with my own lookup based on/sys/class/net
(which I was using to determine the link type before already) so that only the information for the interface in question is accessed an no routing table information is fetched.This of course means that we'd need a different implementation if we ever support more OSes, but I'm sure that would have been the case anyway (because we can't use
AF_PACKET
anywhere else), plus we could always fall back tonet.Interface
in such cases.Closes #50