Skip to content

test(bench): four-core server comparison (Xray, sing-box, mihomo, Citrus) - #126

Merged
Nemu-x merged 3 commits into
devfrom
bench/four-cores
Oct 18, 2026
Merged

Nemu-x merged 3 commits into
devfrom
bench/four-cores

Conversation

@Nemu-x

@Nemu-x Nemu-x commented Oct 18, 2026

Copy link
Copy Markdown
Collaborator

Server-side comparison of four cores on one host, same load, same client per protocol: Xray-core v26.10.17, sing-box v1.14.3, mihomo v1.19.32 and Citrus cc48b139.

Citrus snapshot: dev after #119 (upload write batching) and #118, before #124 (download batching, tls/utls fork bumps) — #124 is not in these numbers.

Full write-up: test/bench/compare/results/2026-10-18-four-cores/RESULTS.md (method, versions, clients, caveats, verdict); all cells with min–max in headline.md / tables.md.

Harness (test/bench/compare)

  • sing-box as a fourth server (musl release, pinned by asset digest); Xray bumped to v26.10.17.
  • New protocols: Hysteria2 (Xray, sing-box, mihomo, Citrus), TUIC v5 and AnyTLS (sing-box, mihomo, Citrus). Missing inbounds are n/a (no config, skipped).
  • One client per protocol for every server: Xray for REALITY/XHTTP/Trojan/SS2022/Hysteria2, sing-box for TUIC/AnyTLS.
  • cmp report writes headline.md: per protocol the winner (a tie when min–max ranges overlap) and Citrus vs the best other server. Unreached idle levels give no value; reality-tlsin uploads are marked not comparable (Xray's client decides whether Vision goes direct).
  • run.sh: NAME/NET/SUBNET/IMAGE to share a host, ALONE=1 waits for and flags foreign containers, ONLY to redo runs; the client config path is per network (with --pid=host the old pkill killed the clients of other bench setups).
  • Xray's Hysteria server gets maxIncomingStreams 2^60 like the sing-quic servers: with its default 1024 its own client fails ~99.9% of new streams.

Headline (medians of 3; Xray / sing-box / mihomo / Citrus)

Download, 32 streams, MB/s

protocol Xray sing-box mihomo Citrus winner Citrus vs best other
reality 2173 (2132–2188) 2653 (2621–2667) 2837 (2706–2839) 2800 (2715–2859) ≈ mihomo, Citrus -1% vs mihomo
reality-tlsin 1331 (928–1397) 5339 (5191–5544) 9797 (9188–10516) 9032 (7973–9057) mihomo -8% vs mihomo
xhttp 925 (894–941) n/a 1185 (1166–1186) 1189 (1158–1193) ≈ Citrus, mihomo +0% vs mihomo
trojan 2095 (2068–2176) 2856 (2704–2892) 2794 (2730–2807) 2807 (2794–2832) ≈ sing-box, mihomo, Citrus -2% vs sing-box
ss2022 1985 (1925–2012) 4234 (4016–4283) 3906 (3880–3933) 3870 (3855–3903) sing-box -9% vs sing-box
hy2 586 (564–609) 645 (617–672) 639 (561–642) 623 (583–638) ≈ sing-box, mihomo, Citrus -3% vs sing-box
tuic n/a 455 (414–455) 450 (425–529) 426 (419–449) ≈ sing-box, mihomo, Citrus -6% vs sing-box
anytls n/a 2504 (2497–2513) 2157 (2117–2264) 2214 (2214–2251) sing-box -12% vs sing-box

Upload, 32 streams, MB/s

protocol Xray sing-box mihomo Citrus winner Citrus vs best other
reality 1871 (1863–1880) 1818 (1815–1854) 1841 (1822–1870) 2843 (2817–2906) Citrus +52% vs Xray
reality-tlsin 2433 (2323–2673) 2360 (2344–2416) 5601 (5075–7475) 2377 (2250–2518) not comparable (client-side Vision switch) –
xhttp 1187 (1169–1245) n/a 1461 (1459–1578) 1531 (1513–1681) ≈ Citrus, mihomo +5% vs mihomo
trojan 3412 (3174–3500) 1849 (1842–1882) 1826 (1815–1857) 2880 (2854–2899) Xray -16% vs Xray
ss2022 3355 (3160–3421) 1840 (1816–1850) 1808 (1800–1834) 2770 (2754–2780) Xray -17% vs Xray
hy2 580 (558–591) 515 (481–520) 613 (552–615) 575 (533–584) ≈ mihomo, Xray, Citrus -6% vs mihomo
tuic n/a 488 (462–502) 583 (553–586) 575 (554–578) ≈ mihomo, Citrus -1% vs mihomo
anytls n/a 3223 (3203–3274) 2923 (2844–3024) 2792 (2677–2884) sing-box -13% vs sing-box

Server CPU per GB, CPU s/GB (lower is better)

At 500 Mbit/s, one stream (same work for every server):

protocol download: Xray / sing-box / mihomo / Citrus winner upload: Xray / sing-box / mihomo / Citrus winner
reality 1.76 / 1.70 / 1.57 / 1.51 ≈ Citrus, sing-box, mihomo 1.99 / 2.02 / 1.97 / 1.99 ≈ mihomo, Xray, sing-box, Citrus
reality-tlsin 1.05 / 1.26 / 1.07 / 1.10 ≈ Xray, mihomo, Citrus 1.20 / 1.13 / 1.16 / 1.63 not comparable (client-side Vision switch)
xhttp 5.49 / n/a / 4.66 / 4.81 ≈ mihomo, Citrus 5.31 / n/a / 4.37 / 3.54 Citrus
trojan 2.27 / 1.54 / 1.51 / 1.50 ≈ Citrus, sing-box, mihomo 2.08 / 1.96 / 1.98 / 1.99 ≈ sing-box, mihomo, Citrus
ss2022 2.23 / 1.39 / 1.37 / 1.40 mihomo 2.29 / 2.03 / 2.01 / 2.11 ≈ mihomo, Xray, sing-box
hy2 5.63 / 4.83 / 4.55 / 4.63 ≈ mihomo, sing-box, Citrus 5.88 / 5.90 / 5.62 / 6.31 ≈ mihomo, Xray, sing-box, Citrus
tuic n/a / 4.76 / 4.52 / 4.70 ≈ mihomo, sing-box, Citrus n/a / 3.90 / 4.15 / 4.10 ≈ sing-box, mihomo, Citrus
anytls n/a / 1.72 / 1.77 / 1.75 ≈ sing-box, mihomo, Citrus n/a / 2.22 / 2.32 / 2.10 ≈ Citrus, sing-box

Bulk, 32 streams (unpaced):

protocol download: Xray / sing-box / mihomo / Citrus winner upload: Xray / sing-box / mihomo / Citrus winner
reality 0.88 / 0.72 / 0.68 / 0.67 ≈ Citrus, mihomo 1.02 / 1.05 / 1.04 / 0.66 Citrus
reality-tlsin 1.37 / 0.36 / 0.19 / 0.21 mihomo 0.77 / 0.80 / 0.33 / 0.82 not comparable (client-side Vision switch)
xhttp 2.15 / n/a / 1.63 / 1.59 Citrus 1.65 / n/a / 1.34 / 1.24 ≈ Citrus, mihomo
trojan 0.90 / 0.67 / 0.68 / 0.67 ≈ sing-box, mihomo, Citrus 0.55 / 1.04 / 1.04 / 0.66 Xray
ss2022 0.96 / 0.45 / 0.49 / 0.49 sing-box 0.55 / 1.06 / 1.05 / 0.69 Xray
hy2 2.33 / 2.09 / 2.04 / 2.10 ≈ mihomo, Xray, sing-box, Citrus 2.94 / 2.91 / 2.82 / 3.00 ≈ mihomo, Xray, sing-box, Citrus
tuic n/a / 2.16 / 2.23 / 2.18 ≈ sing-box, mihomo, Citrus n/a / 2.90 / 2.81 / 2.87 ≈ mihomo, sing-box, Citrus
anytls n/a / 0.75 / 0.87 / 0.85 sing-box n/a / 0.59 / 0.64 / 0.71 sing-box

New connections (128 concurrent clients, request/answer, the sink closes)

protocol conn/s: Xray / sing-box / mihomo / Citrus winner server CPU ms per conn: Xray / sing-box / mihomo / Citrus winner
reality 3578 / 3115 / 2980 / 3363 ≈ Xray, sing-box, Citrus 0.536 / 0.605 / 0.645 / 0.564 ≈ Xray, sing-box, Citrus
reality-x25519 – / 3785 / 3752 / 3851 ≈ Citrus, sing-box, mihomo – / 0.500 / 0.519 / 0.497 ≈ Citrus, sing-box, mihomo
xhttp 9147 / n/a / 10366 / 10496 ≈ Citrus, mihomo 0.217 / n/a / 0.190 / 0.189 ≈ Citrus, mihomo
trojan 4371 / 5030 / 5263 / 5209 ≈ mihomo, Citrus 0.451 / 0.380 / 0.366 / 0.369 ≈ mihomo, Citrus
ss2022 8435 / 9595 / 9477 / 9513 ≈ sing-box, mihomo, Citrus 0.233 / 0.201 / 0.200 / 0.201 ≈ mihomo, sing-box, Citrus
hy2 14651 / 18607 / 17117 / 16322 ≈ sing-box, mihomo 0.130 / 0.100 / 0.113 / 0.116 ≈ sing-box, Citrus
tuic n/a / 20701 / 18585 / 18771 sing-box n/a / 0.088 / 0.100 / 0.096 sing-box
anytls n/a / 14763 / 12491 / 11713 sing-box n/a / 0.133 / 0.157 / 0.163 sing-box

Idle tunnels: RSS per tunnel, KiB (lower is better)

protocol @5000: Xray / sing-box / mihomo / Citrus winner @1000: Xray / sing-box / mihomo / Citrus winner
reality 68.1 / 73.2 / 74.3 / 55.1 Citrus 52.8 / 70.8 / 71.0 / 48.8 ≈ Citrus, Xray
xhttp 62.5 / n/a / 56.2 / 53.4 Citrus 50.2 / n/a / 50.4 / 44.4 Citrus
trojan 84.9 / 38.0 / 63.1 / 51.6 sing-box 59.9 / 36.1 / 51.7 / 45.7 sing-box
ss2022 60.2 / 90.1 / 54.5 / 48.8 Citrus 58.2 / 95.2 / 52.6 / 51.7 ≈ Citrus, mihomo
hy2 41.3 / 23.7 / 28.6 / 26.0 sing-box 32.3 / 19.3 / 22.2 / 17.2 ≈ Citrus, sing-box
tuic n/a / 20.8 / 24.1 / – sing-box n/a / 17.2 / 18.6 / 13.4 Citrus
anytls n/a / 69.3 / 75.5 / 66.3 Citrus n/a / 67.2 / 65.0 / 66.5 ≈ mihomo, sing-box, Citrus

TUIC on Citrus: no value at 5000. Citrus's TUIC server allows 2048
concurrent bidirectional streams per QUIC connection (listener/tuic/server.go,
ServerMaxIncomingStreams), and the sing-box client does not wait for stream
credit: past 2048 it refuses new tunnels ("too many open streams", 2952
errors of 5000 in every repetition). The code comment assumes clients wait
for MAX_STREAMS; the sing-box client does not. A single sing-box TUIC client
with more than 2048 simultaneous TCP connections gets errors from Citrus and
not from mihomo or sing-box. At 1000 tunnels Citrus uses the least.

Latency under load (8-stream unpaced download on the same server)

protocol echo RTT p50, ms: Xray / sing-box / mihomo / Citrus winner new-conn TTFB p50, ms: Xray / sing-box / mihomo / Citrus winner
reality 76.83 / 84.65 / 80.85 / 80.09 Xray 321.36 / 362.62 / 305.84 / 284.09 Citrus
xhttp 4.99 / n/a / 1.44 / 1.42 ≈ Citrus, mihomo 8.07 / n/a / 2.77 / 3.04 ≈ mihomo, Citrus
trojan 71.75 / 76.07 / 79.44 / 80.45 Xray 182.21 / 169.20 / 156.54 / 153.26 Citrus
ss2022 80.08 / 45.85 / 71.34 / 69.33 sing-box 165.56 / 70.37 / 106.04 / 100.96 sing-box
hy2 1.03 / 1.08 / 1.03 / 1.19 ≈ Xray, sing-box, mihomo, Citrus 1.62 / 1.74 / 1.91 / 1.80 ≈ Xray, mihomo, Citrus
tuic n/a / 1.84 / 2.66 / 2.46 ≈ sing-box, mihomo, Citrus n/a / 3.49 / 4.03 / 3.02 ≈ Citrus, sing-box, mihomo
anytls n/a / 88.43 / 90.81 / 91.01 ≈ sing-box, mihomo, Citrus n/a / 150.75 / 133.25 / 129.54 ≈ Citrus, mihomo

On the TCP protocols this RTT is mostly queueing in socket buffers behind the
unpaced download (70–90 ms at 2–4 GB/s); it tracks how much a server buffers,
not its scheduling. sing-box is lower on SS2022 (45 vs 69–80 ms) while also
downloading the fastest there. QUIC protocols stay at 1–3 ms because the
bulk rate is 5× lower.

Verdict

Overall. No core wins everywhere. On this host, among the four, Citrus
has the best or tied-best result on most TCP metrics (REALITY, Trojan,
SS2022, XHTTP): download on par with mihomo and sing-box and far ahead of
Xray, upload ahead of mihomo and sing-box by 50%+ (behind Xray by 16–17% on
Trojan/SS2022 bulk upload), new connections on par with mihomo (13% ahead
on REALITY), and the
lowest memory per tunnel on REALITY, XHTTP and SS2022. sing-box is the
reference on AnyTLS and TUIC (and its new-connection path is the cheapest
on the QUIC protocols); Xray remains the most CPU-efficient on Trojan/SS2022
bulk upload. On the QUIC protocols (Hysteria2, TUIC) sing-box, mihomo and
Citrus are within
the noise on throughput and CPU per GB (Xray trails on Hysteria2 download
and CPU); differences there are in new
streams and memory.

Main caveats: one host (Docker Desktop/WSL2, hybrid CPU), no latency or loss on the bridge; QUIC throughput is bounded by one connection per client; TUIC/AnyTLS use the sing-box client; Citrus's TUIC server caps 2048 streams per connection and the sing-box client errors past that (no 5000-tunnel value for Citrus TUIC; follow-up). Runs overlapped by other containers on the shared host were redone (see RESULTS.md).

…AnyTLS

The harness compares Xray-core, sing-box, mihomo and Citrus as servers.

- fetch.sh pins sing-box v1.14.3 (musl build) and Xray v26.10.17, both
  checked against the release asset digests (Xray also its .dgst).
- cmp gen writes the sing-box configs and the new inbounds: Hysteria2,
  TUIC v5 and AnyTLS (sing-box, mihomo, Citrus; Xray has Hysteria2). A
  server without an inbound gets no config and run.sh skips it as n/a.
- One client per protocol for every server: Xray where it speaks the
  protocol, sing-box for TUIC and AnyTLS. QUIC runs skip the TCP checks.
- Xray's Hysteria server gets maxIncomingStreams 2^60, as the sing-quic
  servers have: with its default of 1024 its own client fails new streams.
- cmp report: four columns, n/a cells, headline.md with the winner per
  protocol (a tie when the min-max ranges overlap) and Citrus against the
  best other server; memory levels a server did not reach are left out;
  reality-tlsin uploads are marked not comparable (the client decides).
- run.sh: NAME, NET, SUBNET and IMAGE let setups share a host; ALONE=1
  waits for other containers before a run and flags the runs one starts
  during; ONLY reruns given runs; NET_ADMIN for the QUIC buffers. The
  client config path is per network, so its pkill does not hit the
  clients of another setup.
Xray-core v26.10.17, sing-box v1.14.3, mihomo v1.19.32 and Citrus
cc48b13 (dev after the upload write batching, before the download
batching) as servers: REALITY (+ variants), XHTTP, Trojan, SS2022,
Hysteria2, TUIC and AnyTLS, 3 repetitions. RESULTS.md has the method,
the clients per protocol, the headline tables with the winner per
protocol, the verdict and the caveats; runs that another container
overlapped were redone and the originals kept under disturbed/.
@Nemu-x
Nemu-x merged commit 08b4d14 into dev Oct 18, 2026
9 checks passed
@Nemu-x
Nemu-x deleted the bench/four-cores branch October 18, 2026 06:46
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