Skip to content

perf(fmt): optimize Yuku parser selection - #312

Merged
chenjiahan merged 2 commits into
mainfrom
chenjiahan/perf-yuku-parser
Aug 11, 2026
Merged

perf(fmt): optimize Yuku parser selection#312
chenjiahan merged 2 commits into
mainfrom
chenjiahan/perf-yuku-parser

Conversation

@chenjiahan

Copy link
Copy Markdown
Member

Summary

This PR makes Yuku language selection extension-driven so regular TypeScript files no longer scan their full contents with a JSX regex or retry unrelated grammars. It also masks comments in a single chunked pass instead of rebuilding the complete source for each comment, while preserving JS JSX, TS/TSX, declaration-file, and module/CommonJS behavior.

Performance

Mean isolated CPU time per real repository corpus:

Benchmark Before After Speedup
Language selection — Rsbuild (1,318 files, 1.80M chars) 18.00 ms 0.097 ms 185.6×
Language selection — Rspack (491 files, 1.68M chars) 33.77 ms 0.030 ms 1,138×
Comment masking — Rsbuild (360 files with comments) 7.89 ms 2.15 ms 3.7×
Comment masking — Rspack (2,822 files with comments) 7.19 ms 4.74 ms 1.5×

Comment-mask output matched for all 2,202 parsed Rsbuild files and 3,613 parsed Rspack files. These are isolated CPU benchmarks; end-to-end formatting gains are smaller because Prettier work dominates and rs fmt formats files in parallel.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 11, 2026

Copy link
Copy Markdown

Deploying rstack-cli with  Cloudflare Pages  Cloudflare Pages

Latest commit: 5354dea
Status: ✅  Deploy successful!
Preview URL: https://10c93ece.rstack-cli.pages.dev
Branch Preview URL: https://chenjiahan-perf-yuku-parser.rstack-cli.pages.dev

View logs

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 84731a982f

ℹ️ 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".

Comment thread packages/rstack/src/fmt/yukuPlugin.ts
@chenjiahan
chenjiahan merged commit b39de82 into main Aug 11, 2026
5 checks passed
@chenjiahan
chenjiahan deleted the chenjiahan/perf-yuku-parser branch August 11, 2026 06:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant