mirror of
https://github.com/pnpm/pnpm.git
synced 2026-04-28 02:53:15 -04:00
perf(resolve-dependencies): avoid copying preferredVersions object (#6735)
replacing object spread with a prototype chain, avoiding extra memory allocations in resolveDependencies this becomes noticeable on relatively large monorepo(~2k packages) reducing memory usage and making it slightly faster 1. allowing to complete `pnpm install` without `--max_old_space_size=8192` (it is noticeably slower, but at least works) 2. prevents OOM issue with `auto-install-peers=true` (this is crashing otherwise no matter `max_old_space_size`)
This commit is contained in:
5
.changeset/brave-clouds-sing.md
Normal file
5
.changeset/brave-clouds-sing.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@pnpm/resolve-dependencies": patch
|
||||
---
|
||||
|
||||
replacing object copying with a prototype chain, avoiding extra memory allocations in resolveDependencies function
|
||||
@@ -522,7 +522,7 @@ export async function resolveDependencies (
|
||||
postponedPeersResolutionQueue.push(postponedPeersResolution)
|
||||
}
|
||||
})
|
||||
const newPreferredVersions = { ...preferredVersions }
|
||||
const newPreferredVersions = Object.create(preferredVersions) as PreferredVersions
|
||||
const currentParentPkgAliases: Record<string, PkgAddress | true> = {}
|
||||
for (const pkgAddress of pkgAddresses) {
|
||||
if (currentParentPkgAliases[pkgAddress.alias] !== true) {
|
||||
|
||||
Reference in New Issue
Block a user