Skip to content

perf(migrate): speed up rewriteAllImports ~16x with cached rules, pre-filter, and rayon#1172

Open
fengmk2 wants to merge 1 commit intomainfrom
improve-migreate-perf
Open

perf(migrate): speed up rewriteAllImports ~16x with cached rules, pre-filter, and rayon#1172
fengmk2 wants to merge 1 commit intomainfrom
improve-migreate-perf

Conversation

@fengmk2
Copy link
Copy Markdown
Member

@fengmk2 fengmk2 commented Mar 27, 2026

  • Cache ast-grep YAML rule parsing with LazyLock (eliminating 921 redundant parses)
  • Add string pre-filter to skip files without vite/vitest/tsdown imports
  • Parallelize file processing with rayon

Benchmark on 307-file project: 20.7s → 1.3s (~16x faster).

Closes #1156

@netlify
Copy link
Copy Markdown

netlify bot commented Mar 27, 2026

Deploy Preview for viteplus-preview canceled.

Name Link
🔨 Latest commit c79fe17
🔍 Latest deploy log https://app.netlify.com/projects/viteplus-preview/deploys/69c687eb144d130008c1c10d

@fengmk2 fengmk2 requested review from branchseer and kazupon March 27, 2026 13:29
Copy link
Copy Markdown
Member Author

fengmk2 commented Mar 27, 2026


How to use the Graphite Merge Queue

Add the label auto-merge to this PR to add it to the merge queue.

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@fengmk2 fengmk2 self-assigned this Mar 27, 2026
@fengmk2 fengmk2 marked this pull request as ready for review March 27, 2026 13:29
@fengmk2 fengmk2 added the test: e2e Auto run e2e tests label Mar 27, 2026 — with Graphite App
@fengmk2 fengmk2 force-pushed the improve-migreate-perf branch from 3812717 to 8d88279 Compare March 27, 2026 13:34
…-filter, and rayon

- Cache ast-grep YAML rule parsing with LazyLock (eliminating 921 redundant parses)
- Add string pre-filter to skip files without vite/vitest/tsdown imports
- Parallelize file processing with rayon

Benchmark on 307-file project: 20.7s → 1.3s (~16x faster).

Closes #1156
@fengmk2 fengmk2 force-pushed the improve-migreate-perf branch from 8d88279 to c79fe17 Compare March 27, 2026 13:36
@fengmk2
Copy link
Copy Markdown
Member Author

fengmk2 commented Mar 27, 2026

Before

before-Screen.Recording.2026-03-27.at.21.43.07.mov

After

afterScreen.Recording.2026-03-27.at.21.45.11.mov

@kazupon It might be that my computer's performance is too good, so the previous serial version wasn't too slow either. 😃

@kazupon
Copy link
Copy Markdown
Collaborator

kazupon commented Mar 28, 2026

@fengmk2
I've verified the performance improvement on vrowser monorepo project:

  • Before: ~211s total (~194s in Step 7: Rewrite configs)
  • After: ~21s total
  • ~10x faster end-to-end

Thank you so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test: e2e Auto run e2e tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

vp migrate shows no progress for 3+ minutes after config merge steps

2 participants