Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf(remix-dev/vite): extract route module exports in parallel for route manifest generation + use transformRequest to utilize vite's transform cache #8102

Closed

Conversation

hi-ogawa
Copy link
Contributor

@hi-ogawa hi-ogawa commented Nov 22, 2023

(These two ideas are independent, so we can evaluate separately. For initial testing, I pushed in one PR, but I'll create two PRs separately later)

1st idea

Not properly tested or benchmarked yet, but it seems doing await getRouteModuleExports(...) in for loop slow down server start up, so I'm experimenting with doing Promise.all instead.
(Regarding this, I was initially looking at server.warmup option https://vitejs.dev/config/server-options#server-warmup, but what it does is more-or-less just triggering transformRequest in parallel (code) and actually server.warmup won't be triggered for child compiler use cases, so I didn't think further about this option.)

2nd idea

Also, while looking at getRouteModuleExports, I thought it might be beneficial to use ViteDevServer.transformRequest API instead of manually transforming code via PluginContainer API. Currently, I needed experimental.skipSsrTransform to make it work, but I also have another idea to not rely on that (see TODO in the code).
Again I haven't tested properly yet, but I'm hoping this might allow utilizing vite's cache (+ auto invalidation?) to save unnecessary transform.
If this idea is sound, then remix's own caching introduced in #7908 to reduce virtual entry invalidation might not be necessary since I think the bottleneck is getDevManifest transforming all route files to extract all exports.


To be able to analyze and evaluate perf ideas more systematically, I'm thinking to prepare dummy remix app with many routes and components. For example, It would be something like remix-equivalent of these benchmarks:

Copy link

changeset-bot bot commented Nov 22, 2023

⚠️ No Changeset found

Latest commit: 03e9887

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@hi-ogawa hi-ogawa changed the title perf(remix-dev/vite): use ViteDevServer.transformRequest for to utilize vite's transform cache + resolve route module exports in parallel perf(remix-dev/vite): use transformRequest for to utilize vite's transform cache + resolve route module exports in parallel Nov 22, 2023
@hi-ogawa hi-ogawa changed the title perf(remix-dev/vite): use transformRequest for to utilize vite's transform cache + resolve route module exports in parallel perf(remix-dev/vite): use transformRequest to utilize vite's transform cache + resolve route module exports in parallel Nov 22, 2023
@hi-ogawa hi-ogawa changed the title perf(remix-dev/vite): use transformRequest to utilize vite's transform cache + resolve route module exports in parallel perf(remix-dev/vite): resolve route module exports in parallel + use transformRequest to utilize vite's transform cache Nov 22, 2023
@hi-ogawa hi-ogawa force-pushed the perf-vite-getRouteModuleExports-warmup branch from 3e7c8ad to 8f1a573 Compare November 22, 2023 13:03
…compiler to utilize vite's transform cache + resolve route module exports in parallel
@hi-ogawa hi-ogawa force-pushed the perf-vite-getRouteModuleExports-warmup branch from d41cee1 to 03e9887 Compare November 22, 2023 13:22
@hi-ogawa hi-ogawa changed the title perf(remix-dev/vite): resolve route module exports in parallel + use transformRequest to utilize vite's transform cache perf(remix-dev/vite): extract route module exports in parallel + use transformRequest to utilize vite's transform cache Nov 22, 2023
@hi-ogawa hi-ogawa changed the title perf(remix-dev/vite): extract route module exports in parallel + use transformRequest to utilize vite's transform cache perf(remix-dev/vite): extract route module exports in parallel for route manifest generation + use transformRequest to utilize vite's transform cache Nov 23, 2023
@hi-ogawa hi-ogawa closed this Nov 23, 2023
@hi-ogawa hi-ogawa deleted the perf-vite-getRouteModuleExports-warmup branch November 23, 2023 06:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants