Repository navigation
Conversation
Tunglies
marked this pull request as ready for review
November 10, 2026 07:24
Tunglies
marked this pull request as draft
November 10, 2026 07:27
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.
Pure-IP UDP packets currently allocate a temporary address string for each lookup in
packetSender.originToTarget. Format the address withnetip.Addr.AppendTointo local scratch space and convert it directly in the map lookup, removing that temporary allocation for ordinary IP addresses.Host precedence, invalid-address handling, persistent map keys, locking, and packet ownership remain unchanged. Long IPv6 zones can grow the temporary slice without truncation. The change is limited to
tunnel/connection.go; it adds no pool, cache, dependency, or public API.Measurements
Measured against
478af2a57c48bdb8e85f6ed93b2c3735e90ceabdon macOS 27.2 / Apple M5 Pro / Go 1.27.3, with identical dependencies. Four paired rounds alternated baseline/candidate order; all measurements ran serially and profiles were collected separately.The fixture calls the actual
processPacketwith warmed mappings and a simulatedPacketConn. It excludes DNS, socket I/O, and payload copying. The figures below describe processing cost, not end-to-end network throughput.GOMAXPROCS=4, one worker cycling through 10 destination keys:Pure workloads use 1400-byte payloads. Mixed traffic is 60% IPv4, 20% IPv6, and 20% domain targets, with 80% 1400-byte, 10% 512-byte, and 10% 64-byte payloads. The smaller payloads belong to the domain cases. Go's integer allocation count truncates the mixed-workload average, so it is omitted here.
Additional runs varied
GOMAXPROCSbetween 1 and 4 and worker count independently between 1 and 4. An initial four-worker domain result was noisy; four longer paired runs gave time changes from −3.0% to +0.2%, without a consistent regression. No domain-path improvement is claimed.For 30 million mixed packets, three fixed-count paired runs reduced median whole-test-process user+system CPU time from 2.05 s to 1.87 s (−8.8%). Maximum RSS ranges overlapped: 18.64–19.07 MB baseline vs. 18.50–19.14 MB patched. This demonstrates reduced allocation churn, not a demonstrated resident-memory reduction or a general mihomo throughput improvement.
Validation
Baseline and patched semantic fixtures passed for IPv4, IPv6, IPv4-mapped IPv6, ordinary and long zones, host precedence, invalid-address fallback, mapping misses, retained output addresses, reverse mapping, and packet drop/deadline behavior. The patched fixtures passed the race detector; the complete application built successfully for native darwin/arm64.