Unverified Commit 7ef95ba7 authored by Shu Ding's avatar Shu Ding Committed by GitHub

Add `computeWorkerKey` to the static optimization worker (#47792)

Since both `exportPage` and `isPageStatic` methods in the static
optimization worker involve loading the actual page component, it's
better to assign the same page to the same worker for these 2 tasks to
avoid unnecessary memory allocation.
Co-authored-by: 's avatarJJ Kasper <jj@jjsweb.site>
parent 8c7e4f9b
......@@ -1272,6 +1272,20 @@ export default async function build(
},
numWorkers: config.experimental.cpus,
enableWorkerThreads: config.experimental.workerThreads,
computeWorkerKey(method, ...args) {
if (method === 'exportPage') {
const typedArgs = args as Parameters<
typeof import('./worker').exportPage
>
return typedArgs[0].pathMap.page
} else if (method === 'isPageStatic') {
const typedArgs = args as Parameters<
typeof import('./worker').isPageStatic
>
return typedArgs[0].originalAppPath || typedArgs[0].page
}
return method
},
exposedMethods: sharedPool
? [
'hasCustomGetInitialProps',
......
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