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

[feature] Remove expensive net.Interface lookups upon link initialization #51

Conversation

fako1024
Copy link
Owner

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 to net.Interface in such cases.

Closes #50

@fako1024 fako1024 added enhancement New feature or request performance Performance / optimization related topics labels Jun 26, 2023
@fako1024 fako1024 added this to the Initial Release (v1) milestone Jun 26, 2023
@fako1024 fako1024 self-assigned this Jun 26, 2023
@fako1024 fako1024 linked an issue Jun 26, 2023 that may be closed by this pull request
3 tasks
link/interface_linux.go Fixed Show fixed Hide fixed
@fako1024
Copy link
Owner Author

@els0r PTAL when you have a moment. Once this is merged I'll bump the version in goProbe and together with the changes done in the recent rotation optimization we can take another shot at profiling a 300+ interfaces host for comparison if you like... 😉

@els0r
Copy link
Collaborator

els0r commented Jun 27, 2023

@els0r PTAL when you have a moment. Once this is merged I'll bump the version in goProbe and together with the changes done in the recent rotation optimization we can take another shot at profiling a 300+ interfaces host for comparison if you like... 😉

I sure can :)

@fako1024 fako1024 merged commit a567eb3 into main Jun 28, 2023
@fako1024 fako1024 deleted the 50-source-initialization-requires-expensive-lookup-for-network-interfaces branch June 28, 2023 06:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request performance Performance / optimization related topics
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Source initialization requires (expensive) lookup for network interfaces
2 participants