Skip to content

Perf improvements#7

Merged
MarcoPolo merged 5 commits into
mainfrom
perf-improvements
Mar 31, 2026
Merged

Perf improvements#7
MarcoPolo merged 5 commits into
mainfrom
perf-improvements

Conversation

@MarcoPolo

Copy link
Copy Markdown
Owner

Mostly around reducing allocations. Commits are meaningful. Lots of help from Claude in making the changes and adding Benchmarks.

- 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.
@MarcoPolo MarcoPolo merged commit 4c8b6f9 into main Mar 31, 2026
1 check passed
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.

1 participant