feat: 自适应并发调度 — 网络探测 + AIMD + 参数智能推导

扫描前自动探测网络环境(RTT、丢包率、fd limit),基于探测数据
推导 6 个关键参数,替代硬编码默认值:

- Timeout: median_RTT + 4σ(覆盖 99.9% 正常连接)
- ModuleThreadNum: target_concurrency / 30
- MaxRetries: ceil(log(0.01)/log(loss_rate))(全失败概率 <1%)
- ICMPRate: 环境基准 × fd 系数
- PocNum: 跟随 ModuleThreadNum
- DisablePing: 已有 ICMP 权限降级机制

线程池从单信号(资源耗尽率)升级为 AIMD + 慢启动:
- 慢启动:target/4 起步,500ms 翻倍
- 稳态 AIMD:健康 +5%,拥塞 ×0.5
- 双信号:资源耗尽率 + RTT 趋势(双 EMA)

用户 -t 显式指定时作为 ceiling,探测仍调整其他参数。

测试:单元 + 边界 + 集成 + 真实网络,core 包 580+ 用例全通过。
This commit is contained in:
ZacharyZcR
2026-06-14 22:23:45 +08:00
parent e0468ecd35
commit 88c7e4f2be
21 changed files with 3287 additions and 251 deletions
+20
View File
@@ -541,6 +541,26 @@ icmp_debug_stable_done:
other: "[ICMP] response stable, ending early, elapsed {{.Arg1}}, alive {{.Arg2}}/{{.Arg3}}"
adaptive_pool_resource_exhausted:
other: "[AdaptivePool] resource exhaustion rate {{.Arg1}}%, threads {{.Arg2}} -> {{.Arg3}}"
adaptive_pool_decrease:
other: "Concurrency adjusted: {{.Arg1}} -> {{.Arg2}} (pressure detected)"
adaptive_pool_increase:
other: "Concurrency adjusted: {{.Arg1}} -> {{.Arg2}} (network healthy)"
adaptive_pool_slowstart_exit:
other: "Slow start exit: current {{.Arg1}} (congestion detected)"
net_probe_result:
other: "Network probe: {{.Arg1}}, RTT {{.Arg2}}ms, loss {{.Arg3}}%, concurrency {{.Arg4}}/{{.Arg5}}"
net_env_lan:
other: "LAN"
net_env_wan:
other: "WAN"
net_env_internet:
other: "Internet"
net_env_slow:
other: "Slow network"
env_tune_summary:
other: "Adaptive params: Timeout={{.Arg1}}ms, ModuleThread={{.Arg2}}, Retry={{.Arg3}}, ICMPRate={{.Arg4}}, PocNum={{.Arg5}}"
env_fd_limit:
other: "fd limit constraint: threads {{.Arg1}} -> {{.Arg2}} (ulimit={{.Arg3}})"
# ========================= Service Plugin Messages =========================
# Format: {service}_{type} - type: credential/unauth/service/vuln
+20
View File
@@ -541,6 +541,26 @@ icmp_debug_stable_done:
other: "[ICMP] 响应稳定,提前结束,耗时 {{.Arg1}},存活 {{.Arg2}}/{{.Arg3}}"
adaptive_pool_resource_exhausted:
other: "[AdaptivePool] 资源耗尽率 {{.Arg1}}%, 线程数 {{.Arg2}} -> {{.Arg3}}"
adaptive_pool_decrease:
other: "并发调整: {{.Arg1}} -> {{.Arg2}} (检测到压力)"
adaptive_pool_increase:
other: "并发调整: {{.Arg1}} -> {{.Arg2}} (网络健康)"
adaptive_pool_slowstart_exit:
other: "慢启动退出: 当前 {{.Arg1}} (检测到拥塞)"
net_probe_result:
other: "网络探测: {{.Arg1}}, RTT {{.Arg2}}ms, 丢包 {{.Arg3}}%, 并发 {{.Arg4}}/{{.Arg5}}"
net_env_lan:
other: "内网"
net_env_wan:
other: "局域网"
net_env_internet:
other: "公网"
net_env_slow:
other: "慢速网络"
env_tune_summary:
other: "参数自适应: Timeout={{.Arg1}}ms, ModuleThread={{.Arg2}}, Retry={{.Arg3}}, ICMPRate={{.Arg4}}, PocNum={{.Arg5}}"
env_fd_limit:
other: "fd limit 约束: 线程数 {{.Arg1}} -> {{.Arg2}} (ulimit={{.Arg3}})"
# ========================= 服务插件通用消息 =========================
# 格式: {service}_{type} - type: credential/unauth/service/vuln