[Bug] 会话 rollout 日志 model-io-sess_*.jsonl 逐请求全量落盘导致 O(N²) 膨胀:长会话单文件 1.7GB,本机 91 文件共 12GB(3.10.2 Linux x64)
Nobody has claimed this yet.
- Dominant language
- No language data
- Stars
- 22
- Forks
- 1
- PR merge metrics
- No merged PRs in 30d
Description
提交前确认 · Pre-submission checklist
- 我已搜索过现有 issue,确认这不是重复(
rollout/磁盘/体积/session file size等关键词均无相同反馈;#354 是缓存命中率、#374 是 V8 堆崩溃、#227 是 transcript 导出契约,均不涉及磁盘膨胀) - 我已阅读 CONTRIBUTING.md
问题类别 · Category
存储 / 磁盘占用异常(无上界的日志膨胀)
涉及的 Agent 框架 · Agent framework
ZCode 桌面端(Linux)
严重程度 · Severity
中 —— 不崩溃、不丢数据,但占用无上界增长,重度用户机器会被逐步吃满(本机已 12GB)
复现频率 · Reproducibility
必现(任何工具调用次数多的长会话)
问题描述 · Description
~/.zcode/cli/rollout/model-io-sess_*.jsonl 的每一行是一次模型请求的完整快照:包含 request.body.messages 里的全部历史消息。LLM API 无状态、每轮重发全部历史,rollout 忠实地把每次重发整段落盘,于是文件按 O(N²) 前缀累积增长 —— 一段去重后仅 ~5MB 的对话,经 615 次请求后落成 1.76GB(≈350 倍膨胀)。
本机实测(ZCode 3.10.2,Linux x64):
| 指标 | 数值 |
|---|---|
| 单会话("基座模型 wiki"批量抽取,615 次模型请求) | 1.76GB |
| 该会话逐行大小 | 首条 0MB → 中位 2.8MB → 末条 5.0MB |
| 该会话去重后真实内容 | ≈ 5MB |
| 末条内嵌消息构成 | 631 对 tool_use/tool_result ≈ 1MB+,system+thinking ≈ 0.3MB,用户文本仅 0.05MB |
| 全机 rollout 目录 | 91 个文件共 12GB(~/.zcode/cli/ 几乎全部空间) |
复现步骤 · Steps to reproduce
- 在 ZCode 里开一个长任务会话(例如批量文献抽取:每篇论文若干轮 搜索→读文件→写条目 的工具循环)
- 持续运行至数百次模型请求(本例 615 次)
- 观察文件增长:
watch -n60 'ls -lh ~/.zcode/cli/rollout/model-io-sess_<该会话>.jsonl' - 会话结束后统计:单文件 1.7GB+;工具调用密集的会话普遍 250MB~900MB
验证膨胀机制的脚本:
python3 - <<'EOF'
import json
p = '~/.zcode/cli/rollout/model-io-sess_<uuid>.jsonl' # 任选一个大文件
sizes = [len(l) for l in open(p, 'rb')]
print(f"记录数 {len(sizes)},总 {sum(sizes)/1e9:.2f}GB,末条 {sizes[-1]/1e6:.1f}MB")
# 内容本身只有末条那 ~5MB,其余 615 份是历史前缀的重复落盘
EOF
期望表现 · Expected behavior
rollout 按增量记录(例如:每行只存本轮新增消息 + 指向上一行的引用/哈希,回放时链式重建),或至少提供:
- 单文件/目录体积上限 + 自动轮转(按大小或按会话结束时间清理)
- 设置项或 CLI 子命令手动清理(
zcode rollout prune --older-than 30d之类)
实际表现 · Actual behavior
无任何上限与清理机制;重度使用数月后 rollout 目录 12GB / 91 文件,且其中单个文件被重复内容占据 ~99%(5MB 真实内容 × 615 次前缀快照)。下游凡是要读会话文件的场景(自定义 Stop 钩子、记忆归档、诊断脚本)都必须处理 GB 级 JSONL。
ZCode 版本 · ZCode version
v3.10.2
设备 / 系统 / 浏览器 · Device / OS / Browser
Linux x64(Ubuntu,kernel 7.0.0-30-generic),ZCode 桌面端
截图 / 录屏 / 日志 · Screenshots / Recordings / Logs
$ du -sh ~/.zcode/cli/rollout/ && ls ~/.zcode/cli/rollout/*.jsonl | wc -l
12G /home/jade/.zcode/cli/rollout/
91
# 最大的几个会话文件
1.7G model-io-sess_53a99341-….jsonl # 基座模型wiki(615 次请求)
903M model-io-sess_de79e183-….jsonl # eeg-fnirs项目抽取进展
679M model-io-sess_01eabaf7-….jsonl # 合并论文信息变量并用pi核对
648M model-io-sess_83ca6a99-….jsonl # 发育曲线 wiki
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the growth in ~/.zcode/cli/rollout/model-io-sess_*.jsonl with the supplied Python size-check script and inspect the rollout recording path. Done means repeated model requests no longer create unbounded O(N²) snapshots, with either incremental records or an implemented size/age limit and cleanup mechanism that keeps replay and existing consumers working.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- linux
- Domain
- desktop, performance
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100