next.js
af83b4b3 - Drop turbo_tasks::function from ValueDebug trait items (#92593)

Commit
97 days ago
Drop turbo_tasks::function from ValueDebug trait items (#92593) ## What? Simplify the `ValueDebug` trait in turbo-tasks by removing turbo-tasks function overhead from `dbg` and `dbg_depth`. ## Why? Every `#[turbo_tasks::value]` and `#[turbo_tasks::value_trait]` type previously generated two `#[turbo_tasks::function]` implementations of `dbg` and `dbg_depth`. These are debugging utilities that are almost never called in production, but the turbo-tasks function machinery (task registration, vtable entries, `NativeFunction` statics, inline extension traits) was emitted for every type regardless — contributing to binary bloat. ## How? - Change `dbg` and `dbg_depth` on the `ValueDebug` trait from `#[turbo_tasks::function]` methods to plain methods returning `Pin<Box<dyn Future<...>>>` (required for object safety without `async_trait`) - Add a default `dbg` implementation on the trait itself that delegates to `dbg_depth(usize::MAX)`, so derived impls only need to implement `dbg_depth` - Remove `ValueDebugString` wrapper type — callers now get a plain `String` back - Callers use `vc.into_trait_ref().await?` then call `.dbg()` / `.dbg_depth()` directly on the trait ref - Update the four macro locations that generate `ValueDebug` impls: `value_debug_macro.rs`, `value_macro.rs`, `primitive_macro.rs`, and the call site in `vc/mod.rs` - `#[turbo_tasks::value_impl]` is kept on the generated `impl ValueDebug for T` blocks so that `Upcast`/`UpcastStrict` and `CollectableTraitCastFunctions` (needed for `into_trait_ref`) are still registered ## Binary size impact (darwin-arm64, compared against canary) | Metric | Canary | This PR | Delta | |---|---|---|---| | Unstripped dylib | 128.6 MB | 124.6 MB | **-4.0 MB (-3.1%)** | | Stripped | 87.2 MB | 84.7 MB | **-2.5 MB (-2.9%)** | | Stripped + gzip (npm) | 29.6 MB | 29.2 MB | **-0.4 MB (-1.4%)** | <!-- NEXT_JS_LLM_PR -->
Author
Parents
Loading