Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf(turbopack): Use ResolvedVc for turbopack-core #73065

Merged
merged 134 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from 87 commits
Commits
Show all changes
134 commits
Select commit Hold shift + click to select a range
22541ff
resolvedvc
kdy1 Nov 21, 2024
51e9c5b
resolvedvc
kdy1 Nov 21, 2024
78b0d1b
resolvedvc
kdy1 Nov 21, 2024
42989bf
resolvedvc
kdy1 Nov 21, 2024
2734e48
resolvedvc
kdy1 Nov 21, 2024
f6e3259
resolvedvc
kdy1 Nov 21, 2024
e7ee558
resolvedvc
kdy1 Nov 21, 2024
0aac743
resolvedvc
kdy1 Nov 21, 2024
92dd2f7
resolvedvc
kdy1 Nov 21, 2024
352b6d2
resolvedvc
kdy1 Nov 21, 2024
dbc603b
resolvedvc
kdy1 Nov 21, 2024
2a581f5
resolvedvc
kdy1 Nov 21, 2024
94446fc
resolvedvc
kdy1 Nov 21, 2024
a1d1565
resolvedvc
kdy1 Nov 21, 2024
05b7979
Fix more
kdy1 Nov 21, 2024
e4b173a
Fix more
kdy1 Nov 21, 2024
0739165
Fix more
kdy1 Nov 21, 2024
ce1f05e
Fix more
kdy1 Nov 21, 2024
9f35866
fix more
kdy1 Nov 25, 2024
2471b9b
fix more
kdy1 Nov 25, 2024
01aedb4
fix more
kdy1 Nov 25, 2024
29c0745
fix more
kdy1 Nov 25, 2024
04cdd3d
fix more
kdy1 Nov 25, 2024
6de7769
Go back to Vc
kdy1 Nov 25, 2024
fe5d92b
fix more
kdy1 Nov 25, 2024
2a1bc5d
fix more
kdy1 Nov 25, 2024
15d9c6a
fix more
kdy1 Nov 25, 2024
3d30ad8
fix more
kdy1 Nov 25, 2024
02936c3
fix more
kdy1 Nov 25, 2024
ca1bfcb
fix more
kdy1 Nov 25, 2024
68285d6
fix more
kdy1 Nov 25, 2024
8d1c44d
fix more
kdy1 Nov 25, 2024
21dbe8e
change sig
kdy1 Nov 25, 2024
d700316
fix more
kdy1 Nov 25, 2024
17af8ac
fix more
kdy1 Nov 25, 2024
5a9db40
fix more
kdy1 Nov 25, 2024
9cbd995
fix more
kdy1 Nov 25, 2024
08c5614
fix more
kdy1 Nov 25, 2024
8fc74c3
fix more
kdy1 Nov 25, 2024
35b606e
fix more
kdy1 Nov 25, 2024
fd0230a
fix more
kdy1 Nov 25, 2024
caabbd8
fix more
kdy1 Nov 25, 2024
4524eaf
fix more
kdy1 Nov 25, 2024
6b83e52
fix more
kdy1 Nov 25, 2024
7512cbb
fix more
kdy1 Nov 25, 2024
b71314e
fix more
kdy1 Nov 25, 2024
4da260a
fix more
kdy1 Nov 25, 2024
08993fc
fix more
kdy1 Nov 25, 2024
f4a1325
fix more
kdy1 Nov 25, 2024
42c79b2
ResolvedVc
kdy1 Nov 25, 2024
08939a6
fix more
kdy1 Nov 25, 2024
7bf7bef
fix more
kdy1 Nov 25, 2024
8351fd3
fix more
kdy1 Nov 25, 2024
ca72c00
fix more
kdy1 Nov 25, 2024
aa32389
fix more
kdy1 Nov 25, 2024
47a129f
fix more
kdy1 Nov 25, 2024
f8a3b01
fix more
kdy1 Nov 25, 2024
28d2160
fix more
kdy1 Nov 25, 2024
5cd5533
fix more
kdy1 Nov 25, 2024
2eb1775
fix more
kdy1 Nov 25, 2024
e2786dd
fix more
kdy1 Nov 25, 2024
28c6969
fix more
kdy1 Nov 25, 2024
4c5461f
Change sig
kdy1 Nov 25, 2024
2288d84
Change sig
kdy1 Nov 25, 2024
f716c5c
fixup
kdy1 Nov 25, 2024
3b6c240
fixup
kdy1 Nov 25, 2024
2cf6270
fixup
kdy1 Nov 25, 2024
004b315
fix more
kdy1 Nov 25, 2024
fb59f34
fix more
kdy1 Nov 25, 2024
78fbe15
fix more
kdy1 Nov 25, 2024
52f1fe2
fix more
kdy1 Nov 25, 2024
5edf744
fix more
kdy1 Nov 25, 2024
91c5b62
fix more
kdy1 Nov 25, 2024
96f7ac0
fix more
kdy1 Nov 25, 2024
53a4ec8
fix more
kdy1 Nov 25, 2024
dae28d4
fix more
kdy1 Nov 25, 2024
d03eb5c
fix more
kdy1 Nov 25, 2024
b876273
Dep
kdy1 Nov 25, 2024
8fe87b3
cargo lockfile
kdy1 Nov 25, 2024
eda57cc
fix more
kdy1 Nov 25, 2024
d2db9dc
fix more
kdy1 Nov 25, 2024
8469dc9
Revert
kdy1 Nov 25, 2024
63a6fe6
fix more
kdy1 Nov 25, 2024
b942cb6
fix more
kdy1 Nov 25, 2024
5e31d00
fix more
kdy1 Nov 25, 2024
ace1972
fix more
kdy1 Nov 25, 2024
1079f27
fix more
kdy1 Nov 25, 2024
1c9478d
Fix
kdy1 Nov 25, 2024
bfa62fa
Fix
kdy1 Nov 25, 2024
be3b6f6
Fix
kdy1 Nov 25, 2024
088b415
Fix
kdy1 Nov 25, 2024
3ee4eae
More ResolvedVc
kdy1 Nov 25, 2024
0e3b046
Fix more
kdy1 Nov 25, 2024
0f3d224
Fix more
kdy1 Nov 25, 2024
589b352
Fix more
kdy1 Nov 25, 2024
6a518c6
Fix more
kdy1 Nov 25, 2024
6fb98ba
Fix more
kdy1 Nov 25, 2024
3821ecc
Fix more
kdy1 Nov 25, 2024
141961d
Fix more
kdy1 Nov 25, 2024
e50db54
Fix more
kdy1 Nov 25, 2024
6ec9c8b
Fix more
kdy1 Nov 25, 2024
4c282d4
Fix more
kdy1 Nov 25, 2024
18c16ed
Fix more
kdy1 Nov 25, 2024
816f8e8
Fix more
kdy1 Nov 25, 2024
318aa91
Fix more
kdy1 Nov 25, 2024
1b51439
Fix more
kdy1 Nov 25, 2024
cb6a2c5
Fix more
kdy1 Nov 25, 2024
77563ad
Fix more
kdy1 Nov 25, 2024
fc28bfe
Fix more
kdy1 Nov 25, 2024
c583f89
Fix more
kdy1 Nov 25, 2024
4636a41
Fix more
kdy1 Nov 25, 2024
a97957a
Fix more
kdy1 Nov 25, 2024
9942a17
Fix more
kdy1 Nov 25, 2024
be6429a
Fix more
kdy1 Nov 25, 2024
633499d
Fix more
kdy1 Nov 25, 2024
96ed075
Fix more
kdy1 Nov 25, 2024
f7585de
Fix more
kdy1 Nov 25, 2024
b3f43f5
Fix more
kdy1 Nov 25, 2024
67d5961
Fix more
kdy1 Nov 25, 2024
b864703
Fix more
kdy1 Nov 25, 2024
5a21e1f
Fix more
kdy1 Nov 25, 2024
0a15be9
Fix more
kdy1 Nov 25, 2024
1337848
Fix more
kdy1 Nov 25, 2024
3abd69d
Fix more
kdy1 Nov 25, 2024
93f22bc
Fix more
kdy1 Nov 25, 2024
83b1c74
Fix more
kdy1 Nov 25, 2024
6662cdd
Fix more
kdy1 Nov 25, 2024
887eb15
Fix more
kdy1 Nov 25, 2024
03ec694
Drop async_recursion
kdy1 Nov 25, 2024
a90f265
cargo lockfile
kdy1 Nov 25, 2024
0c15726
Box::pin
kdy1 Nov 25, 2024
9e0dd31
Merge branch 'canary' into kdy1/resolved-vc-turbopack
kdy1 Nov 25, 2024
7e55f21
lint
kdy1 Nov 25, 2024
c67f45f
impl Default for NodeJsEnvironment
kdy1 Nov 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions turbopack/crates/turbopack-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ workspace = true

[dependencies]
anyhow = { workspace = true }
async-recursion = "1.1.1"
kdy1 marked this conversation as resolved.
Show resolved Hide resolved
async-trait = { workspace = true }
auto-hash-map = { workspace = true }
browserslist-rs = { workspace = true }
Expand Down
10 changes: 5 additions & 5 deletions turbopack/crates/turbopack-core/src/chunk/availability_info.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use anyhow::Result;
use turbo_tasks::Vc;
use turbo_tasks::{ResolvedVc, Vc};

use super::available_chunk_items::{AvailableChunkItemInfoMap, AvailableChunkItems};

Expand All @@ -12,7 +12,7 @@ pub enum AvailabilityInfo {
Root,
/// There are modules already available.
Complete {
available_chunk_items: Vc<AvailableChunkItems>,
available_chunk_items: ResolvedVc<AvailableChunkItems>,
},
}

Expand All @@ -24,7 +24,7 @@ impl AvailabilityInfo {
Self::Complete {
available_chunk_items,
..
} => Some(*available_chunk_items),
} => Some(**available_chunk_items),
}
}

Expand All @@ -35,14 +35,14 @@ impl AvailabilityInfo {
Ok(match self {
AvailabilityInfo::Untracked => AvailabilityInfo::Untracked,
AvailabilityInfo::Root => AvailabilityInfo::Complete {
available_chunk_items: AvailableChunkItems::new(chunk_items).resolve().await?,
available_chunk_items: AvailableChunkItems::new(chunk_items).to_resolved().await?,
},
AvailabilityInfo::Complete {
available_chunk_items,
} => AvailabilityInfo::Complete {
available_chunk_items: available_chunk_items
.with_chunk_items(chunk_items)
.resolve()
.to_resolved()
.await?,
},
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ pub struct AvailableChunkItemInfoMap(
#[turbo_tasks::value]
pub struct AvailableChunkItems {
parent: Option<ResolvedVc<AvailableChunkItems>>,
chunk_items: Vc<AvailableChunkItemInfoMap>,
chunk_items: ResolvedVc<AvailableChunkItemInfoMap>,
}

#[turbo_tasks::value_impl]
impl AvailableChunkItems {
#[turbo_tasks::function]
pub fn new(chunk_items: Vc<AvailableChunkItemInfoMap>) -> Vc<Self> {
pub fn new(chunk_items: ResolvedVc<AvailableChunkItemInfoMap>) -> Vc<Self> {
AvailableChunkItems {
parent: None,
chunk_items,
Expand All @@ -44,7 +44,7 @@ impl AvailableChunkItems {
#[turbo_tasks::function]
pub async fn with_chunk_items(
self: ResolvedVc<Self>,
chunk_items: Vc<AvailableChunkItemInfoMap>,
chunk_items: ResolvedVc<AvailableChunkItemInfoMap>,
) -> Result<Vc<Self>> {
let chunk_items = chunk_items
.await?
Expand All @@ -60,7 +60,7 @@ impl AvailableChunkItems {
.await?;
Ok(AvailableChunkItems {
parent: Some(self),
chunk_items: Vc::cell(chunk_items.into_iter().collect()),
chunk_items: ResolvedVc::cell(chunk_items.into_iter().collect()),
}
.cell())
}
Expand Down
10 changes: 5 additions & 5 deletions turbopack/crates/turbopack-core/src/chunk/data.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use anyhow::Result;
use turbo_rcstr::RcStr;
use turbo_tasks::{ReadRef, TryJoinIterExt, Vc};
use turbo_tasks::{ReadRef, ResolvedVc, TryJoinIterExt, Vc};
use turbo_tasks_fs::FileSystemPath;

use crate::{
Expand All @@ -14,7 +14,7 @@ pub struct ChunkData {
pub included: Vec<ReadRef<ModuleId>>,
pub excluded: Vec<ReadRef<ModuleId>>,
pub module_chunks: Vec<String>,
pub references: Vc<OutputAssets>,
pub references: ResolvedVc<OutputAssets>,
}

#[turbo_tasks::value(transparent)]
Expand Down Expand Up @@ -57,7 +57,7 @@ impl ChunkData {
included: Vec::new(),
excluded: Vec::new(),
module_chunks: Vec::new(),
references: OutputAssets::empty(),
references: OutputAssets::empty().to_resolved().await?,
}
.cell(),
)));
Expand Down Expand Up @@ -112,7 +112,7 @@ impl ChunkData {
included,
excluded,
module_chunks,
references: Vc::cell(module_chunks_references),
references: ResolvedVc::cell(module_chunks_references),
}
.cell(),
)))
Expand All @@ -139,6 +139,6 @@ impl ChunkData {
/// Returns [`OutputAsset`]s that this chunk data references.
#[turbo_tasks::function]
pub fn references(&self) -> Vc<OutputAssets> {
self.references
*self.references
}
}
56 changes: 32 additions & 24 deletions turbopack/crates/turbopack-core/src/compile_time_info.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use anyhow::Result;
use turbo_rcstr::RcStr;
use turbo_tasks::{FxIndexMap, ResolvedVc, Vc};
use turbo_tasks_fs::FileSystemPath;
Expand Down Expand Up @@ -267,13 +268,13 @@ impl FreeVarReferences {
#[turbo_tasks::value(shared)]
#[derive(Debug, Clone)]
pub struct CompileTimeInfo {
pub environment: Vc<Environment>,
pub defines: Vc<CompileTimeDefines>,
pub free_var_references: Vc<FreeVarReferences>,
pub environment: ResolvedVc<Environment>,
pub defines: ResolvedVc<CompileTimeDefines>,
pub free_var_references: ResolvedVc<FreeVarReferences>,
}

impl CompileTimeInfo {
pub fn builder(environment: Vc<Environment>) -> CompileTimeInfoBuilder {
pub fn builder(environment: ResolvedVc<Environment>) -> CompileTimeInfoBuilder {
CompileTimeInfoBuilder {
environment,
defines: None,
Expand All @@ -285,50 +286,57 @@ impl CompileTimeInfo {
#[turbo_tasks::value_impl]
impl CompileTimeInfo {
#[turbo_tasks::function]
pub fn new(environment: Vc<Environment>) -> Vc<Self> {
CompileTimeInfo {
pub async fn new(environment: ResolvedVc<Environment>) -> Result<Vc<Self>> {
Ok(CompileTimeInfo {
environment,
defines: CompileTimeDefines::empty(),
free_var_references: FreeVarReferences::empty(),
defines: CompileTimeDefines::empty().to_resolved().await?,
free_var_references: FreeVarReferences::empty().to_resolved().await?,
}
.cell()
.cell())
}

#[turbo_tasks::function]
pub fn environment(&self) -> Vc<Environment> {
self.environment
*self.environment
}
}

pub struct CompileTimeInfoBuilder {
environment: Vc<Environment>,
defines: Option<Vc<CompileTimeDefines>>,
free_var_references: Option<Vc<FreeVarReferences>>,
environment: ResolvedVc<Environment>,
defines: Option<ResolvedVc<CompileTimeDefines>>,
free_var_references: Option<ResolvedVc<FreeVarReferences>>,
}

impl CompileTimeInfoBuilder {
pub fn defines(mut self, defines: Vc<CompileTimeDefines>) -> Self {
pub fn defines(mut self, defines: ResolvedVc<CompileTimeDefines>) -> Self {
self.defines = Some(defines);
self
}

pub fn free_var_references(mut self, free_var_references: Vc<FreeVarReferences>) -> Self {
pub fn free_var_references(
mut self,
free_var_references: ResolvedVc<FreeVarReferences>,
) -> Self {
self.free_var_references = Some(free_var_references);
self
}

pub fn build(self) -> CompileTimeInfo {
CompileTimeInfo {
pub async fn build(self) -> Result<CompileTimeInfo> {
Ok(CompileTimeInfo {
environment: self.environment,
defines: self.defines.unwrap_or_else(CompileTimeDefines::empty),
free_var_references: self
.free_var_references
.unwrap_or_else(FreeVarReferences::empty),
}
defines: match self.defines {
Some(defines) => defines,
None => CompileTimeDefines::empty().to_resolved().await?,
},
free_var_references: match self.free_var_references {
Some(free_var_references) => free_var_references,
None => FreeVarReferences::empty().to_resolved().await?,
},
})
}

pub fn cell(self) -> Vc<CompileTimeInfo> {
self.build().cell()
pub async fn cell(self) -> Result<Vc<CompileTimeInfo>> {
Ok(self.build().await?.cell())
}
}

Expand Down
34 changes: 13 additions & 21 deletions turbopack/crates/turbopack-core/src/environment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ impl Environment {
pub async fn compile_target(&self) -> Result<Vc<CompileTarget>> {
Ok(match self.execution {
ExecutionEnvironment::NodeJsBuildTime(node_env, ..)
| ExecutionEnvironment::NodeJsLambda(node_env) => node_env.await?.compile_target,
| ExecutionEnvironment::NodeJsLambda(node_env) => *node_env.await?.compile_target,
ExecutionEnvironment::Browser(_) => CompileTarget::unknown(),
ExecutionEnvironment::EdgeWorker(_) => CompileTarget::unknown(),
ExecutionEnvironment::Custom(_) => todo!(),
Expand Down Expand Up @@ -189,7 +189,7 @@ impl Environment {
let env = self;
Ok(match env.execution {
ExecutionEnvironment::NodeJsBuildTime(env)
| ExecutionEnvironment::NodeJsLambda(env) => env.await?.cwd,
| ExecutionEnvironment::NodeJsLambda(env) => *env.await?.cwd,
_ => Vc::cell(None),
})
}
Expand Down Expand Up @@ -227,20 +227,10 @@ pub enum NodeEnvironmentType {

#[turbo_tasks::value(shared)]
pub struct NodeJsEnvironment {
pub compile_target: Vc<CompileTarget>,
pub node_version: Vc<NodeJsVersion>,
pub compile_target: ResolvedVc<CompileTarget>,
pub node_version: ResolvedVc<NodeJsVersion>,
// user specified process.cwd
pub cwd: Vc<Option<RcStr>>,
}

impl Default for NodeJsEnvironment {
fn default() -> Self {
NodeJsEnvironment {
compile_target: CompileTarget::current(),
node_version: NodeJsVersion::default().cell(),
cwd: Vc::cell(None),
}
}
pub cwd: ResolvedVc<Option<RcStr>>,
}

#[turbo_tasks::value_impl]
Expand All @@ -262,12 +252,14 @@ impl NodeJsEnvironment {
}

#[turbo_tasks::function]
pub fn current(process_env: ResolvedVc<Box<dyn ProcessEnv>>) -> Vc<Self> {
Self::cell(NodeJsEnvironment {
compile_target: CompileTarget::current(),
node_version: NodeJsVersion::cell(NodeJsVersion::Current(process_env)),
cwd: Vc::cell(None),
})
pub async fn current(process_env: ResolvedVc<Box<dyn ProcessEnv>>) -> Result<Vc<Self>> {
Ok(Self::cell(NodeJsEnvironment {
compile_target: CompileTarget::current().to_resolved().await?,
node_version: NodeJsVersion::cell(NodeJsVersion::Current(process_env))
.to_resolved()
.await?,
cwd: ResolvedVc::cell(None),
}))
}
}

Expand Down
14 changes: 7 additions & 7 deletions turbopack/crates/turbopack-core/src/file_source.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use anyhow::Result;
use turbo_rcstr::RcStr;
use turbo_tasks::Vc;
use turbo_tasks::{ResolvedVc, Vc};
use turbo_tasks_fs::{FileContent, FileSystemEntryType, FileSystemPath, LinkContent};

use crate::{
Expand All @@ -13,22 +13,22 @@ use crate::{
/// references to other [Source]s.
#[turbo_tasks::value]
pub struct FileSource {
pub path: Vc<FileSystemPath>,
pub query: Vc<RcStr>,
pub path: ResolvedVc<FileSystemPath>,
pub query: ResolvedVc<RcStr>,
}

#[turbo_tasks::value_impl]
impl FileSource {
#[turbo_tasks::function]
pub fn new(path: Vc<FileSystemPath>) -> Vc<Self> {
pub fn new(path: ResolvedVc<FileSystemPath>) -> Vc<Self> {
Self::cell(FileSource {
path,
query: Vc::<RcStr>::default(),
query: ResolvedVc::cell(RcStr::default()),
})
}

#[turbo_tasks::function]
pub fn new_with_query(path: Vc<FileSystemPath>, query: Vc<RcStr>) -> Vc<Self> {
pub fn new_with_query(path: ResolvedVc<FileSystemPath>, query: ResolvedVc<RcStr>) -> Vc<Self> {
Self::cell(FileSource { path, query })
}
}
Expand All @@ -37,7 +37,7 @@ impl FileSource {
impl Source for FileSource {
#[turbo_tasks::function]
fn ident(&self) -> Vc<AssetIdent> {
AssetIdent::from_path(self.path).with_query(self.query)
AssetIdent::from_path(*self.path).with_query(*self.query)
}
}

Expand Down
Loading
Loading