From 31c3294c02a5421179f379dfd5badc337a5f9f3e Mon Sep 17 00:00:00 2001 From: Christoph Knittel Date: Sun, 17 May 2026 12:47:46 +0200 Subject: [PATCH 1/3] Rewatch: use a single timestamp per compile pass --- rewatch/src/build/compile.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/rewatch/src/build/compile.rs b/rewatch/src/build/compile.rs index a0022d20fb..fccd784245 100644 --- a/rewatch/src/build/compile.rs +++ b/rewatch/src/build/compile.rs @@ -468,6 +468,12 @@ pub fn compile( // though modules complete in arbitrary order. results_buffer.sort_by(|a, b| a.module_name.cmp(&b.module_name)); + // Use one timestamp for the whole pass. `mark_modules_with_expired_deps_dirty` + // compares dependency/dependent timestamps before the next build; assigning + // per-result timestamps here would make the sorted result-processing order + // look like real staleness and can force unnecessary downstream recompiles. + let compile_timestamp = SystemTime::now(); + for msg in results_buffer { let CompletionMsg { module_name, @@ -558,8 +564,8 @@ pub fn compile( if result.is_ok() && interface_result.as_ref().is_none_or(|r| r.is_ok()) { module.compile_dirty = false; - module.last_compiled_cmi = Some(SystemTime::now()); - module.last_compiled_cmt = Some(SystemTime::now()); + module.last_compiled_cmi = Some(compile_timestamp); + module.last_compiled_cmt = Some(compile_timestamp); } (compile_warning, compile_error, interface_warning, interface_error) From 5b314738a0f7d7fb46e94c0941687ad4e9172622 Mon Sep 17 00:00:00 2001 From: Christoph Knittel Date: Sun, 17 May 2026 13:02:02 +0200 Subject: [PATCH 2/3] Rewatch: check cmi timestamp when detecting expired deps --- rewatch/src/build/compile.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rewatch/src/build/compile.rs b/rewatch/src/build/compile.rs index fccd784245..e2e743fec1 100644 --- a/rewatch/src/build/compile.rs +++ b/rewatch/src/build/compile.rs @@ -1214,7 +1214,7 @@ pub fn mark_modules_with_expired_deps_dirty(build_state: &mut BuildCommandState) let dependent_module = build_state.modules.get(dependent).unwrap(); match dependent_module.source_type { SourceType::SourceFile(_) => { - match (module.last_compiled_cmt, module.last_compiled_cmt) { + match (module.last_compiled_cmt, module.last_compiled_cmi) { (None, None) | (Some(_), None) | (None, Some(_)) => { // println!( // "🛑 {} is a dependent of {} but has no cmt/cmi", From 76a695efedba00c6ed7a0cb74ea3379b22a5301c Mon Sep 17 00:00:00 2001 From: Jaap Frolich Date: Sun, 17 May 2026 17:04:02 +0200 Subject: [PATCH 3/3] Rewatch: clarify compile timestamp generation Signed-off-by: Jaap Frolich --- rewatch/src/build/compile.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/rewatch/src/build/compile.rs b/rewatch/src/build/compile.rs index e2e743fec1..20b11c57c2 100644 --- a/rewatch/src/build/compile.rs +++ b/rewatch/src/build/compile.rs @@ -468,10 +468,10 @@ pub fn compile( // though modules complete in arbitrary order. results_buffer.sort_by(|a, b| a.module_name.cmp(&b.module_name)); - // Use one timestamp for the whole pass. `mark_modules_with_expired_deps_dirty` - // compares dependency/dependent timestamps before the next build; assigning - // per-result timestamps here would make the sorted result-processing order - // look like real staleness and can force unnecessary downstream recompiles. + // These timestamps are used as a compile-generation marker by + // mark_modules_with_expired_deps_dirty, not as precise wall-clock compile + // times. All modules successfully compiled in one pass are mutually + // up-to-date for that pass, so they must receive the same timestamp. let compile_timestamp = SystemTime::now(); for msg in results_buffer {