[turbopack] Split IsTransient out of TaskInput trait#94136
Draft
lukesandberg wants to merge 2 commits into
Draft
[turbopack] Split IsTransient out of TaskInput trait#94136lukesandberg wants to merge 2 commits into
lukesandberg wants to merge 2 commits into
Conversation
Adds a new `IsTransient` trait with a single method `fn is_transient(&self) -> bool`
defaulting to `false`. Makes `TaskInput: IsTransient` (supertrait), removes
`is_transient` from `TaskInput` itself, and adds a derive proc-macro for `IsTransient`
that emits a field-walking implementation.
This is pure cleanup with two benefits:
1. **Decoupled concern.** Transience checking is orthogonal to whether a type can be
passed as a `#[turbo_tasks::function]` argument. Splitting it out makes the trait
surface cleaner and lets non-`TaskInput` types check transience without adopting
the full TaskInput contract.
2. **Sets up a future blanket impl.** Every `#[derive(NonLocalValue)]` type carries the
property "contains no unresolved Vcs" — exactly the precondition for treating
`TaskInput::resolve_input` as a no-op clone (the `CloneReady` future). A follow-up
commit can have the `NonLocalValue` derive emit the optimized `TaskInput` impl
directly, eliminating the async-fn envelope for ~92 types.
Also switches the default `TaskInput::resolve_input` body from an opaque async block to
the named `CloneReady` future (8 B, no enum discriminant) — small but consistent win
on every primitive impl.
The 144 sites that derive `TaskInput` now also derive `IsTransient`. The handful of
manual `impl TaskInput` blocks (`Pattern`, `Query`, `WebpackLoaderItem`, etc.) drop
the now-orphan `is_transient` method body and gain a trivial `impl IsTransient for X {}`.
…eReady TaskInput
Most #[turbo_tasks::value] types are cell-output types — produced by tasks and never
passed as task arguments — so they don't satisfy TaskInput's supertrait bounds
(`Clone + Eq + Hash + Encode + Decode + ...`). A small fraction (FileSystemPath,
AssetIdent, NextMode, etc.) are intended as function arguments.
This commit adds a `task_input` opt-in flag to #[turbo_tasks::value(...)]:
#[turbo_tasks::value(shared, task_input)]
pub struct FileSystemPath { ... }
When set, the macro:
- Adds `#[derive(turbo_tasks::IsTransient)]` to the struct.
- Emits `impl turbo_tasks::TaskInput for X {}`, using the trait defaults
(`is_resolved = true`, `resolve_input` returns a CloneReady future — 8 bytes,
no async-fn envelope).
Concrete tags applied to high-leverage task-input types: AssetIdent, BatchingConfig,
ClientContextType, EcmascriptModuleAssetType, ExecutionEnvironment, FileSystemPath,
IssueSeverity, NextFontGoogleOptions, NextFontLocalOptions, NextMode, Pattern,
RequestKey, ResolveErrorMode, ServerContextType, SourceMapsType, StyleGroupsAlgorithm.
Measured workspace impact (next-napi-bindings, -Zprint-type-sizes):
- Default change to CloneReady future: -10,760 B (-0.60%)
- task_input opt-in on ~16 types: -17,368 B (-0.96%)
- Combined: -28,128 B (-1.56%)
Follow-ups can tag more leaderboard candidates incrementally as their value justifies.
Contributor
Author
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
Contributor
Stats skippedCommit: 4a4c522 |
Contributor
Failing CI jobsCommit: 4a4c522 | About building and testing Next.js |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

No description provided.