新增 docs/优化实测数据.md:本轮所有优化的实测数字汇总

每一项都写清楚「改之前是多少、改之后是多少、怎么测的、受什么限制」,
以后有人问「这个改动到底有没有用」能直接翻数字,不用靠感觉。

内容包括:
  * 测量方法上的两个坑(从哪台机器测差很多、curl -I 验证 GET 是错的)
  * 下载吞吐 41 倍(含改之前/之后对照)
  * 隧道稳定性:配比对照表、QUIC 72% 拨号率的真因、
    MTU 1400 的效果、长时可用率
  * 长轮询 30 次数据(中位 61439ms)
  * 端到端延迟:局域网 0ms vs 本地中转 15ms
  * 局域网优化的四个真问题
  * 「按一下没反应」的完整证据链和根因
  * 独立验证发现的 9 个问题
  * 测试工具自己骗人的两次
  * 服务端部署脚本的三套测试
  * **没做到的部分**(98.5% 可用率的物理限制,如实记录)

这份是内部工程文档,已加进对外清洁度检查的允许清单
(和 docs/项目规矩.md、docs/双平台发布.md 同类)。
This commit is contained in:
xmz7891
2026-10-07 19:02:57 +08:00
parent 0ee91b68de
commit 4cc368431c
5 changed files with 487 additions and 0 deletions
+63
View File
@@ -0,0 +1,63 @@
#!/bin/bash
# 看 relay-stability 的 30 次长轮询结果(目标 2)
set -u
echo " ── 汇总文件 ──"
[ -f /root/rp_poll30_summary.txt ] && cat /root/rp_poll30_summary.txt | sed 's/^/ /'
echo
echo " ── 明细(前 5 行看格式)──"
[ -f /root/rp_poll30.tsv ] && head -5 /root/rp_poll30.tsv | sed 's/^/ /'
echo
echo " ── 自己再算一遍 ──"
python3 - <<'PYEOF'
from pathlib import Path
p = Path("/root/rp_poll30.tsv")
if not p.is_file():
print(" 没有文件")
raise SystemExit(0)
rows = []
for line in p.read_text(encoding="utf-8", errors="replace").splitlines():
line = line.strip()
if not line:
continue
parts = [x.strip() for x in line.replace(",", "\t").split("\t") if x.strip()]
if not parts:
continue
# 找出状态码和耗时
code = None
ms = None
for x in parts:
if x in ("200", "502", "530", "000", "401", "504"):
code = x
elif x.replace(".", "").isdigit() and "." not in x and len(x) >= 4:
try:
v = int(x)
if 500 <= v <= 300000 and ms is None:
ms = v
except ValueError:
pass
if code:
rows.append((code, ms))
if not rows:
print(" 解析不出样本,原始内容:")
print(p.read_text(encoding="utf-8", errors="replace")[:400])
raise SystemExit(0)
total = len(rows)
ok = sum(1 for c, _m in rows if c == "200")
print(" 样本 %d,成功 %d,可用率 %.1f%%" % (total, ok, ok * 100.0 / total))
good = sorted(m for c, m in rows if c == "200" and m)
if good:
def pc(q):
return good[min(int(len(good) * q), len(good) - 1)]
print(" 耗时: 最小 %d 中位 %d P90 %d P99 %d 最大 %d ms"
% (good[0], good[len(good) // 2], pc(0.9), pc(0.99), good[-1]))
print(" (理想值 = 60000 + 隧道开销;>90000 的算异常长尾)")
outliers = [m for m in good if m > 90000]
print(" 异常长尾(>90 秒): %d 次 %s" % (len(outliers), outliers))
PYEOF
+40
View File
@@ -0,0 +1,40 @@
#!/bin/bash
# 看 relay-stability 在设备上跑到哪了
set -u
echo " ── 它起的进程 ──"
pgrep -af 'rp_|long2h|ab_long|collapse' 2>/dev/null | head -6 | sed 's/^/ /' || echo " (没有)"
echo
echo " ── /root 下它最近写的文件 ──"
ls -la --time-style=+%H:%M:%S /root/rp_* /root/*.tsv /root/*.txt /root/*.out 2>/dev/null \
| sort -k6 | tail -12 | sed 's/^/ /'
echo
echo " ── 那个 2 小时长测的输出 ──"
if [ -f /root/long2h_health.tsv ]; then
echo " 样本数: $(wc -l < /root/long2h_health.tsv)"
echo " 最后 3 行:"
tail -3 /root/long2h_health.tsv | sed 's/^/ /'
fi
echo
echo " ── 配比对照有没有开始(看隧道配置变没变)──"
for s in lanremote-tunnel lanremote-tunnel-h2; do
printf " %-24s %s\n" "$s" \
"$(grep -oE -- '--protocol [a-z0-9]+|--ha-connections [0-9]+' /etc/systemd/system/$s.service 2>/dev/null | tr '\n' ' ')"
done
for p in 20241 20242; do
n=$(curl -s --max-time 4 "http://127.0.0.1:$p/metrics" 2>/dev/null \
| grep '^cloudflared_tunnel_ha_connections' | awk '{print $2}')
printf " 端口 %s -> %s 条\n" "$p" "${n:-读不到}"
done
echo
echo " ── 公网自检 ──"
curl -s --max-time 20 -o /dev/null -w ' HTTP %{http_code} %{time_total}s\n' \
-H 'User-Agent: LanRemote/1.8.2' https://relay.xxmxxs.top/v1/health
echo
echo " ── 设备当前时间 ──"
date '+ %H:%M:%S'
+34
View File
@@ -0,0 +1,34 @@
#!/bin/bash
# A 组长测是否跑完 + 汇总
set -u
echo "════════ 进度 ════════"
echo " 健康样本: $(wc -l < /root/long2h_health.tsv 2>/dev/null || echo 0)"
echo " 连接采样: $(wc -l < /root/long2h_conns.tsv 2>/dev/null || echo 0)"
echo " 轮询: $(wc -l < /root/rp_poll30.tsv 2>/dev/null || echo 0) / 30"
echo " 测试进程: $(pgrep -c -f rp_long2h || echo 0)"
echo
echo "════════ 汇总文件(跑完才有)════════"
if [ -s /root/long2h_summary.txt ]; then
cat /root/long2h_summary.txt
else
echo " (还没生成,测试仍在跑)"
echo " 当前状态码分布:"
awk -F'\t' 'NR>1{print $2}' /root/long2h_health.tsv 2>/dev/null | sort | uniq -c | sed 's/^/ /'
echo " 当前非 200:"
awk -F'\t' 'NR>1 && $2!="200"{print " " $1 " 码=" $2 " " $3 "ms"}' /root/long2h_health.tsv 2>/dev/null
echo " 连接数最新 5 条:"
tail -5 /root/long2h_conns.tsv 2>/dev/null | sed 's/^/ /'
fi
echo
echo "════════ 塌陷窗口预览(总数<=3 的采样)════════"
awk -F'\t' 'NR>1 && $2 ~ /^[0-9]+$/ && $3 ~ /^[0-9]+$/ && ($2+$3)<=3 {
print " " $1 " quic=" $2 " h2=" $3 " 合计=" $2+$3
}' /root/long2h_conns.tsv 2>/dev/null | tail -20
echo
echo "════════ 连接总数分布 ════════"
awk -F'\t' 'NR>1 && $2 ~ /^[0-9]+$/ && $3 ~ /^[0-9]+$/ {print $2+$3}' \
/root/long2h_conns.tsv 2>/dev/null | sort -n | uniq -c | sed 's/^/ /'
+4
View File
@@ -58,6 +58,10 @@ DOCS_ALLOWLIST = {
# 属于描述规则本身,不是对外宣传材料。
"双平台发布.md",
"EzHub-SSH诊断报告.md", # 给服务端运维看的排查报告
# 内部工程数据文档:记录本轮所有优化的实测数字和对比依据,
# 里面会引用"管理页 23 项测试通过"这类工程事实。
# 它不是发给用户的材料,是给自己和后人查数字用的。
"优化实测数据.md",
}
# 官网源码里这些词也不许有(landing.py 渲染出来的页面)