Repository navigation
bench: deterministic reality-tlsin upload, nightly perf check in CI - #127
Merged
Merged
Conversation
…y per stream The TLS sink writes a ready byte after its handshake and acknowledges the upload command, and cmp waits for both, so Xray's Vision client reads the command record alone and switches every upload stream to direct copy instead of at random. The Xray client of reality-tlsin logs at debug level; cmp measure counts per bulk phase the streams whose upload and download went direct, and cmp report ranks the reality-tlsin upload metrics only when every upload stream of every run went direct.
…aseline Short comparison (REALITY, Trojan, SS2022, Hysteria2; mem, hs, bulk) on ubuntu-latest, nightly on dev, on demand and on pull requests touching the harness. cmp gate compares the Citrus/mihomo ratio of each metric with test/bench/compare/ci/baseline.json and fails on a drop of more than the tolerance. run.sh: BUILD=host builds with the host's Go, SETTLE shortens the memory phase.
With --pid=host, pkill -f reads the command line of every process of the host and blocks on a process stuck in the kernel (D state), which hung the runs of the comparison for minutes on a shared Docker host.
Nemu-x
marked this pull request as ready for review
October 18, 2026 10:39
This was referenced Oct 18, 2026
Merged
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.
Two harness follow-ups to #126: a deterministic
reality-tlsinupload, and a nightly perf check in CI.1.
reality-tlsinupload: Vision goes direct on every streamXray's Vision client switches an upload to direct copy only when one of its reads from the local socket contains nothing but whole TLS application-data records (
IsCompleteRecordinproxy/proxy.go).cmpwrote the 1-byte inner command record and the bulk data back to back. A stream therefore went direct (~3000 MB/s) or stayed padded to the end (~400 MB/s), depending on how the client's reads split the writes. This happened on every server, Xray's included.Fix (TLS sink only, so the other protocols are unchanged):
cmpwaits for it before sending the command, so the client's CCS+Finished flight and the command record are never in the same read.cmpwaits for it before sending any data, so the command record is read alone and Vision switches on it.Observability: on
reality-tlsinthe Xray client logs at debug level.cmp measurereads the client log of each bulk phase and counts, per session, theXtlsPadding … 2(upload) andXtls Unpadding … command 2(download) lines, where 2 isCommandPaddingDirect. It storesvision: {streams, up_direct, down_direct}per phase in the run JSON and records an anomaly when a stream did not switch.cmp reportadds a table of these counts totables.md. It ranks thereality-tlsinupload metrics only when every upload stream of every run went direct. Results recorded before this change have no Vision data, so they stay "not comparable", and2026-10-18-four-cores/RESULTS.mdis left as it is.Proof, on a runner (throwaway PR #128, run 39109702359: all four servers × 3 repetitions, bulk + fixed phases):
That is 324 of 324 tunnels direct in both directions. Single-stream upload per repetition, MB/s: Xray 1370/1126/1197, sing-box 1192/1336/1350, mihomo 1446/1478/1408, Citrus 932/1413/1267. There is no ~400 MB/s mode any more; before, Citrus's three values were 385, 392 and 2209. On the runner's single-vCPU sink these MB/s are sink-bound, so they show the switch, not a ranking.
A local run on the reference host (i7-14700K) did not happen: the shared Docker host was busy with other benchmarks for hours, and a process from another build was stuck in D state there (see the pkill fix below).
Also:
startClientused to kill a stale client withpkill -f. With--pid=hostthat reads every process of the host and blocks on one stuck in D state, which hung runs on our shared Docker host. It now kills the client named in its own pid file.2. Nightly perf check (
.github/workflows/perf-nightly.yml)37 2 * * *),workflow_dispatch(both check outdev), andpull_requeston changes undertest/bench/compare/**or the workflow itself. Schedule and dispatch only run from the default branch, so the nightly starts once this reachesmain.run.shwithBUILD=host: Citrus is built with the release flags on the pinned toolchain (setup-go.sh 1.26), with Go caches. Servers are Citrus and mihomo v1.19.32 (the harness pin); protocols are REALITY, Trojan, SS2022 and Hysteria2; phases aremem(1000 tunnels,SETTLE=2s),hsandbulk, with 2 repetitions of a 1 s ramp + 3 s window. On the 4-vCPU runner the server gets cpuset 0, the client 1-2 and the sink 3.cmp gate): for each protocol and metric (dl/ul 1 and 32 streams, CPU/GB dl32/ul32, conn/s, CPU per connection, RSS per tunnel) it computes the ratio of medians Citrus/mihomo, inverted for CPU and memory so that above 1 means Citrus is better. It compares that ratio withtest/bench/compare/ci/baseline.jsonand fails if the ratio is more thantolerance(0.2) below the baseline, or if Citrus has no value where mihomo has one. The table goes to the job summary.runs/,tables.mdandratios.json(this run's ratios, ready to become a new baseline) go to theperf-resultsartifact.ul32_mbpsbaseline producedratio 1.584, baseline 2.376 (-33%)and exit 1.contents: read. Actions are pinned by SHA (the same pins asbench.yml/pr-build.yml).actionlintis clean. The job takes about 12–14 min (perf job runs: 13m40s, 12m, 12m, 12m04s).run.shknobs added:BUILD=host(build with the host's Go) andSETTLE(the memory-phase wait). README updated.