Unverified Commit 29524c1e authored by Niklas Mischkulnig's avatar Niklas Mischkulnig Committed by GitHub

Turbopack: improve eventual consistency (#86724)

as always...
parent 420c6114
...@@ -342,14 +342,16 @@ pub async fn compute_merged_modules(module_graph: Vc<ModuleGraph>) -> Result<Vc< ...@@ -342,14 +342,16 @@ pub async fn compute_merged_modules(module_graph: Vc<ModuleGraph>) -> Result<Vc<
let module = node; let module = node;
let bitmap = module_merged_groups let bitmap = module_merged_groups
.get(&module) .get(&module)
.context("every module should have a bitmap at this point")?; .context("every module should have a bitmap")?;
if mergeable.contains(&module) { if mergeable.contains(&module) {
let mergeable_module = let mergeable_module =
ResolvedVc::try_downcast::<Box<dyn MergeableModule>>( ResolvedVc::try_downcast::<Box<dyn MergeableModule>>(
module, module,
) )
.unwrap(); .context(
"found mergeable module which is not a MergeableModule",
)?;
match chunk_lists.entry(bitmap) { match chunk_lists.entry(bitmap) {
Entry::Vacant(e) => { Entry::Vacant(e) => {
// New list, insert the module // New list, insert the module
...@@ -382,8 +384,12 @@ pub async fn compute_merged_modules(module_graph: Vc<ModuleGraph>) -> Result<Vc< ...@@ -382,8 +384,12 @@ pub async fn compute_merged_modules(module_graph: Vc<ModuleGraph>) -> Result<Vc<
} }
if let Some((parent, _)) = parent_info { if let Some((parent, _)) = parent_info {
let same_bitmap = module_merged_groups.get(&parent).unwrap() let same_bitmap = module_merged_groups
== module_merged_groups.get(&module).unwrap(); .get(&parent)
.context("every module should have a bitmap")?
== module_merged_groups
.get(&module)
.context("every module should have a bitmap")?;
if same_bitmap { if same_bitmap {
intra_group_references_rev intra_group_references_rev
...@@ -470,8 +476,12 @@ pub async fn compute_merged_modules(module_graph: Vc<ModuleGraph>) -> Result<Vc< ...@@ -470,8 +476,12 @@ pub async fn compute_merged_modules(module_graph: Vc<ModuleGraph>) -> Result<Vc<
let module = node; let module = node;
if let Some((parent, _)) = parent_info { if let Some((parent, _)) = parent_info {
let same_bitmap = module_merged_groups.get(&parent).unwrap() let same_bitmap = module_merged_groups
== module_merged_groups.get(&module).unwrap(); .get(&parent)
.context("every module should have a bitmap")?
== module_merged_groups
.get(&module)
.context("every module should have a bitmap")?;
if same_bitmap { if same_bitmap {
intra_group_references intra_group_references
...@@ -481,10 +491,17 @@ pub async fn compute_merged_modules(module_graph: Vc<ModuleGraph>) -> Result<Vc< ...@@ -481,10 +491,17 @@ pub async fn compute_merged_modules(module_graph: Vc<ModuleGraph>) -> Result<Vc<
} }
} }
if parent_info.is_none_or(|(parent, _)| { if match parent_info {
module_merged_groups.get(&parent).unwrap() None => true,
!= module_merged_groups.get(&module).unwrap() Some((parent, _)) => {
}) { module_merged_groups
.get(&parent)
.context("every module should have a bitmap")?
!= module_merged_groups
.get(&module)
.context("every module should have a bitmap")?
}
} {
// This module needs to be exposed: // This module needs to be exposed:
// - referenced from another group or // - referenced from another group or
// - an entry module (TODO assume it will be required for Node/Edge, but not // - an entry module (TODO assume it will be required for Node/Edge, but not
...@@ -553,7 +570,9 @@ pub async fn compute_merged_modules(module_graph: Vc<ModuleGraph>) -> Result<Vc< ...@@ -553,7 +570,9 @@ pub async fn compute_merged_modules(module_graph: Vc<ModuleGraph>) -> Result<Vc<
// Insert occurrences for the "common" list, skip the first because that is now // Insert occurrences for the "common" list, skip the first because that is now
// guaranteed to exist only once // guaranteed to exist only once
for (i, &m) in common_list.iter().enumerate().skip(1) { for (i, &m) in common_list.iter().enumerate().skip(1) {
let occurrences = lists_reverse_indices.get_mut(&m).unwrap(); let occurrences = lists_reverse_indices
.get_mut(&m)
.context("every module should have occurrences")?;
for common_occurrence in &common_occurrences { for common_occurrence in &common_occurrences {
let removed = occurrences.swap_remove(&ListOccurrence { let removed = occurrences.swap_remove(&ListOccurrence {
chunk_group: common_occurrence.chunk_group, chunk_group: common_occurrence.chunk_group,
......
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