Add adaptive throttle for write-back bandwidth (4.14)

Throughput-based congestion detection: when sustained throughput
drops >30% over sliding window with rising RTT, auto-reduce
write-back speed to 50% of current throughput, then probe back up
at +10% every 2 minutes.

- Throttle state visible via `warpgate status`
- User can disable with BW_ADAPTIVE=no
- Only affects write-back uploads, not read fetches
- New config: BW_ADAPTIVE, BW_ADAPTIVE_WINDOW, BW_ADAPTIVE_PROBE_INTERVAL

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
grabbit 2026-02-16 21:42:00 +08:00
parent 7fd1934be5
commit 823d20606a

View File

@ -253,7 +253,7 @@ flowchart LR
- 预热进度显示
#### 4.13 管理工具CLI
- `warpgate status` — 查看服务状态、缓存命中率、回写队列、冲突文件数
- `warpgate status` — 查看服务状态、缓存命中率、回写队列、冲突文件数、当前带宽限速(含 adaptive throttle 状态)
- `warpgate cache-list` — 列出缓存中的文件
- `warpgate cache-clean` — 清理缓存
- `warpgate warmup` — 手动预热
@ -270,6 +270,13 @@ flowchart LR
- 支持上传/下载分别限速
- 运行时动态调整限速(不重启服务)
- 回写带宽不影响读取体验
- **自适应限速Adaptive Throttle**:基于吞吐量观测自动降速,避免回写占满链路影响家人上网
- 监控回写吞吐量的滑动窗口(如最近 30s 平均值),当吞吐持续下降超过阈值(如连续 3 个窗口下降 >30%)且 RTT 同步上升时,判定链路拥塞
- 拥塞时自动将回写限速降至当前吞吐的 50%,释放带宽给其他流量
- 每隔一段时间(如 2 分钟)小幅探测提速(+10%),如果吞吐恢复则逐步回升
- throttle 状态通过 `warpgate status` 实时可见(当前限速值 / 是否处于 throttle / 触发原因)
- 用户可通过 `BW_ADAPTIVE` 配置关闭自适应限速,退回纯手动限速模式
- 自适应限速**仅控制回写(上传)**,不影响读取拉取
#### 4.15 连接容错
- Tailscale 断连时自动重试
@ -1114,8 +1121,11 @@ flowchart TD
|------|------|--------|----------|
| `WRITE_BACK` | 写回延迟 | `60s` | Lightroom: `60-120s`,文档: `10-30s` |
| `TRANSFERS` | 并发回写线程 | `4` | 带宽小就设 `2` |
| `BW_LIMIT_UP` | 上传限速 | `0`(不限) | 酒店 WiFi 建议 `10-20M` |
| `BW_LIMIT_UP` | 上传限速上限 | `0`(不限) | 酒店 WiFi 建议 `10-20M` |
| `BW_LIMIT_DOWN` | 下载限速 | `0`(不限) | 一般不限 |
| `BW_ADAPTIVE` | 自适应限速开关 | `yes` | `yes`=根据吞吐量自动降速,`no`=纯手动 |
| `BW_ADAPTIVE_WINDOW` | 吞吐量观测滑动窗口 | `30s` | - |
| `BW_ADAPTIVE_PROBE_INTERVAL` | 拥塞后探测提速间隔 | `2m` | - |
### 目录缓存与轮询