Skip to content

perf(fmt): reuse formatter import promise - #589

Merged
chenjiahan merged 2 commits into
mainfrom
chenjiahan/cache-fmt-import-promise
Oct 20, 2026
Merged

chenjiahan merged 2 commits into
mainfrom
chenjiahan/cache-fmt-import-promise

Conversation

@chenjiahan

@chenjiahan chenjiahan commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

Motivation

Formatting each uncached file repeats a dynamic import() call even after the formatter module has loaded.

Changes

Add a cachedImport helper following Rsbuild: share pending and fulfilled imports, and clear rejected Promises to allow retries. Use it in the formatter worker while keeping imports after cache-hit checks so formatter dependencies still load lazily.

Prior prototype profiling reduced cumulative repeat-import time across 8 workers from 829 ms to 49 ms. Whole-repository check medians were 16.61 s before and 16.64 s after (7 fresh-process runs, Node.js 22.16.0, --no-cache), so no stable end-to-end speedup was observed. These measurements predate the helper extraction.

Validated package and native builds, 156 focused tests (including lazy loading, import reuse, and retry after rejection), lint, type checking, and formatting.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Deploying rstack-cli with  Cloudflare Pages  Cloudflare Pages

Latest commit: 459fa4c
Status: ✅  Deploy successful!
Preview URL: https://904d0157.rstack-cli.pages.dev
Branch Preview URL: https://chenjiahan-cache-fmt-import.rstack-cli.pages.dev

View logs

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-20T13:37:25.831109Z 459fa4c New commits
ℹ️ 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.

@chenjiahan
chenjiahan enabled auto-merge (squash) October 20, 2026 13:38
@chenjiahan
chenjiahan merged commit a462d97 into main Oct 20, 2026
5 checks passed
@chenjiahan
chenjiahan deleted the chenjiahan/cache-fmt-import-promise branch October 20, 2026 13:40
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