Skip to content

perf(migrate): index finding positions in the Vitest 5 source editor - #3481

Merged
fengmk2 merged 1 commit into
voidzero-dev:mainfrom
jong-kyung:perf/vitest-v5-report-lookup
Nov 18, 2026
Merged

fengmk2 merged 1 commit into
voidzero-dev:mainfrom
jong-kyung:perf/vitest-v5-report-lookup

Conversation

@jong-kyung

@jong-kyung jong-kyung commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

SourceEditor.report() in the Vitest 5 migration repeated two full scans on every call, so its cost grew with the square of the number of findings in a file. This change removes both scans without changing the reported output.

Changes

Line and column lookup. Each call sliced the source from the start of the file to the node and split that prefix into lines to find the line and column. The first call now builds a table of line start offsets once, and later calls reuse it and find the line with a binary search. The column is the distance from the start of that line, so UTF-16 columns stay the same. The table uses the existing line terminator pattern, which treats \r\n, \n,
\r, \u2028, and \u2029 as line breaks. Files without findings never build the table.

Duplicate findings. Each call scanned every earlier finding to skip duplicates. Reported findings are now tracked in a Set keyed by line, column, code, and message, which are the same fields the previous check compared. The findings array and its order are unchanged.

@jong-kyung jong-kyung self-assigned this Nov 18, 2026
@jong-kyung

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-18T06:31:45.716452Z f4443f2 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

Reviewed commit: 04c352f6bd

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@jong-kyung jong-kyung added test: e2e Auto run e2e tests test: install-e2e run vite install e2e test test: create-e2e Run `vp create` e2e tests test: sfw labels Nov 18, 2026
SourceEditor.report() split the source prefix and scanned every earlier finding on each call, so its cost grew with the square of the finding count. Compute line starts once per file on the first report, look up positions with a binary search, and detect duplicates with a Set.
@jong-kyung
jong-kyung force-pushed the perf/vitest-v5-report-lookup branch from 1270271 to f4443f2 Compare November 18, 2026 06:24
@jong-kyung
jong-kyung marked this pull request as ready for review November 18, 2026 06:28
@jong-kyung
jong-kyung requested a review from fengmk2 November 18, 2026 06:32

@fengmk2 fengmk2 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job!

@fengmk2
fengmk2 merged commit 3ab5493 into voidzero-dev:main Nov 18, 2026
122 checks passed
@jong-kyung
jong-kyung deleted the perf/vitest-v5-report-lookup branch November 18, 2026 08:20
@fengmk2 fengmk2 mentioned this pull request Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test: create-e2e Run `vp create` e2e tests test: e2e Auto run e2e tests test: install-e2e run vite install e2e test test: sfw

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants