Skip to content

Commit afc76ac

Browse files
committed
fixup! Rewatch: replace wave scheduler with DAG + critical-path priority (#8374)
Signed-off-by: Christoph Knittel <ck@cca.io>
1 parent a955025 commit afc76ac

1 file changed

Lines changed: 51 additions & 21 deletions

File tree

rewatch/src/build/compile.rs

Lines changed: 51 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ pub fn compile(
265265
}
266266
})
267267
.collect::<AHashSet<String>>();
268+
let originally_dirty_modules = dirty_modules.clone();
268269

269270
// Expand the compile universe: every dirty module plus everything that
270271
// transitively depends on it.
@@ -459,7 +460,37 @@ pub fn compile(
459460
// though modules complete in arbitrary order.
460461
results_buffer.sort_by(|a, b| a.module_name.cmp(&b.module_name));
461462

462-
let mut recompiled_modules = AHashSet::<String>::new();
463+
let stored_warnings_before_compile = build_state
464+
.modules
465+
.iter()
466+
.filter_map(|(module_name, module)| {
467+
if originally_dirty_modules.contains(module_name) {
468+
return None;
469+
}
470+
471+
let SourceType::SourceFile(source_file) = &module.source_type else {
472+
return None;
473+
};
474+
475+
let implementation_warning = source_file.implementation.compile_warnings.clone();
476+
let interface_warning = source_file
477+
.interface
478+
.as_ref()
479+
.and_then(|interface| interface.compile_warnings.clone());
480+
481+
if implementation_warning.is_none() && interface_warning.is_none() {
482+
return None;
483+
}
484+
485+
Some((
486+
module_name.clone(),
487+
module.package_name.clone(),
488+
implementation_warning,
489+
interface_warning,
490+
))
491+
})
492+
.collect::<Vec<(String, String, Option<String>, Option<String>)>>();
493+
let mut modules_with_emitted_warnings = AHashSet::<String>::new();
463494

464495
for msg in results_buffer {
465496
let CompletionMsg {
@@ -472,7 +503,6 @@ pub fn compile(
472503

473504
if is_compiled {
474505
num_compiled_modules += 1;
475-
recompiled_modules.insert(module_name.clone());
476506
}
477507

478508
let package_name = {
@@ -569,6 +599,7 @@ pub fn compile(
569599
if let Some(warning) = compile_warning {
570600
logs::append(package, &warning);
571601
compile_warnings.push_str(&warning);
602+
modules_with_emitted_warnings.insert(module_name.clone());
572603
}
573604
if let Some(error) = compile_error {
574605
logs::append(package, &error);
@@ -577,6 +608,7 @@ pub fn compile(
577608
if let Some(warning) = interface_warning {
578609
logs::append(package, &warning);
579610
compile_warnings.push_str(&warning);
611+
modules_with_emitted_warnings.insert(module_name.clone());
580612
}
581613
if let Some(error) = interface_error {
582614
logs::append(package, &error);
@@ -613,29 +645,27 @@ pub fn compile(
613645
compile_errors.push_str(&message);
614646
}
615647

616-
// Collect warnings from modules that were not recompiled in this build but still have stored
617-
// warnings from a previous compilation. This includes ready modules that were in the compile
618-
// universe but never scheduled because an earlier module failed.
619-
for (module_name, module) in build_state.modules.iter() {
620-
if recompiled_modules.contains(module_name) {
648+
// Collect warnings from modules that did not emit a warning in this build but still had stored
649+
// warnings from a previous compilation before we started. This includes ready modules that were
650+
// in the compile universe but never scheduled because an earlier module failed.
651+
for (module_name, package_name, implementation_warning, interface_warning) in
652+
stored_warnings_before_compile
653+
{
654+
if modules_with_emitted_warnings.contains(&module_name) {
621655
continue;
622656
}
623-
if let SourceType::SourceFile(ref source_file) = module.source_type {
624-
let package = build_state.get_package(&module.package_name);
625-
if let Some(ref warning) = source_file.implementation.compile_warnings {
626-
if let Some(package) = package {
627-
logs::append(package, warning);
628-
}
629-
compile_warnings.push_str(warning);
657+
let package = build_state.get_package(&package_name);
658+
if let Some(warning) = implementation_warning {
659+
if let Some(package) = package {
660+
logs::append(package, &warning);
630661
}
631-
if let Some(ref interface) = source_file.interface
632-
&& let Some(ref warning) = interface.compile_warnings
633-
{
634-
if let Some(package) = package {
635-
logs::append(package, warning);
636-
}
637-
compile_warnings.push_str(warning);
662+
compile_warnings.push_str(&warning);
663+
}
664+
if let Some(warning) = interface_warning {
665+
if let Some(package) = package {
666+
logs::append(package, &warning);
638667
}
668+
compile_warnings.push_str(&warning);
639669
}
640670
}
641671

0 commit comments

Comments
 (0)