-
Notifications
You must be signed in to change notification settings - Fork 26.7k
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
Optimize next-app-loader resolving speed #50745
Merged
kodiakhq
merged 6 commits into
canary
from
06-03-Optimize_next-app-loader_resolving_speed
Jun 5, 2023
Merged
Optimize next-app-loader resolving speed #50745
kodiakhq
merged 6 commits into
canary
from
06-03-Optimize_next-app-loader_resolving_speed
Jun 5, 2023
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
timneutkens
requested review from
ijjk,
shuding,
a team,
huozhi and
feedthejim
as code owners
June 3, 2023 20:33
Current dependencies on/for this PR:
This comment was auto-generated by Graphite. |
Failing test suitesCommit: 08e0d63
Expand output● node builtins › should have polyfilled node.js builtins for the browser correctly in client component
Read more about building and testing Next.js in contributing.md. |
huozhi
approved these changes
Jun 5, 2023
This was referenced Jun 6, 2023
hydRAnger
pushed a commit
to hydRAnger/next.js
that referenced
this pull request
Jun 12, 2023
## What? We recently implemented an optimized resolving method for `app` in Turbopack, this ports some of the main changes in that resolving logic to optimize `next-app-loader` which during compilation resolves the tree structure that we use to render in `app-render.tsx`. Here's the results for a page that is nested a few levels deep on vercel.com using App Router. These results only cover `next-app-loader`, not any modules compiled below it. ### Before <img width="671" alt="CleanShot 2023-06-03 at 22 36 26@2x" src="https://github.com/vercel/next.js/assets/6324199/0edeb060-2460-4a7d-95a7-1c22ea26a065"> ### After <img width="673" alt="CleanShot 2023-06-03 at 22 55 10@2x" src="https://github.com/vercel/next.js/assets/6324199/f40964fc-b169-4d95-8711-73cbff3ec76a"> ## Raw numbers <table> <tr> <td>Before</td> <td>After</td> <td>Delta</td> <td>Delta (percent)</td> </tr> <tr> <td>1.620 ms</td> <td>76.39 ms</td> <td>-1.543.61 ms</td> <td>-95.2%</td> </tr> </table> ## How? Changed the resolving logic to use `fileExists`, looping over the provided pageExtensions. For Turbopack we have a process that does only one pass for generating all trees. That also only reads directories instead of checking individual files, which is even better (<5ms for generating all possible trees) but this PR is a quick win that has a big impact already without refactoring the entire entries generation in webpack.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What?
We recently implemented an optimized resolving method for
app
in Turbopack, this ports some of the main changes in that resolving logic to optimizenext-app-loader
which during compilation resolves the tree structure that we use to render inapp-render.tsx
.Here's the results for a page that is nested a few levels deep on vercel.com using App Router. These results only cover
next-app-loader
, not any modules compiled below it.Before
After
Raw numbers
How?
Changed the resolving logic to use
fileExists
, looping over the provided pageExtensions.For Turbopack we have a process that does only one pass for generating all trees. That also only reads directories instead of checking individual files, which is even better (<5ms for generating all possible trees) but this PR is a quick win that has a big impact already without refactoring the entire entries generation in webpack.