Repository navigation
Conversation
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.
背景
基于当前
master(6d93e072b76be983394c4e2f82803803697e1bb4,1.7.5)。流式 token 更新会反复扫描历史 parts、重新估算未变化的大段工具输出,并保存相同的分布快照。已有的 part debounce 仍同时递增立即刷新信号,未能合并实际的重计算;V2 全局事件也需要按当前查看的会话过滤。另外,旧
dist_snapshot不记录所属会话,切换到尚未加载消息的会话时可能显示前一个会话的分布。改动
{ version: 1, sessionID, dist },只恢复当前会话且字段有效的值。250ms 合并、逐字段比较、异步串行保存,慢存储最多保留一个最新等待值;切换与卸载时 flush,失败不影响面板。无归属的旧派生缓存会重新计算,不修改真实消息或历史记录。验证
npm test:21 项通过,包括原有余额/凭据测试,以及语义缓存、原地修改、迟到数据、回合边界、快照归属、持续流不饥饿、异步串行保存、等待队列去重及存储失败。npm run typecheck、npm run build、npm pack --dry-run、git diff --check均通过。性能测量
比较未修改的已安装 1.7.5 bundle与最终构建。fixture 挂载实际面板与适配层,使用 host memory storage、128 条合成消息,每条工具输出 17,408 字符;当前消息进行 64 次 token 更新(间隔 20ms,结束后等待 450ms)。不挂载余额轮询/命令根,不读取余额凭据或发起模型请求。
该合成、大输出、活跃更新阶段的整份客户端 CPU 耗时减少 89.1%;输出 getter 访问减少 79.8%,snapshot update 调用减少 92.2%。新旧初始及最终分布完全一致。其他会话的八个 legacy 回调由九次无效扫描/相同快照更新降至零;当前会话数据未变化时也不再保存相同快照。
测量边界
process.cpuUsage()的 user + system CPU-ms,不是插件独占 CPU,也不是常态 CPU 使用率。证据与复现
scripts/benchmark-visual-cache.py+scripts/fixtures/visual-cache.mjs:无需旁边的其他插件仓库;检查会话已存在、拒绝覆盖已有证据目录、验证实际加载 bundle 的 profile,并确认全局 CLI 配置与 bundle 未改变。复现命令见报告。最终评审加强了异步保存与卸载处理,已重新测量最终 bundle;此前开发阶段的约 90% 数据不作为本 PR 的最终证据。