Repository navigation
perf(runtime): advance fuzzy Edit line offsets incrementally - #6050
Conversation
Avoid rescanning every prior line for each line-trimmed candidate. Keep ambiguity, newline, size-limit and replacement semantics unchanged. Add offset coverage and a CPU-budget regression for repetitive inputs. Fixes apache#6049 Generated-by: OpenAI Codex Signed-off-by: seekskyworld <djh1813553759@gmail.com>
Astro-Han
left a comment
There was a problem hiding this comment.
Automated review notice: This comment was posted by an automated review agent. It is not an independent human review and does not replace one.
I found no actionable P0–P3 issue at a762ca51f269eb4f83eede95615ec7f414a6fc7b.
The change in packages/runtime/src/edit-replace.ts:229 maintains the next line's UTF-16 offset while scanning, rather than summing the entire preceding prefix for each candidate. Advancing that offset before rejecting a nonmatch preserves the original locations; CRLF, unequal line lengths, surrogate pairs, EOF handling, uniqueness checks, fuzzy limits, and literal replacement remain unchanged. The helper is used by both the filesystem executor and worker.
Validation: 46 Edit/filesystem-worker tests passed. An independent seeded comparison of 25,000 inputs produced identical full results or errors on the parent and this head. On the 49,000 repeated-line case, five-call median helper time fell from 9,798.71 ms to 26.51 ms in this environment; four calls consumed 30,862.07 ms versus 80.76 ms of process CPU. The parent's result exceeds the added one-second CPU guard, while this head remains below it. These are helper measurements, not end-to-end latency guarantees.
No protocol epoch, API, dependency, or persistence change. GitHub reports this head mergeable, with successful CI and Windows packaging checks. I did not run Windows locally or repeat the entire repository test suite.
Astro-Han
left a comment
There was a problem hiding this comment.
Approved at @Astro-Han's explicit request: the automated review of this exact head found no blocking (P0–P2) issues, and CI is green.
Summary
Edit's line-trimmed fallback rescans every preceding line to locate each matching candidate. Track the source offset once as lines advance, preserving candidate selection, ambiguity errors, newline handling and line ranges. On an admitted 49,000-line repetitive fixture, median helper latency falls from 653.52ms to 4.48ms (10 samples per version; method and reproduction in the issue).
Fixes #6049
Verification
owned-child-processdescendant cleanup, thenshell-owner-deathreading incomplete fixture JSON). The first failing case passes in isolation and its unchanged baseline suite passes 12/12. The second failing file passes 6/6 when rerun alone. These failures are retained in the validation record; no unrelated test was weakened.AI use
Tool(s) and scope: OpenAI Codex investigated, implemented and tested this change at @seekskyworld's direction. Final review and merge remain human decisions.
Checklist
Does this PR entail a change in behavior?