Skip to content

[turbopack] Use an arena for JSValues#94297

Open
sampoder wants to merge 1 commit into
sp/turbopack/analyzer-arena-infrafrom
sp/turbopack/analyzer-arena-jsvalue
Open

[turbopack] Use an arena for JSValues#94297
sampoder wants to merge 1 commit into
sp/turbopack/analyzer-arena-infrafrom
sp/turbopack/analyzer-arena-jsvalue

Conversation

@sampoder
Copy link
Copy Markdown
Member

@sampoder sampoder commented Jun 1, 2026

This PR takes the arena introduced in #94296 and uses it! It's large but shouldn't change functionality beyond the use of the arena. Some syntax related to pattern-matching had to change because bumpalo's Box doesn't support the same pattern matching that the standard library's Box does but the code should be equivalent.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 1, 2026

Stats skipped

Commit: 9c87cd9
View workflow run

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 1, 2026

Failing test suites

Commit: 9c87cd9 | About building and testing Next.js

pnpm test-start test/production/app-dir/metadata-static-route-cache/metadata-static-route-cache.test.ts (job)

  • app dir - metadata static routes cache > should generate different content after replace the static metadata file (DD)
Expand output

● app dir - metadata static routes cache › should generate different content after replace the static metadata file

next already started

  65 |   ) {
  66 |     if (this.childProcess) {
> 67 |       throw new Error('next already started')
     |             ^
  68 |     }
  69 |
  70 |     this._cliOutput = ''

  at NextStartInstance.start (lib/next-modes/next-start.ts:67:13)
  at Object.start (production/app-dir/metadata-static-route-cache/metadata-static-route-cache.test.ts:17:16)

Other failing CI jobs

@sampoder sampoder requested review from bgw and lukesandberg June 1, 2026 18:31
@sampoder sampoder marked this pull request as ready for review June 1, 2026 18:31
Bump-allocates the analyzer's `JsValue` tree into a per-thread arena
(`ThreadLocal<Bump>`) that lives for the duration of
`analyze_ecmascript_module_internal` and is freed in one shot when it returns,
replacing the previous `Arc`/`Box`/`Vec` heap allocations. `JsValue` becomes
`JsValue<'a>`, with its list children stored in `BumpVec` (growable) or
`bumpalo::boxed::Box<[_]>` (fixed) and scalar children in `bumpalo::boxed::Box`.

Sync functions take `&Bump` and allocate directly; the async (`Send`-bound)
analysis pipeline holds a `&ThreadLocal<Bump>` and obtains a `&Bump` via
`get_or_default()`, so no `!Send` `&Bump` is ever held across an `.await`.

Builds on the `BumpVec` introduced in the previous commit.
@sampoder sampoder force-pushed the sp/turbopack/analyzer-arena-infra branch from a98d014 to e21492c Compare June 1, 2026 23:29
@sampoder sampoder force-pushed the sp/turbopack/analyzer-arena-jsvalue branch from 4b5a6ea to 9c87cd9 Compare June 1, 2026 23:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant