Repository navigation
fix(agent-core-v2): reduce workspace registry read amplification - #4747
Merged
Merged
Conversation
🦋 Changeset detectedLatest commit: 7ce5b31 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
commit: |
hunshcn
force-pushed
the
fix/workspace-catalog-read-amplification
branch
from
November 9, 2026 11:28
387c4a8 to
7ce5b31
Compare
sailist
approved these changes
Nov 9, 2026
This was referenced Nov 10, 2026
Closed
Closed
Merged
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.
Requirement or Bug
长时间运行的服务积累大量 workspace 后,项目注册或更新会让多个会话重复读取并解析同一份
projects.json,拖慢其他 workspace 操作。本 PR 复用未变化的项目索引,并合并等待执行的目录刷新,降低这部分重复工作。Bug Reproduction Steps
projects.json,启动多个使用该项目注册表的会话。Root Cause
FileWorkspacePersistence.load()每次都重新读取并解析全量文档。每个WorkspaceDirsService又会为每次全局变更单独排入一次刷新,同一文件的解析工作被多个会话及连续通知放大。本 PR 直接减少重复读取和重复排队,不改变超时时间,也不清理已有项目。
Code Changes
项目索引按文件版本复用解析结果;目录服务只保留一个尚未开始的刷新,刷新运行期间收到的变更仍可触发一次后续刷新。刷新继续调用
reloadWorkspace(),保留主目录变化时同步本地配置和文件监听的行为。缓存版本包含 dev、ino、size、mtimeNs 和 ctimeNs;读取前后版本不同则不缓存该次结果。文件监听通知和写入均使缓存失效。写操作继续在原有锁内读取最新文档;没有本地路径或 stat 失败时仍走原读取路径。
建议从
fileWorkspacePersistence.ts的 load/update 看起,再看workspaceDirsService.ts的通知排队逻辑。Behavior Changes and Affected Users
projects.json的外部脚本相关回归覆盖重复读取、写后可见、同大小且保留 mtime 的原子替换、损坏后恢复、读取期间原子替换,以及刷新进行中收到突发通知后最终目录仍正确。未改协议、配置默认值、项目数据格式或旧数据迁移;没有删除项目或改变 trust 判定。
本地验证
1c259c8d35ff648ce8aa3f77169d9887e2a16384验证 workspace、aliases、dirs、trust 共 4 个测试文件:128 passed。Checklist
/approve). No separate issue; reproduction and cause are described above.gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update. No user-facing command, configuration, or API documentation changed.