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

Speed up createNext test suite isolation #64909

Merged
merged 5 commits into from
Apr 23, 2024

Conversation

timneutkens
Copy link
Member

@timneutkens timneutkens commented Apr 23, 2024

What?

Before: 25.71s

CleanShot 2024-04-23 at 12 19 42@2x

After: 11.05s (-57%)

CleanShot 2024-04-23 at 12 16 35@2x

How?

Currently the system for isolation looks like this:

  • Copy packages folder to an isolated directory
  • Run pnpm pack for all folders in packages
  • Collect the pack files, add them as dependencies in package.json of the isolated application
  • Run pnpm install

Because the next-swc (Turbopack + SWC, yes we still need to rename the package) binary file is quite large in development (900MB+) it means we have to copy, then zip (pnpm pack), then unzip (pnpm install) that binary, which takes about 3+ seconds in each step.

The change in this PR is to skip the copy/zip/unzip completely by providing the folder path for the binary directly to Next.js, as it's a binary we don't need the special isolation for this, it's already standalone so running it directly allows us to skip 14,6 seconds of work that is required for each isolated test in development.

This will likely have little effect on CI times as we already do some tricks like only running the packing at the start of the CI process. Only thing that could be better and is probably worth doing is adopting this change for the time it saves for unzipping, that's almost 4 seconds per test still.

Closes NEXT-3200

@timneutkens timneutkens requested review from molebox and delbaoliveira and removed request for a team April 23, 2024 10:17
Copy link
Member Author

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

Join @timneutkens and the rest of your teammates on Graphite Graphite

@timneutkens timneutkens marked this pull request as draft April 23, 2024 10:17
Copy link

socket-security bot commented Apr 23, 2024

Removed dependencies detected. Learn more about Socket for GitHub ↗︎

🚮 Removed packages: npm/next@14.2.1

View full report↗︎

@ijjk
Copy link
Member

ijjk commented Apr 23, 2024

Failing test suites

Commit: 93a4d38

pnpm test-start test/e2e/app-dir/app-compilation/index.test.ts

  • app dir > Loading > should render loading.js in initial html for slow page
Expand output

● app dir › Loading › should render loading.js in initial html for slow page

next build failed with code/signal 1

  89 |           if (code || signal)
  90 |             reject(
> 91 |               new Error(`next build failed with code/signal ${code || signal}`)
     |               ^
  92 |             )
  93 |           else resolve()
  94 |         })

  at ChildProcess.<anonymous> (lib/next-modes/next-start.ts:91:15)

Read more about building and testing Next.js in contributing.md.

@ijjk
Copy link
Member

ijjk commented Apr 23, 2024

Tests Passed

@timneutkens timneutkens marked this pull request as ready for review April 23, 2024 13:02
@@ -25,6 +25,6 @@
"fontkit": "2.0.2"
},
"peerDependencies": {
"next": "*"
"next": "14.3.0-canary.15"
Copy link
Member Author

Choose a reason for hiding this comment

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

This was causing another version of Next.js to be installed, i.e. 14.2.1 and as such caused conflicts and sometimes resolved to the older version incorrectly.

Copy link
Member

@huozhi huozhi left a comment

Choose a reason for hiding this comment

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

Nice PR!

@timneutkens timneutkens merged commit a65bd31 into canary Apr 23, 2024
73 of 79 checks passed
@timneutkens timneutkens deleted the 04-23-Speed_up_createNext_test_suite_isolation branch April 23, 2024 19:13
This was referenced Apr 23, 2024
ijjk added a commit that referenced this pull request Apr 23, 2024
@github-actions github-actions bot added the locked label May 9, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 9, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants