mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[PR #7037] [CLOSED] perf(amneziawg): reuse relay buffers, bound the bridge connect time #6592
Labels
No labels
backlog
bug
clarification needed
documentation
duplicate
enhancement
github_actions
good first issue
invalid
javascript
New Feature
PR welcomed
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
MHSanaei/3x-ui#6592
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/MHSanaei/3x-ui/pull/7037
Author: @Dv2Corn
Created: 11/1/2026
Status: ❌ Closed
Base:
main← Head:perf/amneziawg-relay-buffers📝 Commits (4)
0f555afamneziawg: reuse relay buffers, bound the bridge connect time3565b47test(amneziawg): bound and reset of the bridge CONNECT deadlinee05cf65test(amneziawg): no shared buffer between test goroutines; skip the pool check under -race3c2f447fix(amneziawg): keep the raw bridge conn so a client half-close reaches upstream📊 Changes
6 files changed (+464 additions, -10 deletions)
View changed files
📝
internal/amneziawgnet/egress.go(+2 -2)➕
internal/amneziawgnet/race_off_test.go(+5 -0)➕
internal/amneziawgnet/race_on_test.go(+5 -0)📝
internal/amneziawgnet/relay.go(+59 -8)➕
internal/amneziawgnet/relay_halfclose_test.go(+214 -0)📝
internal/amneziawgnet/relay_test.go(+179 -0)📄 Description
Every connection through the built-in AmneziaWG allocated two new 32 KiB buffers:
net.TCPConnbypasses the buffer passed toio.CopyBufferviaReadFrom/WriteTo. Under a stream of short connections this is gigabytes of garbage and a bloated panel heap.Buffers now come from a
sync.Pool, and the SOCKS handshake with the Xray bridge is limited to 10 s so a silent core cannot hold a connection.Load test (300 AWG + 300 VLESS clients, 200 short connections/s through AWG, 15 min): panel memory average 462 MB → 240 MB, peak 510 → 250 MB. Heap profile before the fix: ~5.1 GB allocated in
io.copyBuffer.Tests:
internal/amneziawgnet/relay_test.go;go test ./internal/amneziawgnet/...passes.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.