Skip to content

[turbopack] Shrink ReadRawVcFuture from 80 to 64 bytes#94135

Draft
lukesandberg wants to merge 2 commits into
canaryfrom
lukesandberg/shrink-futures
Draft

[turbopack] Shrink ReadRawVcFuture from 80 to 64 bytes#94135
lukesandberg wants to merge 2 commits into
canaryfrom
lukesandberg/shrink-futures

Conversation

@lukesandberg
Copy link
Copy Markdown
Contributor

No description provided.

`ReadRawVcFuture` operates in two phases — resolving the `RawVc` pointer
chain, then reading the resolved cell — and previously held the fields
for both phases simultaneously. Phase 1 carried unused `Option<(TaskId,
CellId)>` and `Option<EventListener>` for phase 2, and phase 2 carried
the now-finished `ResolveRawVcFuture`.

Move the phase-specific fields into a `ReadRawVcState` enum so only one
set is live at a time. `read_cell_options` and `strongly_consistent`
stay in the outer struct since both phases (and the builder) need them.
Two small changes to the TaskInput impls that compound across hundreds of
awaitee positions:

- Vc<T>::resolve_input now returns Vc::resolve() directly instead of an
  async fn body around to_resolved().await. The async fn envelope was
  pure overhead since the body had no other awaits — resolve() already
  returns a Future<Output = Result<Vc<T>>>, which is exactly the trait's
  signature. Using resolve() rather than to_resolved() + deref avoids
  the otherwise-discouraged-but-here-correct ResolvedVc round-trip.

- ResolvedVc<T>::resolve_input override removed. It was `async fn ... { Ok(*self) }`
  which is identical in size and behavior to the default
  `async { Ok(self.clone()) }` for Copy types.

Measured with -Zprint-type-sizes on next-napi-bindings:
- Per-Vc<X>::resolve_input future shrinks from 48 B to 32 B (-33%)
- Cascades into ~36 distinct concrete Vc<X> types and dozens of tuple
  TaskInput impls that contain Vc<T> fields
- Total awaitee-byte reduction across turbo/next contexts: ~94 KB
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 26, 2026

Tests Passed

Commit: 8eb0ac4

Copy link
Copy Markdown
Contributor Author

lukesandberg commented May 26, 2026

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 26, 2026

Stats skipped

Commit: 8eb0ac4
View workflow run

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