-
Notifications
You must be signed in to change notification settings - Fork 195
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
Use yarn nodeLinker: node-modules to make tests faster #652
base: main
Are you sure you want to change the base?
Conversation
This change almost halves the execution time of `main.test.ts` (from 57s to 35s on my machine using NOCK_ENV=replay). The end-to-end tests run corepack in a new node process about 150 times. With the pnp linker, node is asked to require `.pnp.cjs` on every startup which significantly contributes to test time.
|
Yeah, for the Node 22 test on Ubuntu total job time drops by 40s to 1min. And on Windows it drops by 3:40 to 8min. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't mind, it's true that we're in kind of a special case here since we're spawning a very large amount of subprocesses in our tests.
- "main": "lib/advanced/index", | ||
+ "main": "lib/advanced/index.js", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why those changes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the original patch I get the following error:
Error: Directory import '.../corepack/node_modules/clipanion/lib/platform' is not supported resolving ES modules imported from ...corepack/node_modules/clipanion/lib/advanced/Cli.mjs
In fact, Cli.mjs
uses import ... from './platform'
but Node requires relative import specifiers to always point to files. I guess this worked before because yarn’s resolver is implemented differently and supports relative package imports.
This comment was marked as resolved.
This comment was marked as resolved.
Will you merge this? It seems like a good improvement. |
I would prefer to keep PnP, if only to have a Node.js project dogfooding the default yarn install strategy. The perf impact is unfortunate, but 30% doesn't feel too dramatic an increase that this is a must-do. |
This change almost halves the execution time of
main.test.ts
(from 57s to 35s on my machine using NOCK_ENV=replay). I expect similar results on CI.The end-to-end tests run corepack in a new node process about 150 times. With the pnp linker, node is asked to require
.pnp.cjs
on every startup which significantly contributes to test time.As an alternative, I tried removing
--require=.pnp.cjs
fromNODE_OPTIONS
inrunCli
. After all, we’re running the bundled version of corepack. But this did not work becausetests/recordRequests.js
is also required which in turn needsbetter-sqlite3
.