Unverified Commit 6bcb06c1 authored by Shu Ding's avatar Shu Ding Committed by GitHub

Limit the static paths worker number during development (#45344)

As per my testing, this saves about 150~210 MB memory for the dev server
as I have an 8-core CPU.

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see
[`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the
feature request has been accepted for implementation before opening a
PR.
- [ ] Related issues linked using `fixes #number`
- [ ]
[e2e](https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have a helpful link attached, see
[`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm build && pnpm lint`
- [ ] The "examples guidelines" are followed from [our contributing
doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)

---------
parent 23353771
...@@ -126,7 +126,9 @@ export default class DevServer extends Server { ...@@ -126,7 +126,9 @@ export default class DevServer extends Server {
require.resolve('./static-paths-worker'), require.resolve('./static-paths-worker'),
{ {
maxRetries: 1, maxRetries: 1,
numWorkers: this.nextConfig.experimental.cpus, // For dev server, it's not necessary to spin up too many workers as long as you are not doing a load test.
// This helps reusing the memory a lot.
numWorkers: Math.min(this.nextConfig.experimental.cpus || 2, 2),
enableWorkerThreads: this.nextConfig.experimental.workerThreads, enableWorkerThreads: this.nextConfig.experimental.workerThreads,
forkOptions: { forkOptions: {
env: { env: {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment