[GH-ISSUE #6378] AmneziaWG: would an opt-in kernel-module datapath be considered? #4329

Open
opened 2026-10-31 20:38:51 +07:00 by bsakaguchi · 4 comments
Owner

Originally created by @YoungReckless4 on GitHub (Aug 31, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6378

PR #6105's update from 2026-08-21 explains why the DKMS module was dropped in favour of embedding
amneziawg-go over gVisor, and the reasoning is sound. I'd like to ask whether an opt-in
kernel datapath, off by default, would be considered — because two of the three premises have moved
since that decision, and I have measurements.

I'm not asking you to take a large patch sight-unseen. I have a working implementation running in
production, but I'd rather hear whether there's any appetite before proposing anything.

What has changed

The protocol lag is closed. The PR notes the 3.1 parameter set landed in amneziawg-go /
amneziawg-tools "well before the kernel module + DKMS package caught up". The kernel module is now
at v3.1.20260828 and supports the full 3.1 set. I verified this on a live interface — awg show
reports s3, s4, content padding addition, random trailers: on, disable cookies: on, and
awg-quick strip | awg setconf accepts H1..H4 = 1..4 as the panel's own client emitters write
them:

interface: awg0
  jc: 4   jmin: 50   jmax: 200
  s1: 30  s2: 70     s3: 25   s4: 15
  header protection key: <set>
  content padding addition: 10-40
  random trailers: on
  disable cookies: on

(values above are illustrative, not from a live deployment)

The throughput tradeoff does not hold for a bulk-transfer profile. The PR says the gap was
measured and "judged acceptable for this protocol's realistic usage pattern (many lower-throughput,
latency-bound connections, not sustained bulk transfer)". That is a fair call for the common case,
but it is the wrong side of the tradeoff for anyone whose users actually pull large files.

Measured on the same host, same inbound, same clients, same port and the same 3.1 parameters — only
the datapath differs (1 vCPU QEMU, Debian 13, kernel 7.1.11-x64v3-xanmod1):

Datapath Peak server→client CPU at that point
Embedded (amneziawg-go + gVisor) 124.6 Mbit/s 50–63% of the single core
Kernel module 190.1 Mbit/s core 70% idle, softirq ~10%

Single-stream on the embedded path sat at 50–86 Mbit/s while the core was 80% idle, so it is not
simply CPU-bound — the userspace path costs both throughput and headroom.

What it would cost, honestly

Your installer-fragility argument is the one I'd defend rather than dispute — I hit it directly:

  • the host kernel was clang-built, so DKMS invoked the module build with LLVM=1 and it failed
    until clang/lld/llvm were installed;
  • kernel ≥ 7.1.5 changed setup_udp_tunnel_sock / udp_tunnel_sock_release to take struct sock *,
    so the module needs a four-call source patch to build at all;
  • Debian has no package, so it has to be built from source.

Secure Boot remains a hard stop. All of that argues for keeping the embedded path as the default and
gating the kernel one behind a host-readiness check that refuses to enable it when the module,
tools or nftables are missing.

The second cost is structural: a kernel interface never reaches Xray, so per-client traffic
accounting, traffic limits and the IP limit all need a parallel path (per-peer counters from
awg show dump, limits enforced by removing the peer, and limitIp reinterpreted as endpoint
roaming since there is no access log). That is real ongoing maintenance surface, and it is the part
I'd expect you to weigh most heavily.

The question

Would you consider an opt-in, off-by-default kernel datapath with a preflight gate, or is the
single-implementation simplicity worth more than the throughput to you? Either answer is useful —
if it's no, I'll keep it in a fork and stop there.

Separately, #6376 fixes a bug found while measuring this: the default MTU does not account for S4, so inbounds generated with S4 ≥ 21 fragment every full-size packet.

Originally created by @YoungReckless4 on GitHub (Aug 31, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6378 PR #6105's update from 2026-08-21 explains why the DKMS module was dropped in favour of embedding `amneziawg-go` over gVisor, and the reasoning is sound. I'd like to ask whether an **opt-in** kernel datapath, off by default, would be considered — because two of the three premises have moved since that decision, and I have measurements. I'm not asking you to take a large patch sight-unseen. I have a working implementation running in production, but I'd rather hear whether there's any appetite before proposing anything. ### What has changed **The protocol lag is closed.** The PR notes the 3.1 parameter set landed in `amneziawg-go` / `amneziawg-tools` "well before the kernel module + DKMS package caught up". The kernel module is now at `v3.1.20260828` and supports the full 3.1 set. I verified this on a live interface — `awg show` reports `s3`, `s4`, `content padding addition`, `random trailers: on`, `disable cookies: on`, and `awg-quick strip | awg setconf` accepts `H1..H4 = 1..4` as the panel's own client emitters write them: ``` interface: awg0 jc: 4 jmin: 50 jmax: 200 s1: 30 s2: 70 s3: 25 s4: 15 header protection key: <set> content padding addition: 10-40 random trailers: on disable cookies: on ``` *(values above are illustrative, not from a live deployment)* **The throughput tradeoff does not hold for a bulk-transfer profile.** The PR says the gap was measured and "judged acceptable for this protocol's realistic usage pattern (many lower-throughput, latency-bound connections, not sustained bulk transfer)". That is a fair call for the common case, but it is the wrong side of the tradeoff for anyone whose users actually pull large files. Measured on the same host, same inbound, same clients, same port and the same 3.1 parameters — only the datapath differs (1 vCPU QEMU, Debian 13, kernel 7.1.11-x64v3-xanmod1): | Datapath | Peak server→client | CPU at that point | |---|---|---| | Embedded (`amneziawg-go` + gVisor) | 124.6 Mbit/s | 50–63% of the single core | | Kernel module | 190.1 Mbit/s | core 70% idle, softirq ~10% | Single-stream on the embedded path sat at 50–86 Mbit/s while the core was 80% idle, so it is not simply CPU-bound — the userspace path costs both throughput and headroom. ### What it would cost, honestly Your installer-fragility argument is the one I'd defend rather than dispute — I hit it directly: - the host kernel was clang-built, so DKMS invoked the module build with `LLVM=1` and it failed until `clang`/`lld`/`llvm` were installed; - kernel ≥ 7.1.5 changed `setup_udp_tunnel_sock` / `udp_tunnel_sock_release` to take `struct sock *`, so the module needs a four-call source patch to build at all; - Debian has no package, so it has to be built from source. Secure Boot remains a hard stop. All of that argues for keeping the embedded path as the default and gating the kernel one behind a host-readiness check that refuses to enable it when the module, tools or nftables are missing. The second cost is structural: a kernel interface never reaches Xray, so per-client traffic accounting, traffic limits and the IP limit all need a parallel path (per-peer counters from `awg show dump`, limits enforced by removing the peer, and `limitIp` reinterpreted as endpoint roaming since there is no access log). That is real ongoing maintenance surface, and it is the part I'd expect you to weigh most heavily. ### The question Would you consider an opt-in, off-by-default kernel datapath with a preflight gate, or is the single-implementation simplicity worth more than the throughput to you? Either answer is useful — if it's no, I'll keep it in a fork and stop there. Separately, #6376 fixes a bug found while measuring this: the default MTU does not account for S4, so inbounds generated with S4 ≥ 21 fragment every full-size packet.
Author
Owner

@github-actions[bot] commented on GitHub (Aug 31, 2026):

Whether to accept an opt-in kernel datapath is a maintainer call, not one I can make — so rather than guess at the answer, I checked your three premises against the tip of main and pulled out the constraints any such patch would have to satisfy. Two of them hold, one is weaker than it looks, and there is one confound in your measurement plus one cost bigger than the one you flagged.

Where the tree actually stands

The kernel/DKMS path is gone, not deprecated. internal/amneziawg is protocol shape only now (types.go:9: "narrowed to protocol-shape-only after the kernel-module (DKMS) + awg-quick"), internal/amneziawgnet/netstack.go:1-11 owns the datapath, and there is no awg-quick/awg show shell-out anywhere outside doc comments. That landed in #6105 (merged 2026-08-24) and shipped in v3.7.0 (2026-08-24), so the code you would be adding back has exactly one release of distance from it.

Premise 1 (protocol lag closed) — true, but not load-bearing

Your quote is accurate; it is from the #6105 body verbatim. But that argument only reopens the kernel option, it does not put pressure on the embedded one, because the panel no longer depends on anything installed on the host:

go.mod:6   github.com/amnezia-vpn/amneziawg-go/v3 v3.1.20260814

and the docs already say so — docs/content/docs/en/config/amneziawg.mdx:66-70: "There is no host-side version requirement — the panel ships its own pinned amneziawg-go, not whatever happens to be installed on the system." So "the module caught up" is a feasibility argument, not a necessity one. It is the weakest of your three.

One small correction: the panel's emitters never write H1..H4 = 1..4. generateHRanges (internal/amneziawg/params.go:112-127) starts at const lo = 5 — "values 1-4 are reserved for vanilla WireGuard message types" — and amneziawg.mdx:49 documents the same rule.

Premise 2 (throughput) — real, but there are now three numbers and they disagree

Nobody disputed the gap; #6105's own body calls it "a real, substantial gap on a single saturating stream". What is new is that your ratio is nothing like the PR's. Both, as measured:

source embedded kernel ratio
#6105 comment (2026-08-18, same box) 37.02 MB/s up ≈ 296 Mbit/s, 79.98 MB/s down ≈ 640 Mbit/s 414.69 MB/s ≈ 3.3 Gbit/s ~5–10×
yours (1 vCPU QEMU, Debian 13) 124.6 Mbit/s peak 190.1 Mbit/s ~1.5×

I am not going to invent a reason for the disagreement. One documented difference is worth knowing though: the PR's embedded figure explicitly excludes the relay hop — "this number is the core tunnel datapath only (no SOCKS5-relay hop, which is the harder, more representative number but strictly lower)" — whereas yours necessarily includes it, since on main there is no way to bypass it.

The confound I would want removed before this decides anything

At the tip, every generated inbound gets RandomTrailers = true (internal/amneziawg/params.go:94) together with very wide H ranges: generateHRanges splits the space below awgHMax = 2147483647 into four bands of (2147483647-5+1)/4 = 536870910 and picks a random sub-range of at least hMinWidth = 1000 in each (params.go:14-19,112-127) — so a single generated H range can span up to ~12.5% of the uint32 space.

In #6303 that exact combination was traced to amneziawg-go's own receive-path classifier misclassifying full-size transport packets as handshakes, costing a proportional share of throughput. I could not read amneziawg-go's source from this checkout, so I am citing that analysis rather than confirming it — but if it holds, it is a property of the userspace implementation specifically. The kernel module is an independent implementation of the same classifier and would not necessarily pay it.

That matters for your A/B: with the panel's generated defaults left in place on both sides, part of what you measured as "kernel vs. userspace datapath" may be a defect in the current default parameters that is being fixed independently (your own #6376 on the S4/MTU half, #6303 on the RandomTrailers/H-range half). Re-running the same bench with RandomTrailers off and narrow H ranges on both sides would separate the two, and if the gap collapses, the whole proposal costs a lot less to decline.

The structural cost, corrected and enlarged

You have the shape of it right, and it is the part I would also weigh heaviest — but the mechanism is not what you described, and it reaches further than accounting.

The identity that makes all of this work is the SOCKS5 auth username, not a log:

// internal/amneziawgnet/relay.go:1-6
// Phase 2: relaying a recovered tunnel connection into Xray's own,
// completely stock SOCKS5 inbound -- authenticating as the owning peer's
// email -- is what gives every embedded AmneziaWG connection real, native
// Xray stats/routing/sniffing with no Xray-core fork at all

SocksInboundSettings (relay.go:46) emits one account per client email, and injectAmneziawgnetSocks (internal/web/service/xray.go:701-712) creates that inbound per enabled AmneziaWG inbound.

The limitIp point specifically: there is no access log to reinterpret away from anymore. internal/web/job/check_client_ip_job.go:30-33 — "The per-client IPs come from the core's online-stats API; no access log is involved" — and collectFromOnlineAPI skips the run outright when that API is unavailable (:96-99, "there is no access-log fallback"). So a kernel interface would be displacing a gRPC online-stats path, not a log parser, and the same displacement also takes out sniffing, the Routing-page integration and the per-inbound online-client counts, which today are free for exactly the same reason (amneziawg.mdx:17-21).

The constraint your write-up does not mention: multi-node

Every state-changing inbound op dispatches through internal/web/runtime, and the AmneziaWG apply is runtime/local.go:58-93 — it runs on whichever node holds the inbound. Server settings are a per-inbound JSON blob synced to nodes, so a useKernelDatapath bit stored in ServerSettings would be a cluster-wide flag landing on nodes whose host readiness differs; a node without the module would silently serve a dead inbound. A preflight gate would have to be a per-node capability, negotiated at sync time, not a per-inbound setting — which is a materially bigger change than the gate you described, and worth costing before anyone says yes.

What I could not settle

Whether the throughput gap survives once the RandomTrailers/H-range and S4/MTU defaults are corrected. One re-run of your own bench with those neutralised on both datapaths would settle it, and it is the single number that would most change how this proposal reads.

Nothing here commits the project either way — that remains a maintainer decision, and this thread is the right place for it.

Verdict: Feature request

This reply was generated automatically; a maintainer may follow up.

<!-- gh-comment-id:5478290542 --> @github-actions[bot] commented on GitHub (Aug 31, 2026): Whether to accept an opt-in kernel datapath is a maintainer call, not one I can make — so rather than guess at the answer, I checked your three premises against the tip of `main` and pulled out the constraints any such patch would have to satisfy. Two of them hold, one is weaker than it looks, and there is one confound in your measurement plus one cost bigger than the one you flagged. ## Where the tree actually stands The kernel/DKMS path is gone, not deprecated. `internal/amneziawg` is protocol shape only now (`types.go:9`: *"narrowed to protocol-shape-only after the kernel-module (DKMS) + awg-quick"*), `internal/amneziawgnet/netstack.go:1-11` owns the datapath, and there is no `awg-quick`/`awg show` shell-out anywhere outside doc comments. That landed in #6105 (merged 2026-08-24) and shipped in **v3.7.0** (2026-08-24), so the code you would be adding back has exactly one release of distance from it. ## Premise 1 (protocol lag closed) — true, but not load-bearing Your quote is accurate; it is from the #6105 body verbatim. But that argument only reopens the kernel option, it does not put pressure on the embedded one, because the panel no longer depends on anything installed on the host: ``` go.mod:6 github.com/amnezia-vpn/amneziawg-go/v3 v3.1.20260814 ``` and the docs already say so — `docs/content/docs/en/config/amneziawg.mdx:66-70`: *"There is no host-side version requirement — the panel ships its own pinned `amneziawg-go`, not whatever happens to be installed on the system."* So "the module caught up" is a feasibility argument, not a necessity one. It is the weakest of your three. One small correction: the panel's emitters never write `H1..H4 = 1..4`. `generateHRanges` (`internal/amneziawg/params.go:112-127`) starts at `const lo = 5` — *"values 1-4 are reserved for vanilla WireGuard message types"* — and `amneziawg.mdx:49` documents the same rule. ## Premise 2 (throughput) — real, but there are now three numbers and they disagree Nobody disputed the gap; #6105's own body calls it *"a real, substantial gap on a single saturating stream"*. What is new is that your ratio is nothing like the PR's. Both, as measured: | source | embedded | kernel | ratio | |---|---|---|---| | #6105 comment (2026-08-18, same box) | 37.02 MB/s up ≈ 296 Mbit/s, 79.98 MB/s down ≈ 640 Mbit/s | 414.69 MB/s ≈ 3.3 Gbit/s | ~5–10× | | yours (1 vCPU QEMU, Debian 13) | 124.6 Mbit/s peak | 190.1 Mbit/s | ~1.5× | I am not going to invent a reason for the disagreement. One documented difference is worth knowing though: the PR's embedded figure explicitly *excludes* the relay hop — *"this number is the core tunnel datapath only (no SOCKS5-relay hop, which is the harder, more representative number but strictly lower)"* — whereas yours necessarily includes it, since on `main` there is no way to bypass it. ## The confound I would want removed before this decides anything At the tip, every generated inbound gets `RandomTrailers = true` (`internal/amneziawg/params.go:94`) together with very wide H ranges: `generateHRanges` splits the space below `awgHMax = 2147483647` into four bands of `(2147483647-5+1)/4 = 536870910` and picks a random sub-range of at least `hMinWidth = 1000` in each (`params.go:14-19,112-127`) — so a single generated H range can span up to ~12.5% of the uint32 space. In #6303 that exact combination was traced to `amneziawg-go`'s own receive-path classifier misclassifying full-size transport packets as handshakes, costing a proportional share of throughput. I could not read `amneziawg-go`'s source from this checkout, so I am citing that analysis rather than confirming it — but if it holds, it is a property of **the userspace implementation specifically**. The kernel module is an independent implementation of the same classifier and would not necessarily pay it. That matters for your A/B: with the panel's generated defaults left in place on both sides, part of what you measured as "kernel vs. userspace datapath" may be a defect in the current default parameters that is being fixed independently (your own #6376 on the S4/MTU half, #6303 on the `RandomTrailers`/H-range half). Re-running the same bench with `RandomTrailers` off and narrow H ranges on both sides would separate the two, and if the gap collapses, the whole proposal costs a lot less to decline. ## The structural cost, corrected and enlarged You have the shape of it right, and it is the part I would also weigh heaviest — but the mechanism is not what you described, and it reaches further than accounting. The identity that makes all of this work is the SOCKS5 auth username, not a log: ```go // internal/amneziawgnet/relay.go:1-6 // Phase 2: relaying a recovered tunnel connection into Xray's own, // completely stock SOCKS5 inbound -- authenticating as the owning peer's // email -- is what gives every embedded AmneziaWG connection real, native // Xray stats/routing/sniffing with no Xray-core fork at all ``` `SocksInboundSettings` (`relay.go:46`) emits one account per client email, and `injectAmneziawgnetSocks` (`internal/web/service/xray.go:701-712`) creates that inbound per enabled AmneziaWG inbound. The `limitIp` point specifically: there is no access log to reinterpret away from anymore. `internal/web/job/check_client_ip_job.go:30-33` — *"The per-client IPs come from the core's online-stats API; no access log is involved"* — and `collectFromOnlineAPI` skips the run outright when that API is unavailable (`:96-99`, *"there is no access-log fallback"*). So a kernel interface would be displacing a gRPC online-stats path, not a log parser, and the same displacement also takes out sniffing, the Routing-page integration and the per-inbound online-client counts, which today are free for exactly the same reason (`amneziawg.mdx:17-21`). ## The constraint your write-up does not mention: multi-node Every state-changing inbound op dispatches through `internal/web/runtime`, and the AmneziaWG apply is `runtime/local.go:58-93` — it runs on whichever node holds the inbound. Server settings are a per-inbound JSON blob synced to nodes, so a `useKernelDatapath` bit stored in `ServerSettings` would be a **cluster-wide** flag landing on nodes whose host readiness differs; a node without the module would silently serve a dead inbound. A preflight gate would have to be a per-node capability, negotiated at sync time, not a per-inbound setting — which is a materially bigger change than the gate you described, and worth costing before anyone says yes. ## What I could not settle Whether the throughput gap survives once the `RandomTrailers`/H-range and S4/MTU defaults are corrected. One re-run of your own bench with those neutralised on both datapaths would settle it, and it is the single number that would most change how this proposal reads. Nothing here commits the project either way — that remains a maintainer decision, and this thread is the right place for it. Verdict: Feature request *This reply was generated automatically; a maintainer may follow up.* <!-- claude-issue:analyst -->
Author
Owner

@YoungReckless4 commented on GitHub (Aug 31, 2026):

Correction to the throughput figures above — the kernel row understated the result.

The 190 Mbit/s I quoted was the peak of a short run that ended before the transfer had
saturated the link. A sustained single-stream download of a 4 GB file — roughly a minute
of continuous transfer — ran at the client's full line rate:

idle=66.3%  softirq=11.7%  steal=2.4% | eth0 rx=462.0 tx=501.3 Mbit  txpps=47997  txdrop+=0 | awg tx=483.5 Mbit

483 Mbit/s through the tunnel, 501 Mbit/s on the host NIC at ~48k pps, with the single core
still 66% idle and softirq at 11.7%. That is the client's 500 Mbit line, not a server
limit — on the kernel path the datapath was not the bottleneck at all.

Against 124.6 Mbit/s peak on the embedded path for the same client, same line, same inbound
and the same 3.1 parameters, the gap is closer to 4x than the 1.5x implied above.

My earlier figure was wrong because I armed the sampler near the end of that transfer, saw
throughput fall away a few seconds later, and read it as rate limiting when the file had
simply finished downloading.

The installer-fragility and parallel-accounting costs described above are unchanged, and
remain the real trade-off to weigh.

<!-- gh-comment-id:5478396559 --> @YoungReckless4 commented on GitHub (Aug 31, 2026): **Correction to the throughput figures above — the kernel row understated the result.** The 190 Mbit/s I quoted was the peak of a short run that ended before the transfer had saturated the link. A sustained single-stream download of a 4 GB file — roughly a minute of continuous transfer — ran at the client's full line rate: ``` idle=66.3% softirq=11.7% steal=2.4% | eth0 rx=462.0 tx=501.3 Mbit txpps=47997 txdrop+=0 | awg tx=483.5 Mbit ``` 483 Mbit/s through the tunnel, 501 Mbit/s on the host NIC at ~48k pps, with the single core still **66% idle** and softirq at 11.7%. That is the client's 500 Mbit line, not a server limit — on the kernel path the datapath was not the bottleneck at all. Against 124.6 Mbit/s peak on the embedded path for the same client, same line, same inbound and the same 3.1 parameters, the gap is closer to **4x** than the 1.5x implied above. My earlier figure was wrong because I armed the sampler near the end of that transfer, saw throughput fall away a few seconds later, and read it as rate limiting when the file had simply finished downloading. The installer-fragility and parallel-accounting costs described above are unchanged, and remain the real trade-off to weigh.
Author
Owner

@oracle-impl commented on GitHub (Sep 1, 2026):

+1

<!-- gh-comment-id:5493866456 --> @oracle-impl commented on GitHub (Sep 1, 2026): +1
Author
Owner

@YoungReckless4 commented on GitHub (Sep 1, 2026):

Controlled measurements, and two corrections to what I wrote above

This supersedes both the throughput table in the issue body (124.6 / 190.1 Mbit/s) and my earlier correction comment (483 Mbit/s). Those came from sampler windows that were not aligned to the transfers. The series below was taken with the sampler armed before each run started, on the same host, inbound, client, file and mirror, changing one thing at a time.

Two factual corrections first

  • The body says the panel's emitters write H1..H4 = 1..4. They do not: generateHRanges floors at 5 (const lo = 5, "values 1-4 are reserved for vanilla WireGuard message types"). I had that backwards.
  • The body describes limitIp as needing to be "reinterpreted as endpoint roaming since there is no access log". The bot's correction above is right: per-client IPs come from the core's online-stats API, and identity comes from the per-client SOCKS5 account, not from a log.

Host

1 vCPU (QEMU Virtual CPU 2.5+), 1.1 GB RAM, Debian 13, kernel 7.1.11-x64v3-xanmod1. RTT to the client ~53 ms, to the mirror 36 ms. One AmneziaWG inbound, 7 clients, MTU 1420 set explicitly, S4 = 12, H1..H4 empty, RandomTrailers on, DisableCookies on.

That last line matters: neither cause diagnosed in #6303 applies here. H1..H4 are empty, so they are not written to UAPI at all and amneziawg-go uses its single-value defaults, which gives the DeterminePacketTypeAndPadding misclassification from amnezia-vpn/amneziawg-go#183 nothing to match against. And with an explicit MTU of 1420 and S4 = 12 a full-size packet is 1492 bytes on the wire, under 1500, so the fragmentation from #6376 is not in play either. Whatever is measured below is a residual after both of those are excluded.

Method

Client: one download of debian-13.6.0-amd64-DVD-1.iso from cdimage.debian.org (redirected to umu.se), one browser download, single TCP connection, roughly 60 to 130 s of transfer per run. Server: /proc/net/dev sampled every 2 s. Reported figure is eth0 tx, because the embedded path has no kernel interface to sample. In kernel mode eth0 tx tracked awg1 tx to within about 4% (encapsulation overhead), so it slightly flatters every row equally. All figures recomputed from the raw logs, mean over samples above 20 Mbit/s.

Between runs only the panel binary changed, plus deleting the kernel interface so the embedded device could bind the port:

Run Datapath mean peak core idle at busiest sample
A kernel module (my fork) 445.5 Mbit/s 534.5 60.8%
B embedded, stock v3.7.0 (tunQueueDepth 1024) 57.2 102.2 65.4%
C embedded, tunQueueDepth 8192, nothing else changed 62.9 100.0 53.5%
D embedded, TCPSendBufferSizeRangeOption / TCPReceiveBufferSizeRangeOption 4 MB default, 16 MB max, TCPModerateReceiveBufferOption on, queue back at 1024 57.5 81.4 51.7%

B, C and D are indistinguishable. The client's own readout during A was 500 Mbit/s, which is that line's rate.

Where the drop happens, measured from the server itself

With the embedded build running, three curl runs of the same URL from the host, 15 s each:

Path Throughput
direct, no Xray, no tunnel 1.9 to 2.3 Gbit/s
through the inbound's own relay: --socks5 127.0.0.1:65101 --proxy-user <email>:<pass> (credentials from bin/config.json), no tunnel 1.0 to 1.7 Gbit/s
through the tunnel (runs B, C, D above) 55 to 63 Mbit/s

Xray and the SOCKS5 relay hop are not the ceiling. The drop is entirely inside the gVisor + amneziawg-go path. This is the part I would most like others to reproduce, because it takes three commands and no client: it tells you whether your own ceiling is the link, Xray, or the tunnel.

What this rules out on this host, and what it does not settle

Ruled out: CPU (the single core was never below 50% idle in any embedded run), tunQueueDepth for a single stream, TCP buffer sizing, CUBIC vs Reno (tried earlier, no change), the H-range classifier, MTU/S4, Xray, the relay.

Not settled: the mechanism. I have named three causes over the course of this thread and been wrong each time, so I am not offering a fourth. The shape of the data (a hard ceiling with the core mostly idle) says the path is blocking on something rather than computing, and that is as far as the evidence goes.

Scope. Single stream only. #6330 targets 20 to 28 concurrent flows and measured SlowStartRetransmits there; run C does not test that claim and should not be read as evidence about it. The diagnosis in #6303 and the fixes in #6330 are @kuzzrus's work, and this residual is separate from what they found.

How this bears on the question in the issue

In #6105 the maintainer wrote: "Userspace netstack vs. kernel module is the only trade-off that would change my mind here." The number given in reply, on real hardware, was 296 Mbit/s up and 640 Mbit/s down for the embedded path against 414.69 MB/s for the kernel module on the same box, "roughly 5-10x below the kernel module's own ceiling", and explicitly "the core tunnel datapath only (no SOCKS5-relay hop, which is the harder, more representative number but strictly lower)".

The ratio here is 7.8x, inside that range, with the relay hop included and separately shown not to be the bottleneck. What differs is the absolute number. 640 Mbit/s on real hardware was reasonably judged not a practical bottleneck; 57 Mbit/s on a 1 vCPU VPS is one, for any client on a faster line than that. The ratio looks hardware-independent across these two measurements; whether the absolute figure lands somewhere tolerable depends entirely on the host, and a single-vCPU VPS is a common host for this panel.

The costs listed in the body are unchanged: DKMS fragility, a parallel accounting path outside Xray, and the multi-node point the bot raised, that readiness would have to be a per-node capability rather than a per-inbound setting. Nothing here asks for a decision. It is the measurement the original question was missing.

One request. If anyone has an embedded AmneziaWG inbound on a multi-core box, the three server-side commands above take a few minutes and would show whether the absolute ceiling scales with cores. That is the one number this thread still lacks.

<!-- gh-comment-id:5500999758 --> @YoungReckless4 commented on GitHub (Sep 1, 2026): ## Controlled measurements, and two corrections to what I wrote above This supersedes both the throughput table in the issue body (124.6 / 190.1 Mbit/s) and my earlier correction comment (483 Mbit/s). Those came from sampler windows that were not aligned to the transfers. The series below was taken with the sampler armed before each run started, on the same host, inbound, client, file and mirror, changing one thing at a time. ### Two factual corrections first - The body says the panel's emitters write `H1..H4 = 1..4`. They do not: `generateHRanges` floors at 5 (`const lo = 5`, "values 1-4 are reserved for vanilla WireGuard message types"). I had that backwards. - The body describes `limitIp` as needing to be "reinterpreted as endpoint roaming since there is no access log". The bot's correction above is right: per-client IPs come from the core's online-stats API, and identity comes from the per-client SOCKS5 account, not from a log. ### Host 1 vCPU (QEMU Virtual CPU 2.5+), 1.1 GB RAM, Debian 13, kernel 7.1.11-x64v3-xanmod1. RTT to the client ~53 ms, to the mirror 36 ms. One AmneziaWG inbound, 7 clients, MTU 1420 set explicitly, S4 = 12, H1..H4 empty, RandomTrailers on, DisableCookies on. That last line matters: neither cause diagnosed in #6303 applies here. H1..H4 are empty, so they are not written to UAPI at all and amneziawg-go uses its single-value defaults, which gives the `DeterminePacketTypeAndPadding` misclassification from amnezia-vpn/amneziawg-go#183 nothing to match against. And with an explicit MTU of 1420 and S4 = 12 a full-size packet is 1492 bytes on the wire, under 1500, so the fragmentation from #6376 is not in play either. Whatever is measured below is a residual after both of those are excluded. ### Method Client: one download of `debian-13.6.0-amd64-DVD-1.iso` from cdimage.debian.org (redirected to umu.se), one browser download, single TCP connection, roughly 60 to 130 s of transfer per run. Server: `/proc/net/dev` sampled every 2 s. Reported figure is `eth0 tx`, because the embedded path has no kernel interface to sample. In kernel mode `eth0 tx` tracked `awg1 tx` to within about 4% (encapsulation overhead), so it slightly flatters every row equally. All figures recomputed from the raw logs, mean over samples above 20 Mbit/s. Between runs only the panel binary changed, plus deleting the kernel interface so the embedded device could bind the port: | Run | Datapath | mean | peak | core idle at busiest sample | |---|---|---|---|---| | A | kernel module (my fork) | **445.5** Mbit/s | 534.5 | 60.8% | | B | embedded, stock v3.7.0 (`tunQueueDepth` 1024) | 57.2 | 102.2 | 65.4% | | C | embedded, `tunQueueDepth` 8192, nothing else changed | 62.9 | 100.0 | 53.5% | | D | embedded, `TCPSendBufferSizeRangeOption` / `TCPReceiveBufferSizeRangeOption` 4 MB default, 16 MB max, `TCPModerateReceiveBufferOption` on, queue back at 1024 | 57.5 | 81.4 | 51.7% | B, C and D are indistinguishable. The client's own readout during A was 500 Mbit/s, which is that line's rate. ### Where the drop happens, measured from the server itself With the embedded build running, three `curl` runs of the same URL from the host, 15 s each: | Path | Throughput | |---|---| | direct, no Xray, no tunnel | 1.9 to 2.3 Gbit/s | | through the inbound's own relay: `--socks5 127.0.0.1:65101 --proxy-user <email>:<pass>` (credentials from `bin/config.json`), no tunnel | 1.0 to 1.7 Gbit/s | | through the tunnel (runs B, C, D above) | 55 to 63 Mbit/s | Xray and the SOCKS5 relay hop are not the ceiling. The drop is entirely inside the gVisor + amneziawg-go path. This is the part I would most like others to reproduce, because it takes three commands and no client: it tells you whether your own ceiling is the link, Xray, or the tunnel. ### What this rules out on this host, and what it does not settle Ruled out: CPU (the single core was never below 50% idle in any embedded run), `tunQueueDepth` for a single stream, TCP buffer sizing, CUBIC vs Reno (tried earlier, no change), the H-range classifier, MTU/S4, Xray, the relay. Not settled: the mechanism. I have named three causes over the course of this thread and been wrong each time, so I am not offering a fourth. The shape of the data (a hard ceiling with the core mostly idle) says the path is blocking on something rather than computing, and that is as far as the evidence goes. **Scope.** Single stream only. #6330 targets 20 to 28 concurrent flows and measured `SlowStartRetransmits` there; run C does not test that claim and should not be read as evidence about it. The diagnosis in #6303 and the fixes in #6330 are @kuzzrus's work, and this residual is separate from what they found. ### How this bears on the question in the issue In #6105 the maintainer wrote: "Userspace netstack vs. kernel module is the only trade-off that would change my mind here." The number given in reply, on real hardware, was 296 Mbit/s up and 640 Mbit/s down for the embedded path against 414.69 MB/s for the kernel module on the same box, "roughly 5-10x below the kernel module's own ceiling", and explicitly "the core tunnel datapath only (no SOCKS5-relay hop, which is the harder, more representative number but strictly lower)". The ratio here is 7.8x, inside that range, with the relay hop included and separately shown not to be the bottleneck. What differs is the absolute number. 640 Mbit/s on real hardware was reasonably judged not a practical bottleneck; 57 Mbit/s on a 1 vCPU VPS is one, for any client on a faster line than that. The ratio looks hardware-independent across these two measurements; whether the absolute figure lands somewhere tolerable depends entirely on the host, and a single-vCPU VPS is a common host for this panel. The costs listed in the body are unchanged: DKMS fragility, a parallel accounting path outside Xray, and the multi-node point the bot raised, that readiness would have to be a per-node capability rather than a per-inbound setting. Nothing here asks for a decision. It is the measurement the original question was missing. **One request.** If anyone has an embedded AmneziaWG inbound on a multi-core box, the three server-side commands above take a few minutes and would show whether the absolute ceiling scales with cores. That is the one number this thread still lacks.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MHSanaei/3x-ui#4329
No description provided.