Commit 427b524
authored
perf: avoid AST depth depending on pnpm workspace size (#2865)
This converts 2 `if/elif bazel_package == "pnpm-project-path"` blocks
into 2 constants and the `if/elif` is replaced with a lookup into the
constant. See the diffs of the snapshot files for the best outline of
the changes.
This prevents a reported `java.lang.StackOverflowError` from the bazel
starlark parser treating `elif` as nested `else: if`. This reduces the
`npm_link_all_packages()` from N `if/elif` statements into a single map
lookup. The tradeoff is when the generated `defs.bzl` is `load()`ed it
now has 2 giant maps declared at load time.
Overall I (and my robot assistants, and my testing on a repo with ~2k
pnpm workspace projects) think this has negligible impact on actually
performance but should avoid the `java.lang.StackOverflowError`.
### Changes are visible to end-users: no
### Test plan
- Covered by existing test cases1 parent 9350244 commit 427b524
13 files changed
Lines changed: 2733 additions & 2472 deletions
File tree
- .aspect
- e2e
- npm_translate_lock_disable_hooks/snapshots
- npm_translate_lock_empty/snapshots
- npm_translate_lock_replace_packages/snapshots
- pnpm_lockfiles
- v101/snapshots
- v110/snapshots
- v90/snapshots
- pnpm_workspace_rerooted/snapshots
- pnpm_workspace/snapshots
- npm/private
- test/snapshots
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
47 | 50 | | |
48 | 51 | | |
49 | 52 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 29 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 commit comments