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] Implementation of several micro-optimizations #123

Merged
merged 11 commits into from
May 26, 2023

Conversation

fako1024
Copy link
Collaborator

The following high-level changes are incorporated in this PR (see also the issue #83 for details / numbers):

  • Switch packet capture to IP layer / zero-copy mode (less data to process, minimization of copies / allocations)
  • Removal of GPPacket layer (instead direct interaction with the flow map, saves overhead and simplifies code)
  • Removal ob obsolete select {} statement in core processing routine (this has been bothering me from the beginning - with the new two-way lock concept it's simply not necessary anymore)
  • Several tiny improvements (like compiler hints and a removal of a few allocations in the inner loops where it might count)

@els0r I'll add a few comments in the code as usual for brevity, feel free to ping me if any further questions arise.

Final sidenote: I even tried to replace the whole map[string]*GPFlow logic with the new hashmap - it looked promising at first, but it turns out that using *GPFlow pointers as map values (and then changing counters on the pointers directly) significantly outweighs the improvements that come from the hashmap. As soon as there are more than a few items in the map the additional lookups required to change the values (even in place) bring me on par with the current implementation at best (while being less readable), so I decided to skip that.

@fako1024 fako1024 added feature New feature or request performance Performance / optimization related topics labels May 24, 2023
@fako1024 fako1024 added this to the v4 Release milestone May 24, 2023
@fako1024 fako1024 requested a review from els0r May 24, 2023 14:24
@fako1024 fako1024 self-assigned this May 24, 2023
@fako1024 fako1024 linked an issue May 24, 2023 that may be closed by this pull request
6 tasks
pkg/capture/capture.go Show resolved Hide resolved
pkg/capture/capturetypes/packet.go Show resolved Hide resolved
pkg/capture/capturetypes/packet.go Show resolved Hide resolved
pkg/capture/flow.go Show resolved Hide resolved
pkg/capture/flow.go Show resolved Hide resolved
pkg/capture/packet_test.go Show resolved Hide resolved
pkg/types/hashmap/hashmap_test.go Outdated Show resolved Hide resolved
Copy link
Owner

@els0r els0r left a comment

Choose a reason for hiding this comment

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

Me gusta.

Would be great if you can do the rename of GPFlow to Flow

pkg/capture/capture.go Outdated Show resolved Hide resolved
pkg/capture/capture.go Show resolved Hide resolved
pkg/capture/capturetypes/packet.go Outdated Show resolved Hide resolved
pkg/capture/flow.go Outdated Show resolved Hide resolved
@fako1024
Copy link
Collaborator Author

Me gusta.

Would be great if you can do the rename of GPFlow to Flow

All done, thanks for the feedback!

@fako1024 fako1024 merged commit 807d2fb into develop May 26, 2023
@fako1024 fako1024 deleted the 83-micro-optimization-collection-issue branch May 26, 2023 07:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request performance Performance / optimization related topics
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Micro-optimization collection issue
2 participants