Unverified Commit 85c3f2e7 authored by Benjamin Woodruff's avatar Benjamin Woodruff Committed by GitHub

Turbopack: bincode: Migrate TaskInput serialization to bincode (#86631)

https://github.com/vercel/next.js/pull/86338 switches cell storage to use bincode, but it uses a compatibility shim for storing `TaskInput`s using `serde` + `pot`. This PR completes the migration by switching `TaskInput` to use `bincode` as well.

## Benchmark Summary

`next build` is consistently faster across a variety of repositories when persistent caching is enabled, and the resulting cache size is consistently smaller.

![Screenshot 2025-12-01 at 9.07.20 PM.png](https://app.graphite.com/user-attachments/assets/2e19f83a-5810-4c55-b67a-aa0dd1c5da22.png)

`cargo build` runs only slightly faster, but there's potential for improving this further by removing unused `serde` macro derives.

## Benchmarking Notes

Performance measurements (aside from cargo build) are taken using `next build`​. This should have proportional benefits for `next dev`​ too, but `next build`​ is more reproducible and easier to measure. `canary` refers to `a8f7b546`.

These numbers are taken with persistent caching enabled with an empty cache, so it's the worst-case scenario for the serialization codepath. We don't care nearly as much about the performance of deserialization because it's less common.

## `cargo build -p next-swc-napi`

This makes builds _slightly_ faster. This branch doesn't clean up the serde derives yet, so there's a bunch of unused macro expansion here, so I think this number is actually pretty good.

```
~/next.js $ hyperfine -w 1 -r 5 -p 'git co a8f7b546 && cargo clean' -p 'git co bgw/bincode-task-inputs && cargo clean' 'cargo build -p next-swc-napi' 'cargo build -p next-swc-napi'
Benchmark 1: cargo build -p next-swc-napi
  Time (mean ± σ):     237.476 s ±  1.420 s    [User: 2001.820 s, System: 84.957 s]
  Range (min … max):   235.294 s … 238.862 s    5 runs

Benchmark 2: cargo build -p next-swc-napi
  Time (mean ± σ):     232.366 s ±  1.549 s    [User: 1945.355 s, System: 83.940 s]
  Range (min … max):   230.550 s … 234.485 s    5 runs

Summary
  cargo build -p next-swc-napi ran
    1.02 ± 0.01 times faster than cargo build -p next-swc-napi
```

## next-site

Using `~/front/apps/next-site` on macos with a M2 Pro. Nothing else was running on the machine.

```
hyperfine -p 'rm -rf .next' -w 2 -r 20 'TURBOPACK_PERSISTENT_CACHE=1 TURBO_ENGINE_IGNORE_DIRTY=1 pnpm next build --turbopack --experimental-build-mode=compile'
du -sh .next/cache/turbopack/
du -s .next/cache/turbopack/
```

#### Canary

```
Benchmark 1: TURBOPACK_PERSISTENT_CACHE=1 TURBO_ENGINE_IGNORE_DIRTY=1 pnpm next build --turbopack --experimental-build-mode=compile
  Time (mean ± σ):     14.999 s ±  0.258 s    [User: 84.137 s, System: 8.683 s]
  Range (min … max):   14.400 s … 15.509 s    20 runs
```

```
855M    .next/cache/turbopack/
1751640 .next/cache/turbopack/    (Note: macos measures size in 512B blocks)
```

#### This Branch

```
Benchmark 1: TURBOPACK_PERSISTENT_CACHE=1 TURBO_ENGINE_IGNORE_DIRTY=1 pnpm next build --turbopack --experimental-build-mode=compile
  Time (mean ± σ):     14.106 s ±  0.255 s    [User: 79.976 s, System: 8.421 s]
  Range (min … max):   13.829 s … 14.939 s    20 runs
```

```
767M    .next/cache/turbopack/
1571072 .next/cache/turbopack/    (Note: macos measures size in 512B blocks)
```

## vercel-site

Using `~/front/apps/vercel-site` on macos with a M2 Pro. Nothing else was running on the machine.

```
hyperfine -p 'rm -rf .next' -w 2 -r 20 'TURBOPACK_PERSISTENT_CACHE=1 TURBO_ENGINE_IGNORE_DIRTY=1 pnpm next build --turbopack --experimental-build-mode=compile'
du -sh .next/cache/turbopack/
du -s .next/cache/turbopack/
```

#### Canary

```
Benchmark 1: TURBOPACK_PERSISTENT_CACHE=1 TURBO_ENGINE_IGNORE_DIRTY=1 pnpm next build --turbopack --experimental-build-mode=compile
  Time (mean ± σ):     93.274 s ±  1.630 s    [User: 671.120 s, System: 57.888 s]
  Range (min … max):   91.111 s … 96.881 s    10 runs
```

```
4.3G    .next/cache/turbopack/
9002568 .next/cache/turbopack/    (Note: macos measures size in 512B blocks)
```

#### This Branch

```
Benchmark 1: TURBOPACK_PERSISTENT_CACHE=1 TURBO_ENGINE_IGNORE_DIRTY=1 pnpm next build --turbopack --experimental-build-mode=compile
  Time (mean ± σ):     88.694 s ±  0.963 s    [User: 633.801 s, System: 54.576 s]
  Range (min … max):   87.357 s … 90.037 s    10 runs
```

```
3.7G    .next/cache/turbopack/
7788472 .next/cache/turbopack/    (Note: macos measures size in 512B blocks)
```

## shadcn/ui

Using a low-noise Linux machine: https://github.com/bgw/benchmark-scripts/

```
diff --git a/apps/v4/next.config.mjs b/apps/v4/next.config.mjs
index 7fa0f012..d1137d01 100644
--- a/apps/v4/next.config.mjs
+++ b/apps/v4/next.config.mjs
@@ -27,6 +27,7 @@ const nextConfig = {
   },
   experimental: {
     turbopackFileSystemCacheForDev: true,
+    turbopackFileSystemCacheForBuild: true,
   },
   redirects() {
     return [
```

```
cd ~/shadcn-ui/apps/v4
hyperfine -p 'rm -rf .next' -w 2 'pnpm next build --turbopack --experimental-build-mode=compile'
du -sh .next/cache/turbopack/
du -s .next/cache/turbopack/
```

#### Canary

```
Benchmark 1: pnpm next build --turbopack --experimental-build-mode=compile
  Time (mean ± σ):     62.772 s ±  0.939 s    [User: 163.153 s, System: 11.170 s]
  Range (min … max):   60.739 s … 64.220 s    10 runs
```

```
596M    .next/cache/turbopack/
609636  .next/cache/turbopack/    (Note: Linux measures size in 1024B blocks)
```

#### This Branch

```
Benchmark 1: pnpm next build --turbopack --experimental-build-mode=compile
  Time (mean ± σ):     59.017 s ±  1.014 s    [User: 151.359 s, System: 9.978 s]
  Range (min … max):   57.124 s … 60.343 s    10 runs
```

```
491M    .next/cache/turbopack/
502240  .next/cache/turbopack/    (Note: Linux measures size in 1024B blocks)
```
parent 6169e786
...@@ -9238,7 +9238,6 @@ dependencies = [ ...@@ -9238,7 +9238,6 @@ dependencies = [
"turbo-tasks-macros", "turbo-tasks-macros",
"turbo-tasks-malloc", "turbo-tasks-malloc",
"unsize", "unsize",
"unty",
] ]
[[package]] [[package]]
...@@ -9288,6 +9287,7 @@ dependencies = [ ...@@ -9288,6 +9287,7 @@ dependencies = [
"afl", "afl",
"anyhow", "anyhow",
"arbitrary", "arbitrary",
"bincode 2.0.1",
"libfuzzer-sys", "libfuzzer-sys",
"once_cell", "once_cell",
"serde", "serde",
...@@ -9426,6 +9426,7 @@ name = "turbo-tasks-macros-tests" ...@@ -9426,6 +9426,7 @@ name = "turbo-tasks-macros-tests"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bincode 2.0.1",
"serde", "serde",
"tokio", "tokio",
"trybuild", "trybuild",
...@@ -9566,6 +9567,7 @@ name = "turbopack-cli" ...@@ -9566,6 +9567,7 @@ name = "turbopack-cli"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bincode 2.0.1",
"clap", "clap",
"codspeed-criterion-compat", "codspeed-criterion-compat",
"console-subscriber", "console-subscriber",
......
...@@ -123,6 +123,8 @@ fn pick_route(entrypoints: OperationVc<Entrypoints>, key: RcStr, route: &Route) ...@@ -123,6 +123,8 @@ fn pick_route(entrypoints: OperationVc<Entrypoints>, key: RcStr, route: &Route)
ValueDebugFormat, ValueDebugFormat,
NonLocalValue, NonLocalValue,
OperationValue, OperationValue,
Encode,
Decode,
)] )]
enum EndpointSelector { enum EndpointSelector {
RoutePageHtml(RcStr), RoutePageHtml(RcStr),
......
...@@ -612,7 +612,18 @@ enum PageEndpointType { ...@@ -612,7 +612,18 @@ enum PageEndpointType {
} }
#[derive( #[derive(
Copy, Clone, Serialize, Deserialize, PartialEq, Eq, Hash, Debug, TaskInput, TraceRawVcs, Copy,
Clone,
Serialize,
Deserialize,
PartialEq,
Eq,
Hash,
Debug,
TaskInput,
TraceRawVcs,
Encode,
Decode,
)] )]
enum SsrChunkType { enum SsrChunkType {
Page, Page,
...@@ -621,7 +632,18 @@ enum SsrChunkType { ...@@ -621,7 +632,18 @@ enum SsrChunkType {
} }
#[derive( #[derive(
Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize, TaskInput, TraceRawVcs, Copy,
Clone,
Debug,
PartialEq,
Eq,
Hash,
Serialize,
Deserialize,
TaskInput,
TraceRawVcs,
Encode,
Decode,
)] )]
enum EmitManifests { enum EmitManifests {
/// Don't emit any manifests /// Don't emit any manifests
......
...@@ -209,10 +209,6 @@ pub struct ProjectOptions { ...@@ -209,10 +209,6 @@ pub struct ProjectOptions {
pub current_node_js_version: RcStr, pub current_node_js_version: RcStr,
} }
#[derive(
Debug, Serialize, Deserialize, Clone, TaskInput, PartialEq, Eq, Hash, TraceRawVcs, NonLocalValue,
)]
#[serde(rename_all = "camelCase")]
pub struct PartialProjectOptions { pub struct PartialProjectOptions {
/// A root path from which all files must be nested under. Trying to access /// A root path from which all files must be nested under. Trying to access
/// a file outside this root will fail. Think of this as a chroot. /// a file outside this root will fail. Think of this as a chroot.
......
use std::collections::BTreeSet; use std::collections::BTreeSet;
use anyhow::Result; use anyhow::Result;
use bincode::{Decode, Encode};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use turbo_rcstr::{RcStr, rcstr}; use turbo_rcstr::{RcStr, rcstr};
use turbo_tasks::{ResolvedVc, TaskInput, Vc, trace::TraceRawVcs}; use turbo_tasks::{ResolvedVc, TaskInput, Vc, trace::TraceRawVcs};
...@@ -32,11 +33,13 @@ use turbopack_node::{ ...@@ -32,11 +33,13 @@ use turbopack_node::{
}; };
use turbopack_resolve::resolve_options_context::ResolveOptionsContext; use turbopack_resolve::resolve_options_context::ResolveOptionsContext;
use super::transforms::get_next_client_transforms_rules;
use crate::{ use crate::{
mode::NextMode, mode::NextMode,
next_build::get_postcss_package_mapping, next_build::get_postcss_package_mapping,
next_client::runtime_entry::{RuntimeEntries, RuntimeEntry}, next_client::{
runtime_entry::{RuntimeEntries, RuntimeEntry},
transforms::get_next_client_transforms_rules,
},
next_config::NextConfig, next_config::NextConfig,
next_font::local::NextFontLocalResolvePlugin, next_font::local::NextFontLocalResolvePlugin,
next_import_map::{ next_import_map::{
...@@ -405,7 +408,19 @@ pub async fn get_client_module_options_context( ...@@ -405,7 +408,19 @@ pub async fn get_client_module_options_context(
Ok(module_options_context) Ok(module_options_context)
} }
#[derive(Clone, Debug, PartialEq, Eq, Hash, TaskInput, TraceRawVcs, Serialize, Deserialize)] #[derive(
Clone,
Debug,
PartialEq,
Eq,
Hash,
TaskInput,
TraceRawVcs,
Serialize,
Deserialize,
Encode,
Decode,
)]
pub struct ClientChunkingContextOptions { pub struct ClientChunkingContextOptions {
pub mode: Vc<NextMode>, pub mode: Vc<NextMode>,
pub root_path: FileSystemPath, pub root_path: FileSystemPath,
......
use anyhow::Result; use anyhow::Result;
use bincode::{Decode, Encode};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use turbo_rcstr::{RcStr, rcstr}; use turbo_rcstr::{RcStr, rcstr};
use turbo_tasks::{ResolvedVc, TaskInput, Vc, trace::TraceRawVcs}; use turbo_tasks::{ResolvedVc, TaskInput, Vc, trace::TraceRawVcs};
...@@ -196,7 +197,19 @@ pub async fn get_edge_resolve_options_context( ...@@ -196,7 +197,19 @@ pub async fn get_edge_resolve_options_context(
.cell()) .cell())
} }
#[derive(Clone, Debug, PartialEq, Eq, Hash, TaskInput, TraceRawVcs, Serialize, Deserialize)] #[derive(
Clone,
Debug,
PartialEq,
Eq,
Hash,
TaskInput,
TraceRawVcs,
Serialize,
Deserialize,
Encode,
Decode,
)]
pub struct EdgeChunkingContextOptions { pub struct EdgeChunkingContextOptions {
pub mode: Vc<NextMode>, pub mode: Vc<NextMode>,
pub root_path: FileSystemPath, pub root_path: FileSystemPath,
......
...@@ -5,7 +5,7 @@ use either::Either; ...@@ -5,7 +5,7 @@ use either::Either;
use indoc::formatdoc; use indoc::formatdoc;
use itertools::Itertools; use itertools::Itertools;
use turbo_rcstr::RcStr; use turbo_rcstr::RcStr;
use turbo_tasks::{ResolvedVc, Vc}; use turbo_tasks::{EitherTaskInput, ResolvedVc, Vc};
use turbo_tasks_fs::{FileContent, FileSystemPath}; use turbo_tasks_fs::{FileContent, FileSystemPath};
use turbopack_core::{ use turbopack_core::{
asset::AssetContent, asset::AssetContent,
...@@ -36,9 +36,13 @@ pub async fn insert_next_root_params_mapping( ...@@ -36,9 +36,13 @@ pub async fn insert_next_root_params_mapping(
) -> Result<()> { ) -> Result<()> {
import_map.insert_exact_alias( import_map.insert_exact_alias(
"next/root-params", "next/root-params",
get_next_root_params_mapping(is_root_params_enabled, ty, collected_root_params) get_next_root_params_mapping(
.to_resolved() is_root_params_enabled,
.await?, EitherTaskInput(ty),
collected_root_params,
)
.to_resolved()
.await?,
); );
Ok(()) Ok(())
} }
...@@ -46,7 +50,7 @@ pub async fn insert_next_root_params_mapping( ...@@ -46,7 +50,7 @@ pub async fn insert_next_root_params_mapping(
#[turbo_tasks::function] #[turbo_tasks::function]
async fn get_next_root_params_mapping( async fn get_next_root_params_mapping(
is_root_params_enabled: Vc<bool>, is_root_params_enabled: Vc<bool>,
ty: Either<ServerContextType, ClientContextType>, ty: EitherTaskInput<ServerContextType, ClientContextType>,
collected_root_params: Option<Vc<CollectedRootParams>>, collected_root_params: Option<Vc<CollectedRootParams>>,
) -> Result<Vc<ImportMapping>> { ) -> Result<Vc<ImportMapping>> {
// This mapping goes into the global resolve options, so we want to avoid invalidating it if // This mapping goes into the global resolve options, so we want to avoid invalidating it if
...@@ -77,12 +81,12 @@ impl NextRootParamsMapper { ...@@ -77,12 +81,12 @@ impl NextRootParamsMapper {
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn new( pub fn new(
is_root_params_enabled: ResolvedVc<bool>, is_root_params_enabled: ResolvedVc<bool>,
context_type: Either<ServerContextType, ClientContextType>, context_type: EitherTaskInput<ServerContextType, ClientContextType>,
collected_root_params: Option<ResolvedVc<CollectedRootParams>>, collected_root_params: Option<ResolvedVc<CollectedRootParams>>,
) -> Vc<Self> { ) -> Vc<Self> {
NextRootParamsMapper { NextRootParamsMapper {
is_root_params_enabled, is_root_params_enabled,
context_type, context_type: context_type.0,
collected_root_params, collected_root_params,
} }
.cell() .cell()
......
use std::collections::BTreeSet; use std::collections::BTreeSet;
use anyhow::{Result, bail}; use anyhow::{Result, bail};
use bincode::{Decode, Encode};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use turbo_rcstr::{RcStr, rcstr}; use turbo_rcstr::{RcStr, rcstr};
use turbo_tasks::{ResolvedVc, TaskInput, Vc, trace::TraceRawVcs}; use turbo_tasks::{ResolvedVc, TaskInput, Vc, trace::TraceRawVcs};
...@@ -38,10 +39,6 @@ use turbopack_node::{ ...@@ -38,10 +39,6 @@ use turbopack_node::{
use turbopack_nodejs::NodeJsChunkingContext; use turbopack_nodejs::NodeJsChunkingContext;
use turbopack_resolve::resolve_options_context::ResolveOptionsContext; use turbopack_resolve::resolve_options_context::ResolveOptionsContext;
use super::{
resolve::ExternalCjsModulesResolvePlugin,
transforms::{get_next_server_internal_transforms_rules, get_next_server_transforms_rules},
};
use crate::{ use crate::{
app_structure::CollectedRootParams, app_structure::CollectedRootParams,
mode::NextMode, mode::NextMode,
...@@ -49,7 +46,10 @@ use crate::{ ...@@ -49,7 +46,10 @@ use crate::{
next_config::NextConfig, next_config::NextConfig,
next_font::local::NextFontLocalResolvePlugin, next_font::local::NextFontLocalResolvePlugin,
next_import_map::{get_next_edge_and_server_fallback_import_map, get_next_server_import_map}, next_import_map::{get_next_edge_and_server_fallback_import_map, get_next_server_import_map},
next_server::resolve::ExternalPredicate, next_server::{
resolve::{ExternalCjsModulesResolvePlugin, ExternalPredicate},
transforms::{get_next_server_internal_transforms_rules, get_next_server_transforms_rules},
},
next_shared::{ next_shared::{
resolve::{ resolve::{
ModuleFeatureReportResolvePlugin, NextExternalResolvePlugin, ModuleFeatureReportResolvePlugin, NextExternalResolvePlugin,
...@@ -981,7 +981,19 @@ pub async fn get_server_module_options_context( ...@@ -981,7 +981,19 @@ pub async fn get_server_module_options_context(
Ok(module_options_context) Ok(module_options_context)
} }
#[derive(Clone, Debug, PartialEq, Eq, Hash, TaskInput, TraceRawVcs, Serialize, Deserialize)] #[derive(
Clone,
Debug,
PartialEq,
Eq,
Hash,
TaskInput,
TraceRawVcs,
Serialize,
Deserialize,
Encode,
Decode,
)]
pub struct ServerChunkingContextOptions { pub struct ServerChunkingContextOptions {
pub mode: Vc<NextMode>, pub mode: Vc<NextMode>,
pub root_path: FileSystemPath, pub root_path: FileSystemPath,
......
...@@ -59,7 +59,18 @@ pub fn defines(define_env: &FxIndexMap<RcStr, Option<RcStr>>) -> CompileTimeDefi ...@@ -59,7 +59,18 @@ pub fn defines(define_env: &FxIndexMap<RcStr, Option<RcStr>>) -> CompileTimeDefi
} }
#[derive( #[derive(
Debug, Clone, Copy, PartialEq, Eq, Hash, TaskInput, Serialize, Deserialize, TraceRawVcs, Debug,
Clone,
Copy,
PartialEq,
Eq,
Hash,
TaskInput,
Serialize,
Deserialize,
TraceRawVcs,
Encode,
Decode,
)] )]
pub enum PathType { pub enum PathType {
PagesPage, PagesPage,
......
#[doc(hidden)] #[doc(hidden)]
pub mod macro_helpers; pub mod macro_helpers;
use std::ptr::copy_nonoverlapping; use std::{any::Any, ptr::copy_nonoverlapping};
use ::smallvec::SmallVec; use ::smallvec::SmallVec;
use bincode::{ use bincode::{
...@@ -17,6 +17,8 @@ pub type TurboBincodeEncoder<'a> = ...@@ -17,6 +17,8 @@ pub type TurboBincodeEncoder<'a> =
EncoderImpl<TurboBincodeWriter<'a>, bincode::config::Configuration>; EncoderImpl<TurboBincodeWriter<'a>, bincode::config::Configuration>;
pub type TurboBincodeDecoder<'a> = pub type TurboBincodeDecoder<'a> =
DecoderImpl<TurboBincodeReader<'a>, bincode::config::Configuration, ()>; DecoderImpl<TurboBincodeReader<'a>, bincode::config::Configuration, ()>;
pub type AnyEncodeFn = fn(&dyn Any, &mut TurboBincodeEncoder<'_>) -> Result<(), EncodeError>;
pub type AnyDecodeFn<T> = fn(&mut TurboBincodeDecoder<'_>) -> Result<T, DecodeError>;
fn new_turbo_bincode_encoder(buf: &mut TurboBincodeBuffer) -> TurboBincodeEncoder<'_> { fn new_turbo_bincode_encoder(buf: &mut TurboBincodeBuffer) -> TurboBincodeEncoder<'_> {
EncoderImpl::new(TurboBincodeWriter::new(buf), TURBO_BINCODE_CONFIG) EncoderImpl::new(TurboBincodeWriter::new(buf), TURBO_BINCODE_CONFIG)
......
...@@ -11,6 +11,7 @@ cargo-fuzz = true ...@@ -11,6 +11,7 @@ cargo-fuzz = true
afl = "0.15.18" afl = "0.15.18"
anyhow = { workspace = true } anyhow = { workspace = true }
arbitrary = { version = "1.4.1", features = ["derive"] } arbitrary = { version = "1.4.1", features = ["derive"] }
bincode = { workspace = true }
libfuzzer-sys = "0.4.9" libfuzzer-sys = "0.4.9"
once_cell = { workspace = true } once_cell = { workspace = true }
serde = { workspace = true } serde = { workspace = true }
......
...@@ -2,6 +2,7 @@ use std::sync::Arc; ...@@ -2,6 +2,7 @@ use std::sync::Arc;
use anyhow::Result; use anyhow::Result;
use arbitrary::Arbitrary; use arbitrary::Arbitrary;
use bincode::{Decode, Encode};
use once_cell::sync::Lazy; use once_cell::sync::Lazy;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use turbo_tasks::{self, NonLocalValue, State, TaskInput, TurboTasks, Vc, trace::TraceRawVcs}; use turbo_tasks::{self, NonLocalValue, State, TaskInput, TurboTasks, Vc, trace::TraceRawVcs};
...@@ -19,6 +20,8 @@ use turbo_tasks_malloc::TurboMalloc; ...@@ -19,6 +20,8 @@ use turbo_tasks_malloc::TurboMalloc;
Deserialize, Deserialize,
TraceRawVcs, TraceRawVcs,
TaskInput, TaskInput,
Encode,
Decode,
)] )]
pub struct TaskReferenceSpec { pub struct TaskReferenceSpec {
task: u16, task: u16,
...@@ -39,6 +42,8 @@ pub struct TaskReferenceSpec { ...@@ -39,6 +42,8 @@ pub struct TaskReferenceSpec {
Deserialize, Deserialize,
TraceRawVcs, TraceRawVcs,
TaskInput, TaskInput,
Encode,
Decode,
)] )]
pub struct TaskSpec { pub struct TaskSpec {
references: Vec<TaskReferenceSpec>, references: Vec<TaskReferenceSpec>,
......
...@@ -604,17 +604,6 @@ fn encode_task_type( ...@@ -604,17 +604,6 @@ fn encode_task_type(
buffer: &mut TurboBincodeBuffer, buffer: &mut TurboBincodeBuffer,
task_id: Option<TaskId>, task_id: Option<TaskId>,
) -> Result<()> { ) -> Result<()> {
// DO NOT REMOVE THE `inline(never)` ATTRIBUTE!
// CachedTaskType's `Encode`/`Decode` implementations use `pot` internally for `TaskInput`s.
// TODO: remove `serde` and `pot`, make `TaskInput: Encode + Decode`.
//
// `pot` uses the pointer address of `&'static str` to deduplicate Symbols.
// If this function is inlined into multiple different callsites it might inline the Serialize
// implementation too, which can pull a `&'static str` from another crate into this crate.
// Since string deduplication between crates is not guaranteed, it can lead to behavior changes
// due to the pointer addresses. This can lead to lookup path and store path creating different
// serialization of the same task type, which breaks task cache lookups.
#[inline(never)]
fn encode_once_into( fn encode_once_into(
task_type: &CachedTaskType, task_type: &CachedTaskType,
buffer: &mut TurboBincodeBuffer, buffer: &mut TurboBincodeBuffer,
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
#![feature(arbitrary_self_types_pointers)] #![feature(arbitrary_self_types_pointers)]
use anyhow::Result; use anyhow::Result;
use serde::{Deserialize, Serialize}; use bincode::{Decode, Encode};
use turbo_tasks::{NonLocalValue, ResolvedVc, TaskInput, Vc, trace::TraceRawVcs}; use turbo_tasks::{NonLocalValue, ResolvedVc, TaskInput, Vc, trace::TraceRawVcs};
use turbo_tasks_testing::{Registration, register, run_once_without_cache_check}; use turbo_tasks_testing::{Registration, register, run_once_without_cache_check};
...@@ -62,9 +62,7 @@ async fn read_incorrect_task_input_operation(value: IncorrectTaskInput) -> Resul ...@@ -62,9 +62,7 @@ async fn read_incorrect_task_input_operation(value: IncorrectTaskInput) -> Resul
/// Has an intentionally incorrect `TaskInput` implementation, representing some code that the debug /// Has an intentionally incorrect `TaskInput` implementation, representing some code that the debug
/// tracing might be particularly useful with. /// tracing might be particularly useful with.
#[derive( #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, TraceRawVcs, Encode, Decode, NonLocalValue)]
Copy, Clone, Debug, PartialEq, Eq, Hash, TraceRawVcs, Serialize, Deserialize, NonLocalValue,
)]
struct IncorrectTaskInput(ResolvedVc<u64>); struct IncorrectTaskInput(ResolvedVc<u64>);
impl TaskInput for IncorrectTaskInput { impl TaskInput for IncorrectTaskInput {
......
#![feature(arbitrary_self_types)] #![feature(arbitrary_self_types)]
#![feature(arbitrary_self_types_pointers)] #![feature(arbitrary_self_types_pointers)]
use serde::{Deserialize, Serialize}; use bincode::{Decode, Encode};
use turbo_tasks::{NonLocalValue, ResolvedVc, TaskInput, trace::TraceRawVcs}; use turbo_tasks::{NonLocalValue, ResolvedVc, TaskInput, trace::TraceRawVcs};
use turbo_tasks_testing::{Registration, register, run_once_without_cache_check}; use turbo_tasks_testing::{Registration, register, run_once_without_cache_check};
...@@ -30,9 +30,7 @@ fn emit_incorrect_task_input_operation(value: IncorrectTaskInput) { ...@@ -30,9 +30,7 @@ fn emit_incorrect_task_input_operation(value: IncorrectTaskInput) {
} }
/// Has an intentionally incorrect `TaskInput` implementation /// Has an intentionally incorrect `TaskInput` implementation
#[derive( #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, TraceRawVcs, Encode, Decode, NonLocalValue)]
Copy, Clone, Debug, PartialEq, Eq, Hash, TraceRawVcs, Serialize, Deserialize, NonLocalValue,
)]
struct IncorrectTaskInput(ResolvedVc<U32Wrapper>); struct IncorrectTaskInput(ResolvedVc<U32Wrapper>);
impl TaskInput for IncorrectTaskInput { impl TaskInput for IncorrectTaskInput {
......
...@@ -7,6 +7,7 @@ edition = "2024" ...@@ -7,6 +7,7 @@ edition = "2024"
[dev-dependencies] [dev-dependencies]
anyhow = { workspace = true } anyhow = { workspace = true }
bincode = { workspace = true }
serde = { workspace = true } serde = { workspace = true }
tokio = { workspace = true } tokio = { workspace = true }
trybuild = { version = "1.0.104" } trybuild = { version = "1.0.104" }
......
...@@ -3,13 +3,13 @@ ...@@ -3,13 +3,13 @@
//! macro and the `#[turbo_tasks::function]` macro. //! macro and the `#[turbo_tasks::function]` macro.
#![allow(clippy::needless_return)] // tokio macro-generated code doesn't respect this #![allow(clippy::needless_return)] // tokio macro-generated code doesn't respect this
use serde::{Deserialize, Serialize}; use bincode::{Decode, Encode};
use turbo_tasks::{Completion, ReadRef, TaskInput, Vc, trace::TraceRawVcs}; use turbo_tasks::{Completion, ReadRef, TaskInput, Vc, trace::TraceRawVcs};
use turbo_tasks_testing::{Registration, register, run_once}; use turbo_tasks_testing::{Registration, register, run_once};
static REGISTRATION: Registration = register!(); static REGISTRATION: Registration = register!();
#[derive(Clone, TaskInput, Debug, PartialEq, Eq, Hash, Serialize, Deserialize, TraceRawVcs)] #[derive(Clone, TaskInput, Debug, PartialEq, Eq, Hash, Encode, Decode, TraceRawVcs)]
struct OneUnnamedField(u32); struct OneUnnamedField(u32);
#[turbo_tasks::function] #[turbo_tasks::function]
......
...@@ -56,7 +56,6 @@ turbo-tasks-hash = { workspace = true } ...@@ -56,7 +56,6 @@ turbo-tasks-hash = { workspace = true }
turbo-tasks-macros = { workspace = true } turbo-tasks-macros = { workspace = true }
turbo-tasks-malloc = { workspace = true } turbo-tasks-malloc = { workspace = true }
unsize = { workspace = true } unsize = { workspace = true }
unty = { workspace = true }
pot = "3.0.0" pot = "3.0.0"
[dev-dependencies] [dev-dependencies]
......
...@@ -13,10 +13,14 @@ use auto_hash_map::AutoMap; ...@@ -13,10 +13,14 @@ use auto_hash_map::AutoMap;
use bincode::{ use bincode::{
Decode, Encode, Decode, Encode,
error::{DecodeError, EncodeError}, error::{DecodeError, EncodeError},
impl_borrow_decode,
}; };
use rustc_hash::FxHasher; use rustc_hash::FxHasher;
use tracing::Span; use tracing::Span;
use turbo_bincode::{TurboBincodeDecoder, TurboBincodeEncoder}; use turbo_bincode::{
TurboBincodeDecode, TurboBincodeDecoder, TurboBincodeEncode, TurboBincodeEncoder,
impl_decode_for_turbo_bincode_decode, impl_encode_for_turbo_bincode_encode,
};
use turbo_rcstr::RcStr; use turbo_rcstr::RcStr;
use crate::{ use crate::{
...@@ -77,6 +81,38 @@ impl CachedTaskType { ...@@ -77,6 +81,38 @@ impl CachedTaskType {
} }
} }
impl TurboBincodeEncode for CachedTaskType {
fn encode(&self, encoder: &mut TurboBincodeEncoder) -> Result<(), EncodeError> {
Encode::encode(&registry::get_function_id(self.native_fn), encoder)?;
let (encode_arg_any, _) = self.native_fn.arg_meta.bincode;
Encode::encode(&self.this, encoder)?;
encode_arg_any(&*self.arg, encoder)?;
Ok(())
}
}
impl<Context> TurboBincodeDecode<Context> for CachedTaskType {
fn decode(decoder: &mut TurboBincodeDecoder) -> Result<Self, DecodeError> {
let native_fn = registry::get_native_function(Decode::decode(decoder)?);
let (_, decode_arg_any) = native_fn.arg_meta.bincode;
let this = Decode::decode(decoder)?;
let arg = decode_arg_any(decoder)?;
Ok(Self {
native_fn,
this,
arg,
})
}
}
impl_encode_for_turbo_bincode_encode!(CachedTaskType);
impl_decode_for_turbo_bincode_decode!(CachedTaskType);
impl_borrow_decode!(CachedTaskType);
// Manual implementation is needed because of a borrow issue with `Box<dyn Trait>`: // Manual implementation is needed because of a borrow issue with `Box<dyn Trait>`:
// https://github.com/rust-lang/rust/issues/31740 // https://github.com/rust-lang/rust/issues/31740
impl PartialEq for CachedTaskType { impl PartialEq for CachedTaskType {
...@@ -102,126 +138,6 @@ impl Display for CachedTaskType { ...@@ -102,126 +138,6 @@ impl Display for CachedTaskType {
} }
} }
mod ser {
use bincode::{
de::{Decoder, read::Reader},
enc::Encoder,
};
use serde::{Deserialize, Deserializer, Serialize, Serializer, ser::SerializeSeq};
use super::*;
const POT_CONFIG: pot::Config = pot::Config::new().compatibility(pot::Compatibility::V4);
struct FunctionAndArgBorrowed<'a> {
native_fn: &'static NativeFunction,
arg: &'a dyn MagicAny,
}
struct FunctionAndArgOwned {
native_fn: &'static NativeFunction,
arg: Box<dyn MagicAny>,
}
impl Serialize for FunctionAndArgBorrowed<'_> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
let Self { native_fn, arg } = self;
let mut state = serializer.serialize_seq(Some(2))?;
state.serialize_element(&registry::get_function_id(native_fn))?;
let arg = *arg;
let arg = native_fn.arg_meta.as_serialize(arg);
state.serialize_element(arg)?;
state.end()
}
}
impl<'de> Deserialize<'de> for FunctionAndArgOwned {
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
struct Visitor;
impl<'de> serde::de::Visitor<'de> for Visitor {
type Value = FunctionAndArgOwned;
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
write!(formatter, "a valid FunctionAndArgOwned")
}
fn visit_seq<A>(self, mut seq: A) -> Result<Self::Value, A::Error>
where
A: serde::de::SeqAccess<'de>,
{
let fn_id = seq
.next_element()?
.ok_or_else(|| serde::de::Error::invalid_length(0, &self))?;
let native_fn = registry::get_native_function(fn_id);
let seed = native_fn.arg_meta.deserialization_seed();
let arg = seq
.next_element_seed(seed)?
.ok_or_else(|| serde::de::Error::invalid_length(1, &self))?;
Ok(FunctionAndArgOwned { native_fn, arg })
}
}
deserializer.deserialize_seq(Visitor)
}
}
// HACK: We don't yet require `TaskInput: Encode + Decode`, so use a pot serializer for the
// function arguments, and bincode for everything else.
impl Encode for CachedTaskType {
fn encode<E: Encoder>(&self, encoder: &mut E) -> Result<(), EncodeError> {
struct BincodeWriterWrapper<W: bincode::enc::write::Writer>(W);
impl<W: bincode::enc::write::Writer> std::io::Write for BincodeWriterWrapper<W> {
fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> {
self.write_all(buf)?;
Ok(buf.len())
}
fn write_all(&mut self, buf: &[u8]) -> std::io::Result<()> {
self.0.write(buf).map_err(std::io::Error::other)
}
fn flush(&mut self) -> std::io::Result<()> {
Ok(())
}
}
let function_and_arg = FunctionAndArgBorrowed {
native_fn: self.native_fn,
arg: &*self.arg,
};
POT_CONFIG
.serialize_into(
&function_and_arg,
&mut BincodeWriterWrapper(encoder.writer()),
)
.map_err(|e| EncodeError::OtherString(e.to_string()))?;
Encode::encode(&self.this, encoder)
}
}
impl<Context> Decode<Context> for CachedTaskType {
fn decode<D: Decoder<Context = Context>>(decoder: &mut D) -> Result<Self, DecodeError> {
struct BincodeReaderWrapper<R: Reader>(R);
impl<R: Reader> std::io::Read for BincodeReaderWrapper<R> {
fn read(&mut self, buf: &mut [u8]) -> std::io::Result<usize> {
self.read_exact(buf)?;
Ok(buf.len())
}
fn read_exact(&mut self, buf: &mut [u8]) -> std::io::Result<()> {
self.0.read(buf).map_err(std::io::Error::other)
}
}
let FunctionAndArgOwned { native_fn, arg } = POT_CONFIG
.deserialize_from(BincodeReaderWrapper(decoder.reader()))
.map_err(|e| DecodeError::OtherString(e.to_string()))?;
let this: Option<RawVc> = Decode::decode(decoder)?;
Ok(CachedTaskType {
native_fn,
this,
arg,
})
}
}
}
pub struct TaskExecutionSpec<'a> { pub struct TaskExecutionSpec<'a> {
pub future: Pin<Box<dyn Future<Output = Result<RawVc>> + Send + 'a>>, pub future: Pin<Box<dyn Future<Output = Result<RawVc>> + Send + 'a>>,
pub span: Span, pub span: Span,
......
...@@ -91,46 +91,51 @@ use std::hash::BuildHasherDefault; ...@@ -91,46 +91,51 @@ use std::hash::BuildHasherDefault;
pub use anyhow::{Error, Result}; pub use anyhow::{Error, Result};
use auto_hash_map::AutoSet; use auto_hash_map::AutoSet;
pub use capture_future::TurboTasksPanic;
pub use collectibles::CollectiblesSource;
pub use completion::{Completion, Completions};
pub use display::ValueToString;
pub use effect::{ApplyEffectsContext, Effects, apply_effects, effect, get_effects};
pub use id::{ExecutionId, LocalTaskId, TRANSIENT_TASK_BIT, TaskId, TraitTypeId, ValueTypeId};
pub use invalidation::{
InvalidationReason, InvalidationReasonKind, InvalidationReasonSet, Invalidator, get_invalidator,
};
pub use join_iter_ext::{JoinIterExt, TryFlatJoinIterExt, TryJoinIterExt};
pub use key_value_pair::KeyValuePair;
pub use magic_any::MagicAny;
pub use manager::{
CurrentCellRef, ReadConsistency, ReadTracking, TaskPersistence, TurboTasks, TurboTasksApi,
TurboTasksBackendApi, TurboTasksCallApi, Unused, UpdateInfo, dynamic_call, emit, mark_finished,
mark_root, mark_session_dependent, mark_stateful, prevent_gc, run, run_once,
run_once_with_reason, trait_call, turbo_tasks, turbo_tasks_scope,
};
pub use output::OutputContent;
pub use raw_vc::{CellId, RawVc, ReadRawVcFuture, ResolveTypeError};
pub use read_options::{ReadCellOptions, ReadOutputOptions};
pub use read_ref::ReadRef;
use rustc_hash::FxHasher; use rustc_hash::FxHasher;
pub use serialization_invalidation::SerializationInvalidator;
pub use shrink_to_fit::ShrinkToFit; pub use shrink_to_fit::ShrinkToFit;
pub use spawn::{
JoinHandle, block_for_future, block_in_place, spawn, spawn_blocking, spawn_thread,
};
pub use state::{State, TransientState};
pub use task::{SharedReference, TypedSharedReference, task_input::TaskInput};
pub use task_execution_reason::TaskExecutionReason;
pub use trait_ref::{IntoTraitRef, TraitRef};
pub use turbo_tasks_macros::{TaskInput, function, value_impl}; pub use turbo_tasks_macros::{TaskInput, function, value_impl};
pub use value::{TransientInstance, TransientValue};
pub use value_type::{TraitMethod, TraitType, ValueType}; pub use crate::{
pub use vc::{ capture_future::TurboTasksPanic,
Dynamic, NonLocalValue, OperationValue, OperationVc, OptionVcExt, ReadVcFuture, ResolvedVc, collectibles::CollectiblesSource,
Upcast, UpcastStrict, ValueDefault, Vc, VcCast, VcCellCompareMode, VcCellNewMode, completion::{Completion, Completions},
VcDefaultRead, VcRead, VcTransparentRead, VcValueTrait, VcValueTraitCast, VcValueType, display::ValueToString,
VcValueTypeCast, effect::{ApplyEffectsContext, Effects, apply_effects, effect, get_effects},
id::{ExecutionId, LocalTaskId, TRANSIENT_TASK_BIT, TaskId, TraitTypeId, ValueTypeId},
invalidation::{
InvalidationReason, InvalidationReasonKind, InvalidationReasonSet, Invalidator,
get_invalidator,
},
join_iter_ext::{JoinIterExt, TryFlatJoinIterExt, TryJoinIterExt},
key_value_pair::KeyValuePair,
magic_any::MagicAny,
manager::{
CurrentCellRef, ReadConsistency, ReadTracking, TaskPersistence, TurboTasks, TurboTasksApi,
TurboTasksBackendApi, TurboTasksCallApi, Unused, UpdateInfo, dynamic_call, emit,
mark_finished, mark_root, mark_session_dependent, mark_stateful, prevent_gc, run, run_once,
run_once_with_reason, trait_call, turbo_tasks, turbo_tasks_scope,
},
output::OutputContent,
raw_vc::{CellId, RawVc, ReadRawVcFuture, ResolveTypeError},
read_options::{ReadCellOptions, ReadOutputOptions},
read_ref::ReadRef,
serialization_invalidation::SerializationInvalidator,
spawn::{JoinHandle, block_for_future, block_in_place, spawn, spawn_blocking, spawn_thread},
state::{State, TransientState},
task::{
SharedReference, TypedSharedReference,
task_input::{EitherTaskInput, TaskInput},
},
task_execution_reason::TaskExecutionReason,
trait_ref::{IntoTraitRef, TraitRef},
value::{TransientInstance, TransientValue},
value_type::{TraitMethod, TraitType, ValueType},
vc::{
Dynamic, NonLocalValue, OperationValue, OperationVc, OptionVcExt, ReadVcFuture, ResolvedVc,
Upcast, UpcastStrict, ValueDefault, Vc, VcCast, VcCellCompareMode, VcCellNewMode,
VcDefaultRead, VcRead, VcTransparentRead, VcValueTrait, VcValueTraitCast, VcValueType,
VcValueTypeCast,
},
}; };
pub type SliceMap<K, V> = Box<[(K, V)]>; pub type SliceMap<K, V> = Box<[(K, V)]>;
......
use std::{any::Any, fmt::Debug, hash::Hash}; use std::{
any::{Any, type_name},
fmt::Debug,
hash::Hash,
};
use serde::{Deserialize, Serialize, de::DeserializeSeed};
use turbo_dyn_eq_hash::{ use turbo_dyn_eq_hash::{
DynEq, DynHash, impl_eq_for_dyn, impl_hash_for_dyn, impl_partial_eq_for_dyn, DynEq, DynHash, impl_eq_for_dyn, impl_hash_for_dyn, impl_partial_eq_for_dyn,
}; };
...@@ -26,85 +29,12 @@ impl_partial_eq_for_dyn!(dyn MagicAny); ...@@ -26,85 +29,12 @@ impl_partial_eq_for_dyn!(dyn MagicAny);
impl_eq_for_dyn!(dyn MagicAny); impl_eq_for_dyn!(dyn MagicAny);
impl_hash_for_dyn!(dyn MagicAny); impl_hash_for_dyn!(dyn MagicAny);
impl dyn MagicAny { pub fn any_as_encode<T: Any>(this: &dyn Any) -> &T {
pub fn as_serialize<T: Debug + Eq + Hash + Serialize + Send + Sync + TraceRawVcs + 'static>( if let Some(enc) = this.downcast_ref::<T>() {
&self, return enc;
) -> &dyn erased_serde::Serialize {
if let Some(r) = (self as &dyn Any).downcast_ref::<T>() {
r
} else {
#[cfg(debug_assertions)]
panic!(
"MagicAny::as_serializable broken: got {} but expected {}",
self.magic_type_name(),
std::any::type_name::<T>(),
);
#[cfg(not(debug_assertions))]
panic!("MagicAny::as_serializable bug");
}
}
}
type MagicAnySerializeFunctor = fn(&dyn MagicAny) -> &dyn erased_serde::Serialize;
#[derive(Clone, Copy)]
pub struct MagicAnySerializeSeed {
functor: MagicAnySerializeFunctor,
}
impl MagicAnySerializeSeed {
pub fn new<T: Debug + Eq + Hash + Serialize + Send + Sync + TraceRawVcs + 'static>() -> Self {
fn serialize<T: Debug + Eq + Hash + Serialize + Send + Sync + TraceRawVcs + 'static>(
value: &dyn MagicAny,
) -> &dyn erased_serde::Serialize {
value.as_serialize::<T>()
}
Self {
functor: serialize::<T>,
}
}
pub fn as_serialize<'a>(&self, value: &'a dyn MagicAny) -> &'a dyn erased_serde::Serialize {
(self.functor)(value)
}
}
type MagicAnyDeserializeSeedFunctor =
fn(&mut dyn erased_serde::Deserializer<'_>) -> Result<Box<dyn MagicAny>, erased_serde::Error>;
#[derive(Clone, Copy)]
pub struct MagicAnyDeserializeSeed {
functor: MagicAnyDeserializeSeedFunctor,
}
impl MagicAnyDeserializeSeed {
pub fn new<T>() -> Self
where
T: for<'de> Deserialize<'de> + Debug + Eq + Hash + Send + Sync + TraceRawVcs + 'static,
{
fn deserialize<T>(
deserializer: &mut dyn erased_serde::Deserializer<'_>,
) -> Result<Box<dyn MagicAny>, erased_serde::Error>
where
T: for<'de> Deserialize<'de> + Debug + Eq + Hash + Send + Sync + TraceRawVcs + 'static,
{
let value: T = erased_serde::deserialize(deserializer)?;
Ok(Box::new(value))
}
Self {
functor: deserialize::<T>,
}
}
}
impl<'de> DeserializeSeed<'de> for MagicAnyDeserializeSeed {
type Value = Box<dyn MagicAny>;
fn deserialize<D>(self, deserializer: D) -> Result<Self::Value, D::Error>
where
D: serde::Deserializer<'de>,
{
let mut deserializer = <dyn erased_serde::Deserializer>::erase(deserializer);
(self.functor)(&mut deserializer).map_err(serde::de::Error::custom)
} }
unreachable!(
"any_as_encode::<{}> called with invalid type",
type_name::<T>()
);
} }
use std::{any::Any, fmt::Debug, hash::Hash, pin::Pin}; use std::{any::Any, fmt::Debug, hash::Hash, pin::Pin};
use anyhow::Result; use anyhow::Result;
use bincode::{Decode, Encode};
use futures::Future; use futures::Future;
use once_cell::sync::Lazy; use once_cell::sync::Lazy;
use serde::{Deserialize, Serialize};
use tracing::Span; use tracing::Span;
use turbo_bincode::{AnyDecodeFn, AnyEncodeFn};
use crate::{ use crate::{
RawVc, TaskExecutionReason, TaskInput, TaskPersistence, RawVc, TaskExecutionReason, TaskInput, TaskPersistence,
magic_any::{MagicAny, MagicAnyDeserializeSeed, MagicAnySerializeSeed}, magic_any::{MagicAny, any_as_encode},
task::{ task::{
IntoTaskFn, TaskFn, IntoTaskFn, TaskFn,
function::{IntoTaskFnWithThis, NativeTaskFuture}, function::{IntoTaskFnWithThis, NativeTaskFuture},
...@@ -24,8 +25,8 @@ type FilterOwnedArgsFunctor = for<'a> fn(Box<dyn MagicAny>) -> Box<dyn MagicAny> ...@@ -24,8 +25,8 @@ type FilterOwnedArgsFunctor = for<'a> fn(Box<dyn MagicAny>) -> Box<dyn MagicAny>
type FilterAndResolveFunctor = ResolveFunctor; type FilterAndResolveFunctor = ResolveFunctor;
pub struct ArgMeta { pub struct ArgMeta {
serializer: MagicAnySerializeSeed, // TODO: This should be an `Option` with `None` for transient tasks. We can skip some codegen.
deserializer: MagicAnyDeserializeSeed, pub bincode: (AnyEncodeFn, AnyDecodeFn<Box<dyn MagicAny>>),
is_resolved: IsResolvedFunctor, is_resolved: IsResolvedFunctor,
resolve: ResolveFunctor, resolve: ResolveFunctor,
/// Used for trait methods, filters out unused arguments. /// Used for trait methods, filters out unused arguments.
...@@ -43,7 +44,7 @@ pub struct ArgMeta { ...@@ -43,7 +44,7 @@ pub struct ArgMeta {
impl ArgMeta { impl ArgMeta {
pub fn new<T>() -> Self pub fn new<T>() -> Self
where where
T: TaskInput + Serialize + for<'de> Deserialize<'de> + 'static, T: TaskInput + Encode + Decode<()> + 'static,
{ {
fn noop_filter_args(args: Box<dyn MagicAny>) -> Box<dyn MagicAny> { fn noop_filter_args(args: Box<dyn MagicAny>) -> Box<dyn MagicAny> {
args args
...@@ -56,11 +57,19 @@ impl ArgMeta { ...@@ -56,11 +57,19 @@ impl ArgMeta {
filter_and_resolve: FilterAndResolveFunctor, filter_and_resolve: FilterAndResolveFunctor,
) -> Self ) -> Self
where where
T: TaskInput + Serialize + for<'de> Deserialize<'de> + 'static, T: TaskInput + Encode + Decode<()> + 'static,
{ {
Self { Self {
serializer: MagicAnySerializeSeed::new::<T>(), bincode: (
deserializer: MagicAnyDeserializeSeed::new::<T>(), |this, enc| {
T::encode(any_as_encode::<T>(this), enc)?;
Ok(())
},
|dec| {
let val = T::decode(dec)?;
Ok(Box::new(val))
},
),
is_resolved: |value| downcast_args_ref::<T>(value).is_resolved(), is_resolved: |value| downcast_args_ref::<T>(value).is_resolved(),
resolve: resolve_functor_impl::<T>, resolve: resolve_functor_impl::<T>,
filter_owned, filter_owned,
...@@ -68,14 +77,6 @@ impl ArgMeta { ...@@ -68,14 +77,6 @@ impl ArgMeta {
} }
} }
pub fn deserialization_seed(&self) -> MagicAnyDeserializeSeed {
self.deserializer
}
pub fn as_serialize<'a>(&self, value: &'a dyn MagicAny) -> &'a dyn erased_serde::Serialize {
self.serializer.as_serialize(value)
}
pub fn is_resolved(&self, value: &dyn MagicAny) -> bool { pub fn is_resolved(&self, value: &dyn MagicAny) -> bool {
(self.is_resolved)(value) (self.is_resolved)(value)
} }
...@@ -174,7 +175,7 @@ impl NativeFunction { ...@@ -174,7 +175,7 @@ impl NativeFunction {
implementation: impl IntoTaskFn<Mode, Inputs>, implementation: impl IntoTaskFn<Mode, Inputs>,
) -> Self ) -> Self
where where
Inputs: TaskInput + Serialize + for<'de> Deserialize<'de> + 'static, Inputs: TaskInput + Encode + Decode<()> + 'static,
{ {
Self { Self {
name, name,
...@@ -191,7 +192,7 @@ impl NativeFunction { ...@@ -191,7 +192,7 @@ impl NativeFunction {
implementation: I, implementation: I,
) -> Self ) -> Self
where where
Inputs: TaskInput + Serialize + for<'de> Deserialize<'de> + 'static, Inputs: TaskInput + Encode + Decode<()> + 'static,
I: IntoTaskFn<Mode, Inputs>, I: IntoTaskFn<Mode, Inputs>,
{ {
Self { Self {
...@@ -214,7 +215,7 @@ impl NativeFunction { ...@@ -214,7 +215,7 @@ impl NativeFunction {
) -> Self ) -> Self
where where
This: Sync + Send + 'static, This: Sync + Send + 'static,
Inputs: TaskInput + Serialize + for<'de> Deserialize<'de> + 'static, Inputs: TaskInput + Encode + Decode<()> + 'static,
I: IntoTaskFnWithThis<Mode, This, Inputs>, I: IntoTaskFnWithThis<Mode, This, Inputs>,
{ {
Self { Self {
......
...@@ -8,13 +8,12 @@ use std::{ ...@@ -8,13 +8,12 @@ use std::{
use anyhow::Result; use anyhow::Result;
use bincode::{ use bincode::{
Decode, Encode, Decode, Encode,
de::Decoder,
enc::Encoder,
error::{DecodeError, EncodeError}, error::{DecodeError, EncodeError},
impl_borrow_decode, impl_borrow_decode,
}; };
use turbo_bincode::{ use turbo_bincode::{
TurboBincodeDecoder, TurboBincodeEncoder, turbo_bincode_decode, turbo_bincode_encode, TurboBincodeDecode, TurboBincodeDecoder, TurboBincodeEncode, TurboBincodeEncoder,
impl_decode_for_turbo_bincode_decode, impl_encode_for_turbo_bincode_encode,
}; };
use unsize::CoerceUnsize; use unsize::CoerceUnsize;
...@@ -64,99 +63,44 @@ impl TypedSharedReference { ...@@ -64,99 +63,44 @@ impl TypedSharedReference {
pub fn into_untyped(self) -> SharedReference { pub fn into_untyped(self) -> SharedReference {
self.reference self.reference
} }
}
fn encode(&self, enc: &mut TurboBincodeEncoder) -> Result<(), EncodeError> { impl TurboBincodeEncode for TypedSharedReference {
fn encode(&self, encoder: &mut TurboBincodeEncoder) -> Result<(), EncodeError> {
let Self { type_id, reference } = self; let Self { type_id, reference } = self;
let value_type = registry::get_value_type(*type_id); let value_type = registry::get_value_type(*type_id);
if let Some(bincode) = value_type.bincode { if let Some(bincode) = value_type.bincode {
type_id.encode(enc)?; type_id.encode(encoder)?;
bincode.0(&*reference.0, enc)?; bincode.0(&*reference.0, encoder)?;
Ok(()) Ok(())
} else { } else {
Err(EncodeError::OtherString(format!( Err(EncodeError::OtherString(format!(
"{:?} is not serializable", "{} is not encodable",
value_type.global_name value_type.global_name
))) )))
} }
} }
}
fn decode(dec: &mut TurboBincodeDecoder) -> Result<Self, DecodeError> { impl<Context> TurboBincodeDecode<Context> for TypedSharedReference {
let type_id = ValueTypeId::decode(dec)?; fn decode(decoder: &mut TurboBincodeDecoder) -> Result<Self, DecodeError> {
let type_id = ValueTypeId::decode(decoder)?;
let value_type = registry::get_value_type(type_id); let value_type = registry::get_value_type(type_id);
if let Some(bincode) = value_type.bincode { if let Some(bincode) = value_type.bincode {
let reference = bincode.1(dec)?; let reference = bincode.1(decoder)?;
Ok(Self { type_id, reference }) Ok(Self { type_id, reference })
} else { } else {
#[cold] #[cold]
fn not_deserializable(value_type: &ValueType) -> DecodeError { fn not_decodable(value_type: &ValueType) -> DecodeError {
DecodeError::OtherString(format!("{value_type} is not deserializable")) DecodeError::OtherString(format!("{} is not decodable", value_type.global_name))
}
Err(not_deserializable(value_type))
}
}
}
impl Encode for TypedSharedReference {
fn encode<'a, E: Encoder>(&self, encoder: &'a mut E) -> Result<(), EncodeError> {
let maybe_turbo_encoder = if unty::type_equal::<E, TurboBincodeEncoder>() {
// SAFETY: Transmute is safe because `&mut E` is `&mut TurboBincodeEncoder`:
// - `unty::type_equal::<E, TurboBincodeEncoder>()` does not check lifetimes, but does
// check the type and layout, so we know those are correct.
// - The transmuted encoder cannot escape this function, and we know that the lifetime
// of `'f` is at least as long as the function.
// - Lifetimes don't change layout. This is not guaranteed, but if this assumption is
// broken, we'd have a different type id, `type_equal` would return `false` and we'd
// fall back to a slower codepath, and wouldn't violate memory safety.
// - Two mutable references have the same layout and alignment when they reference
// exactly the same type.
// - The explicit lifetime ('a) avoids creating an implitly unbounded lifetime.
Ok(unsafe { std::mem::transmute::<&'a mut E, &'a mut TurboBincodeEncoder>(encoder) })
} else {
Err(encoder)
};
match maybe_turbo_encoder {
Ok(turbo_encoder) => TypedSharedReference::encode(self, turbo_encoder),
Err(generic_encoder) => {
// The underlying `SharedReference` can only be serialized using
// `TurboBincodeEncoder` because the encoder function pointer cannot take type
// parameters. This is okay, because we expect any hot codepaths to use
// `TurboBincodeEncoder`.
//
// Create a `TurboBincodeEncoder` and encode this as a nested byte array. We must
// redundantly store a size here, otherwise we won't be able to determine what size
// buffer to use for `TurboBincodeReader`.
let buffer = turbo_bincode_encode(self)?;
buffer.encode(generic_encoder)
}
}
}
}
impl<Context> Decode<Context> for TypedSharedReference {
fn decode<'a, D: Decoder<Context = Context>>(decoder: &mut D) -> Result<Self, DecodeError> {
let maybe_turbo_decoder = if unty::type_equal::<D, TurboBincodeDecoder>() {
// SAFETY: See notes on the `Encode::encode` implementation above.
Ok(unsafe { std::mem::transmute::<&mut D, &mut TurboBincodeDecoder<'a>>(decoder) })
} else {
Err(decoder)
};
match maybe_turbo_decoder {
Ok(turbo_decoder) => TypedSharedReference::decode(turbo_decoder),
Err(generic_decoder) => {
// The underlying `SharedReference` can only be deserialized using
// `TurboBincodeDecoder` because the decoder function pointer cannot take type
// parameters. This is okay, because we expect any hot codepaths to use
// `TurboBincodeDecoder`.
//
// Decode the nested byte array that was created during encoding, then use a
// `TurboBincodeDecoder` to decode the contents.
let buffer: Vec<u8> = Decode::decode(generic_decoder)?;
turbo_bincode_decode(&buffer)
} }
Err(not_decodable(value_type))
} }
} }
} }
impl_encode_for_turbo_bincode_encode!(TypedSharedReference);
impl_decode_for_turbo_bincode_decode!(TypedSharedReference);
impl_borrow_decode!(TypedSharedReference); impl_borrow_decode!(TypedSharedReference);
impl Deref for TypedSharedReference { impl Deref for TypedSharedReference {
......
use std::{ use std::{
any::{Any, type_name},
fmt::{self, Debug, Display, Formatter}, fmt::{self, Debug, Display, Formatter},
hash::Hash, hash::Hash,
}; };
use auto_hash_map::{AutoMap, AutoSet}; use auto_hash_map::{AutoMap, AutoSet};
use bincode::{ use bincode::{Decode, Encode};
Decode, Encode,
error::{DecodeError, EncodeError},
};
use tracing::Span; use tracing::Span;
use turbo_bincode::{TurboBincodeDecoder, TurboBincodeEncoder}; use turbo_bincode::{AnyDecodeFn, AnyEncodeFn};
use crate::{ use crate::{
RawVc, SharedReference, VcValueType, id::TraitTypeId, macro_helpers::NativeFunction, registry, RawVc, SharedReference, VcValueType, id::TraitTypeId, macro_helpers::NativeFunction,
task::shared_reference::TypedSharedReference, vc::VcCellMode, magic_any::any_as_encode, registry, task::shared_reference::TypedSharedReference,
vc::VcCellMode,
}; };
type RawCellFactoryFn = fn(TypedSharedReference) -> RawVc; type RawCellFactoryFn = fn(TypedSharedReference) -> RawVc;
type AnyEncodeFn = fn(&dyn Any, &mut TurboBincodeEncoder<'_>) -> Result<(), EncodeError>;
type AnyDecodeFn = fn(&mut TurboBincodeDecoder<'_>) -> Result<SharedReference, DecodeError>;
// TODO this type need some refactoring when multiple languages are added to // TODO this type need some refactoring when multiple languages are added to
// turbo-task In this case a trait_method might be of a different function type. // turbo-task In this case a trait_method might be of a different function type.
// It probably need to be a Vc<Function>. // It probably need to be a Vc<Function>.
...@@ -42,7 +36,7 @@ pub struct ValueType { ...@@ -42,7 +36,7 @@ pub struct ValueType {
trait_methods: AutoMap<&'static TraitMethod, &'static NativeFunction>, trait_methods: AutoMap<&'static TraitMethod, &'static NativeFunction>,
/// Functions to convert to write the type to a buffer or read it from a buffer. /// Functions to convert to write the type to a buffer or read it from a buffer.
pub bincode: Option<(AnyEncodeFn, AnyDecodeFn)>, pub bincode: Option<(AnyEncodeFn, AnyDecodeFn<SharedReference>)>,
/// An implementation of /// An implementation of
/// [`VcCellMode::raw_cell`][crate::vc::VcCellMode::raw_cell]. /// [`VcCellMode::raw_cell`][crate::vc::VcCellMode::raw_cell].
...@@ -91,16 +85,6 @@ impl Display for ValueType { ...@@ -91,16 +85,6 @@ impl Display for ValueType {
} }
} }
pub fn any_as_encode<T: Any>(this: &dyn Any) -> &T {
if let Some(enc) = this.downcast_ref::<T>() {
return enc;
}
unreachable!(
"any_as_encode::<{}> called with invalid type",
type_name::<T>()
);
}
pub trait ManualEncodeWrapper: Encode { pub trait ManualEncodeWrapper: Encode {
type Value; type Value;
...@@ -171,7 +155,7 @@ impl ValueType { ...@@ -171,7 +155,7 @@ impl ValueType {
// Helper for other constructor functions // Helper for other constructor functions
fn new_inner<T: VcValueType>( fn new_inner<T: VcValueType>(
global_name: &'static str, global_name: &'static str,
bincode: Option<(AnyEncodeFn, AnyDecodeFn)>, bincode: Option<(AnyEncodeFn, AnyDecodeFn<SharedReference>)>,
) -> Self { ) -> Self {
Self { Self {
name: std::any::type_name::<T>(), name: std::any::type_name::<T>(),
......
...@@ -38,6 +38,7 @@ workspace = true ...@@ -38,6 +38,7 @@ workspace = true
[dependencies] [dependencies]
anyhow = { workspace = true } anyhow = { workspace = true }
bincode = { workspace = true }
clap = { workspace = true, features = ["derive", "env"] } clap = { workspace = true, features = ["derive", "env"] }
console-subscriber = { workspace = true, optional = true } console-subscriber = { workspace = true, optional = true }
dunce = { workspace = true } dunce = { workspace = true }
......
...@@ -5,6 +5,7 @@ use std::{ ...@@ -5,6 +5,7 @@ use std::{
}; };
use anyhow::anyhow; use anyhow::anyhow;
use bincode::{Decode, Encode};
use clap::{Args, Parser, ValueEnum}; use clap::{Args, Parser, ValueEnum};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use turbo_tasks::{NonLocalValue, TaskInput, trace::TraceRawVcs}; use turbo_tasks::{NonLocalValue, TaskInput, trace::TraceRawVcs};
...@@ -48,6 +49,8 @@ impl Arguments { ...@@ -48,6 +49,8 @@ impl Arguments {
TaskInput, TaskInput,
NonLocalValue, NonLocalValue,
TraceRawVcs, TraceRawVcs,
Encode,
Decode,
)] )]
pub enum Target { pub enum Target {
Browser, Browser,
......
use std::{env::current_dir, path::PathBuf}; use std::{env::current_dir, path::PathBuf};
use anyhow::{Context, Result}; use anyhow::{Context, Result};
use bincode::{Decode, Encode};
use dunce::canonicalize; use dunce::canonicalize;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use turbo_rcstr::{RcStr, rcstr}; use turbo_rcstr::{RcStr, rcstr};
...@@ -8,7 +9,18 @@ use turbo_tasks::{NonLocalValue, TaskInput, Vc, trace::TraceRawVcs}; ...@@ -8,7 +9,18 @@ use turbo_tasks::{NonLocalValue, TaskInput, Vc, trace::TraceRawVcs};
use turbo_tasks_fs::{DiskFileSystem, FileSystem}; use turbo_tasks_fs::{DiskFileSystem, FileSystem};
#[derive( #[derive(
Clone, Debug, TaskInput, Hash, PartialEq, Eq, NonLocalValue, Serialize, Deserialize, TraceRawVcs, Clone,
Debug,
TaskInput,
Hash,
PartialEq,
Eq,
NonLocalValue,
Serialize,
Deserialize,
TraceRawVcs,
Encode,
Decode,
)] )]
pub enum EntryRequest { pub enum EntryRequest {
Relative(RcStr), Relative(RcStr),
......
use std::cmp::Reverse; use std::cmp::Reverse;
use anyhow::Result; use anyhow::Result;
use bincode::{Decode, Encode};
use indexmap::map::Entry; use indexmap::map::Entry;
use rustc_hash::{FxHashMap, FxHashSet}; use rustc_hash::{FxHashMap, FxHashSet};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
...@@ -23,7 +24,18 @@ use crate::{ ...@@ -23,7 +24,18 @@ use crate::{
}; };
#[derive( #[derive(
TaskInput, Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, NonLocalValue, TraceRawVcs, TaskInput,
Debug,
Clone,
PartialEq,
Eq,
Hash,
Serialize,
Deserialize,
NonLocalValue,
TraceRawVcs,
Encode,
Decode,
)] )]
pub struct StyleGroupsConfig { pub struct StyleGroupsConfig {
pub max_chunk_size: usize, pub max_chunk_size: usize,
......
use std::{collections::BTreeMap, hash::Hash, mem::replace, ops::DerefMut}; use std::{collections::BTreeMap, hash::Hash, mem::replace, ops::DerefMut};
use bincode::{Decode, Encode};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use turbo_tasks::{NonLocalValue, TaskInput, trace::TraceRawVcs}; use turbo_tasks::{NonLocalValue, TaskInput, trace::TraceRawVcs};
...@@ -16,6 +17,8 @@ use turbo_tasks::{NonLocalValue, TaskInput, trace::TraceRawVcs}; ...@@ -16,6 +17,8 @@ use turbo_tasks::{NonLocalValue, TaskInput, trace::TraceRawVcs};
Deserialize, Deserialize,
NonLocalValue, NonLocalValue,
TaskInput, TaskInput,
Encode,
Decode,
)] )]
#[serde(transparent)] #[serde(transparent)]
pub struct Headers(BTreeMap<String, HeaderValue>); pub struct Headers(BTreeMap<String, HeaderValue>);
...@@ -23,7 +26,18 @@ pub struct Headers(BTreeMap<String, HeaderValue>); ...@@ -23,7 +26,18 @@ pub struct Headers(BTreeMap<String, HeaderValue>);
/// The value of an http header. HTTP headers might contain non-utf-8 bytes. An /// The value of an http header. HTTP headers might contain non-utf-8 bytes. An
/// header might also occur multiple times. /// header might also occur multiple times.
#[derive( #[derive(
Clone, Debug, PartialEq, Eq, Hash, TraceRawVcs, Serialize, Deserialize, NonLocalValue, TaskInput, Clone,
Debug,
PartialEq,
Eq,
Hash,
TraceRawVcs,
Serialize,
Deserialize,
NonLocalValue,
TaskInput,
Encode,
Decode,
)] )]
#[serde(untagged)] #[serde(untagged)]
pub enum HeaderValue { pub enum HeaderValue {
......
...@@ -28,7 +28,7 @@ use turbo_tasks_fs::FileSystemPath; ...@@ -28,7 +28,7 @@ use turbo_tasks_fs::FileSystemPath;
use turbo_tasks_hash::{DeterministicHash, DeterministicHasher, Xxh3Hash64Hasher}; use turbo_tasks_hash::{DeterministicHash, DeterministicHasher, Xxh3Hash64Hasher};
use turbopack_core::version::{Version, VersionedContent}; use turbopack_core::version::{Version, VersionedContent};
use self::{ use crate::source::{
headers::Headers, issue_context::IssueFilePathContentSource, query::Query, headers::Headers, issue_context::IssueFilePathContentSource, query::Query,
route_tree::RouteTree, route_tree::RouteTree,
}; };
...@@ -192,6 +192,8 @@ impl HeaderList { ...@@ -192,6 +192,8 @@ impl HeaderList {
Hash, Hash,
Default, Default,
TaskInput, TaskInput,
Encode,
Decode,
)] )]
pub struct ContentSourceData { pub struct ContentSourceData {
/// HTTP method, if requested. /// HTTP method, if requested.
......
use std::{collections::BTreeMap, hash::Hash, ops::DerefMut}; use std::{collections::BTreeMap, hash::Hash, ops::DerefMut};
use bincode::{Decode, Encode};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use turbo_tasks::{NonLocalValue, TaskInput, trace::TraceRawVcs}; use turbo_tasks::{NonLocalValue, TaskInput, trace::TraceRawVcs};
use super::ContentSourceDataFilter; use crate::source::ContentSourceDataFilter;
/// A parsed query string from a http request /// A parsed query string from a http request
#[derive( #[derive(
Clone, Debug, PartialEq, Eq, Default, Hash, TraceRawVcs, Serialize, Deserialize, NonLocalValue, Clone,
Debug,
PartialEq,
Eq,
Default,
Hash,
TraceRawVcs,
Serialize,
Deserialize,
NonLocalValue,
Encode,
Decode,
)] )]
#[serde(transparent)] #[serde(transparent)]
pub struct Query(BTreeMap<String, QueryValue>); pub struct Query(BTreeMap<String, QueryValue>);
...@@ -44,7 +56,19 @@ impl DerefMut for Query { ...@@ -44,7 +56,19 @@ impl DerefMut for Query {
} }
} }
#[derive(Clone, Debug, PartialEq, Eq, Hash, TraceRawVcs, Serialize, Deserialize, NonLocalValue)] #[derive(
Clone,
Debug,
PartialEq,
Eq,
Hash,
TraceRawVcs,
Serialize,
Deserialize,
NonLocalValue,
Encode,
Decode,
)]
#[serde(untagged)] #[serde(untagged)]
pub enum QueryValue { pub enum QueryValue {
/// Simple string value, might be an empty string when there is no value /// Simple string value, might be an empty string when there is no value
......
...@@ -14,7 +14,18 @@ use crate::source::{GetContentSourceContent, GetContentSourceContents}; ...@@ -14,7 +14,18 @@ use crate::source::{GetContentSourceContent, GetContentSourceContents};
/// The type of the route. This will decide about the remaining segments of the /// The type of the route. This will decide about the remaining segments of the
/// route after the base. /// route after the base.
#[derive( #[derive(
TaskInput, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize, TraceRawVcs, NonLocalValue, TaskInput,
Clone,
Debug,
PartialEq,
Eq,
Hash,
Serialize,
Deserialize,
TraceRawVcs,
NonLocalValue,
Encode,
Decode,
)] )]
pub enum RouteType { pub enum RouteType {
Exact, Exact,
......
...@@ -109,6 +109,8 @@ pub(crate) enum PatternMapping { ...@@ -109,6 +109,8 @@ pub(crate) enum PatternMapping {
TraceRawVcs, TraceRawVcs,
TaskInput, TaskInput,
NonLocalValue, NonLocalValue,
Encode,
Decode,
)] )]
pub(crate) enum ResolveType { pub(crate) enum ResolveType {
AsyncChunkLoader, AsyncChunkLoader,
......
use std::{borrow::Cow, iter, sync::Arc, thread::available_parallelism, time::Duration}; use std::{borrow::Cow, iter, sync::Arc, thread::available_parallelism, time::Duration};
use anyhow::{Result, bail}; use anyhow::{Result, bail};
use bincode::{Decode, Encode};
use futures_retry::{FutureRetry, RetryPolicy}; use futures_retry::{FutureRetry, RetryPolicy};
use serde::{Deserialize, Serialize, de::DeserializeOwned}; use serde::{Deserialize, Serialize, de::DeserializeOwned};
use serde_json::Value as JsonValue; use serde_json::Value as JsonValue;
...@@ -143,6 +144,8 @@ async fn emit_evaluate_pool_assets_with_effects_operation( ...@@ -143,6 +144,8 @@ async fn emit_evaluate_pool_assets_with_effects_operation(
TaskInput, TaskInput,
NonLocalValue, NonLocalValue,
TraceRawVcs, TraceRawVcs,
Encode,
Decode,
)] )]
pub enum EnvVarTracking { pub enum EnvVarTracking {
WholeEnvTracked, WholeEnvTracked,
...@@ -509,7 +512,6 @@ async fn pull_operation<T: EvaluateContext>( ...@@ -509,7 +512,6 @@ async fn pull_operation<T: EvaluateContext>(
} }
} }
#[derive(Clone, PartialEq, Eq, Hash, TaskInput, Debug, Serialize, Deserialize, TraceRawVcs)]
struct BasicEvaluateContext { struct BasicEvaluateContext {
entries: ResolvedVc<EvaluateEntries>, entries: ResolvedVc<EvaluateEntries>,
cwd: FileSystemPath, cwd: FileSystemPath,
......
...@@ -395,7 +395,19 @@ pub enum InfoMessage { ...@@ -395,7 +395,19 @@ pub enum InfoMessage {
}, },
} }
#[derive(Debug, Clone, TaskInput, Hash, PartialEq, Eq, Serialize, Deserialize, TraceRawVcs)] #[derive(
Debug,
Clone,
TaskInput,
Hash,
PartialEq,
Eq,
Serialize,
Deserialize,
TraceRawVcs,
Encode,
Decode,
)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct WebpackResolveOptions { pub struct WebpackResolveOptions {
alias_fields: Option<Vec<RcStr>>, alias_fields: Option<Vec<RcStr>>,
...@@ -430,7 +442,19 @@ pub enum ResponseMessage { ...@@ -430,7 +442,19 @@ pub enum ResponseMessage {
TrackFileRead {}, TrackFileRead {},
} }
#[derive(Clone, PartialEq, Eq, Hash, TaskInput, Serialize, Deserialize, Debug, TraceRawVcs)] #[derive(
Clone,
PartialEq,
Eq,
Hash,
TaskInput,
Serialize,
Deserialize,
Debug,
TraceRawVcs,
Encode,
Decode,
)]
pub struct WebpackLoaderContext { pub struct WebpackLoaderContext {
pub entries: ResolvedVc<EvaluateEntries>, pub entries: ResolvedVc<EvaluateEntries>,
pub cwd: FileSystemPath, pub cwd: FileSystemPath,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment