You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Mapping Store startup awaited every Thread, metadata, and delegation read serially, which compounds latency on stores with hundreds of records.
Read Thread records and their metadata, then delegation records, in ordered batches of up to eight. Keep recovery, quarantine, migration, and map insertion in the original directory order under the existing lock.
Drain every read in an active batch before surfacing an error to initialization cleanup. Preserve backup fallback and the existing exclusive lock and takeover protocol.
Related issues
Refs #595. Thanks to #609 for the prior bounded-read work. Archived records still load at startup. Physical HDD and end-to-end Desktop startup remain to be measured.
UI Demo
N/A (Mapping Store startup I/O).
Test plan
Both new regressions failed on the base commit and passed with this change. vitest run --config tests/vitest.config.js packages/mapping-store/test passed all 166 tests in 15 files. Coverage includes ordered bounded reads, lock retention on failure, and reopening the same instance.
Benchmarked MappingStore.initialize() on arm64 macOS, Node 22.23.2, before commit 049b07b91 and after c381ede95. Each alternating sample used a fresh copy of the same synthetic data with 725 Threads (573 archived), 208 metadata files, 204 delegations, and 344 backups. Fixture setup and teardown were outside the measured interval. Both revisions read the same 1,654 record paths per sample and produced matching Thread and delegation data.
Workload
Samples per revision
Median, before → after
p90, before → after
Local disk, warm cache
15
85.0 ms → 38.6 ms
91.3 ms → 43.2 ms
Local files with 5 ms added per record read
7
10.009 s → 1.316 s
10.083 s → 1.392 s
The maximum observed number of simultaneous record reads was 1 before and 8 after. Independent per-read delays model latency, not a physical drive's seek behavior.
Mapping Store startup reads are now batched up to eight at a time, with recovery order and lock behavior preserved. Failures are drained before cleanup. No merge-blocking risk was identified, and physical HDD performance remains unmeasured.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
标题“perf(mapping-store): bound startup file reads”准确描述了主要变更:Mapping Store 启动时的文件读取改为分批并发读取,每批最多 8 项。标题与变更集、PR 目标和提交信息一致,没有无关内容。
Reviewing files that changed from the base of the PR and between 1143c82 and c381ede.
Files selected for processing: 4
docs/architecture/harness-plugin-runtime.md
packages/mapping-store/src/mapping-store.ts
packages/mapping-store/src/startup-reads.ts
packages/mapping-store/test/startup-reads.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
Source excerpt: `codexhost` runs external Agent Harnesses as independent Threads inside Codex Desktop, preserving the official shell and native Codex path.
CodeRabbit inference engine (AGENTS.md)
Files:
docs/architecture/harness-plugin-runtime.md
packages/mapping-store/src/mapping-store.ts
packages/mapping-store/src/startup-reads.ts
packages/mapping-store/test/startup-reads.test.ts
ast-grep (0.51.3)
packages/mapping-store/test/startup-reads.test.ts
[warning] 26-26: Filesystem path is not a string literal; a request-/variable-derived path can enable path traversal. Validate and normalize the path before use.
Context: fs.readFile(file, options)
Note: [CWE-22] Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal').
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
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.
Summary
Mapping Store startup awaited every Thread, metadata, and delegation read serially, which compounds latency on stores with hundreds of records.
Related issues
Refs #595. Thanks to #609 for the prior bounded-read work. Archived records still load at startup. Physical HDD and end-to-end Desktop startup remain to be measured.
UI Demo
N/A (Mapping Store startup I/O).
Test plan
vitest run --config tests/vitest.config.js packages/mapping-store/testpassed all 166 tests in 15 files. Coverage includes ordered bounded reads, lock retention on failure, and reopening the same instance.tsc -b packages/mapping-store, focused ESLint, Prettier, andgit diff --checkpassed.MappingStore.initialize()on arm64 macOS, Node 22.23.2, before commit049b07b91and afterc381ede95. Each alternating sample used a fresh copy of the same synthetic data with 725 Threads (573 archived), 208 metadata files, 204 delegations, and 344 backups. Fixture setup and teardown were outside the measured interval. Both revisions read the same 1,654 record paths per sample and produced matching Thread and delegation data.The maximum observed number of simultaneous record reads was 1 before and 8 after. Independent per-read delays model latency, not a physical drive's seek behavior.