Perf improvements#7
Merged
Merged
Conversation
- CoDel ring buffer initial capacity from 128 to 4 - linkDriver packet channel buffer from 1024 to 32
Write raw IP bytes and port directly to the hash instead of calling addr.String() which allocates. Falls back to String() for other types.
container/heap.Push/Pop box values into interface{}, causing allocations
on every packet. Direct push/pop methods on packetHeap eliminate this.
Total allocations: 4.57 GB -> 4.44 GB (-3%).
Pass packets by pointer through the entire pipeline: channels, queues, routers, and delivery. Avoids copying the 40-byte Packet struct (2 interfaces + 1 slice header) at every handoff.
string(addr.IP) allocates on every map lookup. A [16]byte array with length field is allocation-free and still works as a map key.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Mostly around reducing allocations. Commits are meaningful. Lots of help from Claude in making the changes and adding Benchmarks.