Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
f89016d7
Unverified
Commit
f89016d7
authored
Dec 01, 2025
by
Niklas Mischkulnig
Committed by
GitHub
Dec 01, 2025
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Turbopack: improve eventual consistency (#86682)
as always..
parent
daa822c5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
15 deletions
+25
-15
binding_usage_info.rs
...tes/turbopack-core/src/module_graph/binding_usage_info.rs
+4
-2
module_batches.rs
.../crates/turbopack-core/src/module_graph/module_batches.rs
+21
-13
No files found.
turbopack/crates/turbopack-core/src/module_graph/binding_usage_info.rs
View file @
f89016d7
use
std
::
collections
::
hash_map
::
Entry
;
use
std
::
collections
::
hash_map
::
Entry
;
use
anyhow
::{
Result
,
bail
};
use
anyhow
::{
Context
,
Result
,
bail
};
use
auto_hash_map
::
AutoSet
;
use
auto_hash_map
::
AutoSet
;
use
rustc_hash
::{
FxHashMap
,
FxHashSet
};
use
rustc_hash
::{
FxHashMap
,
FxHashSet
};
use
tracing
::
Instrument
;
use
tracing
::
Instrument
;
...
@@ -140,7 +140,9 @@ pub async fn compute_binding_usage_info(
...
@@ -140,7 +140,9 @@ pub async fn compute_binding_usage_info(
// If the current edge is an unused import, skip it
// If the current edge is an unused import, skip it
match
&
ref_data
.binding_usage.import
{
match
&
ref_data
.binding_usage.import
{
ImportUsage
::
Exports
(
exports
)
=>
{
ImportUsage
::
Exports
(
exports
)
=>
{
let
source_used_exports
=
used_exports
.get
(
&
parent
)
.unwrap
();
let
source_used_exports
=
used_exports
.get
(
&
parent
)
.context
(
"parent module must have usage info"
)
?
;
if
exports
if
exports
.iter
()
.iter
()
.all
(|
e
|
!
source_used_exports
.is_export_used
(
e
))
.all
(|
e
|
!
source_used_exports
.is_export_used
(
e
))
...
...
turbopack/crates/turbopack-core/src/module_graph/module_batches.rs
View file @
f89016d7
...
@@ -449,10 +449,13 @@ pub async fn compute_module_batches(
...
@@ -449,10 +449,13 @@ pub async fn compute_module_batches(
|
v
|
Either
::
Right
(
v
.iter
()
.copied
()),
|
v
|
Either
::
Right
(
v
.iter
()
.copied
()),
)
)
.map
(|
module
|
{
.map
(|
module
|
{
let
idx
=
*
pre_batches
.entries
.get
(
&
module
)
.unwrap
();
let
idx
=
*
pre_batches
(
idx
,
0
)
.entries
.get
(
&
module
)
.context
(
"could not prebatch for module"
)
?
;
Ok
((
idx
,
0
))
})
})
.collect
::
<
Vec
<
_
>>
()
;
.collect
::
<
Result
<
Vec
<
_
>>>
()
?
;
stack
.reverse
();
stack
.reverse
();
let
mut
visited
=
FxHashSet
::
default
();
let
mut
visited
=
FxHashSet
::
default
();
while
let
Some
((
idx
,
mut
pos
))
=
stack
.pop
()
{
while
let
Some
((
idx
,
mut
pos
))
=
stack
.pop
()
{
...
@@ -501,7 +504,7 @@ pub async fn compute_module_batches(
...
@@ -501,7 +504,7 @@ pub async fn compute_module_batches(
let
idx
=
chunk_group_info
let
idx
=
chunk_group_info
.chunk_group_keys
.chunk_group_keys
.get_index_of
(
&
chunk_group_key
)
.get_index_of
(
&
chunk_group_key
)
.
unwrap
()
;
.
context
(
"could not find chunk group key for merged chunk group"
)
?
;
ordered_entries
[
idx
]
=
Some
(
merged_modules
);
ordered_entries
[
idx
]
=
Some
(
merged_modules
);
}
}
}
}
...
@@ -536,7 +539,9 @@ pub async fn compute_module_batches(
...
@@ -536,7 +539,9 @@ pub async fn compute_module_batches(
let
mut
extracted_shared_items
=
0
;
let
mut
extracted_shared_items
=
0
;
// Extract shared modules into separate batches
// Extract shared modules into separate batches
for
i
in
0
..
parallel_module_to_pre_batch
.len
()
{
for
i
in
0
..
parallel_module_to_pre_batch
.len
()
{
let
(
&
module
,
batches
)
=
parallel_module_to_pre_batch
.get_index
(
i
)
.unwrap
();
let
(
&
module
,
batches
)
=
parallel_module_to_pre_batch
.get_index
(
i
)
.context
(
"could not find parallel module to pre batch index"
)
?
;
if
batches
.len
()
>
1
{
if
batches
.len
()
>
1
{
// Create a new batch for the shared modules
// Create a new batch for the shared modules
let
batches_with_item_index
=
batches
let
batches_with_item_index
=
batches
...
@@ -545,10 +550,10 @@ pub async fn compute_module_batches(
...
@@ -545,10 +550,10 @@ pub async fn compute_module_batches(
let
batch_items
=
&
pre_batches
.batches
[
idx
]
.items
;
let
batch_items
=
&
pre_batches
.batches
[
idx
]
.items
;
let
item_idx
=
batch_items
let
item_idx
=
batch_items
.get_index_of
(
&
PreBatchItem
::
ParallelModule
(
module
))
.get_index_of
(
&
PreBatchItem
::
ParallelModule
(
module
))
.
unwrap
()
;
.
context
(
"could not find batch item index for parallel module"
)
?
;
(
idx
,
item_idx
)
Ok
((
idx
,
item_idx
)
)
})
})
.collect
::
<
Vec
<
_
>>
()
;
.collect
::
<
Result
<
Vec
<
_
>>>
()
?
;
let
mut
selected_items
=
1
;
let
mut
selected_items
=
1
;
fn
get_item_at
(
fn
get_item_at
(
pre_batches
:
&
PreBatches
,
pre_batches
:
&
PreBatches
,
...
@@ -564,7 +569,10 @@ pub async fn compute_module_batches(
...
@@ -564,7 +569,10 @@ pub async fn compute_module_batches(
&
pre_batches
,
&
pre_batches
,
batches_with_item_index
[
0
]
.
0
,
batches_with_item_index
[
0
]
.
0
,
batches_with_item_index
[
0
]
.
1
+
selected_items
,
batches_with_item_index
[
0
]
.
1
+
selected_items
,
)
&&
parallel_module_to_pre_batch
.get
(
next_module
)
.unwrap
()
.len
()
)
&&
parallel_module_to_pre_batch
.get
(
next_module
)
.context
(
"could not find pre batch for parallel module"
)
?
.len
()
==
batches
.len
()
==
batches
.len
()
&&
batches_with_item_index
[
1
..
]
&&
batches_with_item_index
[
1
..
]
.iter
()
.iter
()
...
@@ -602,7 +610,7 @@ pub async fn compute_module_batches(
...
@@ -602,7 +610,7 @@ pub async fn compute_module_batches(
if
let
PreBatchItem
::
ParallelModule
(
module
)
=
item
{
if
let
PreBatchItem
::
ParallelModule
(
module
)
=
item
{
parallel_module_to_pre_batch
parallel_module_to_pre_batch
.get_mut
(
module
)
.get_mut
(
module
)
.
unwrap
()
.
context
(
"could not find pre batch for parallel module"
)
?
.clear
();
.clear
();
}
}
}
}
...
@@ -624,7 +632,7 @@ pub async fn compute_module_batches(
...
@@ -624,7 +632,7 @@ pub async fn compute_module_batches(
if
let
PreBatchItem
::
ParallelModule
(
module
)
=
item
{
if
let
PreBatchItem
::
ParallelModule
(
module
)
=
item
{
parallel_module_to_pre_batch
parallel_module_to_pre_batch
.get_mut
(
module
)
.get_mut
(
module
)
.
unwrap
()
.
context
(
"could not find pre batch for parallel module"
)
?
.clear
();
.clear
();
}
}
}
}
...
@@ -852,7 +860,7 @@ pub async fn compute_module_batches(
...
@@ -852,7 +860,7 @@ pub async fn compute_module_batches(
let
idx
=
pre_batches
let
idx
=
pre_batches
.single_module_entries
.single_module_entries
.get_index_of
(
&
module
)
.get_index_of
(
&
module
)
.
unwrap
()
;
.
context
(
"could not find single module entry index"
)
?
;
let
idx
=
single_module_indices
[
idx
];
let
idx
=
single_module_indices
[
idx
];
graph
.add_edge
(
graph
.add_edge
(
index
,
index
,
...
@@ -882,7 +890,7 @@ pub async fn compute_module_batches(
...
@@ -882,7 +890,7 @@ pub async fn compute_module_batches(
let
idx
=
pre_batches
let
idx
=
pre_batches
.single_module_entries
.single_module_entries
.get_index_of
(
&
module
)
.get_index_of
(
&
module
)
.
unwrap
()
;
.
context
(
"could not find single module entry index"
)
?
;
let
idx
=
single_module_indices
[
idx
];
let
idx
=
single_module_indices
[
idx
];
entries
.insert
(
module
,
idx
);
entries
.insert
(
module
,
idx
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment