From f700c39c0555b70034ac09b279b5e3727547a0f3 Mon Sep 17 00:00:00 2001 From: Carl Meyer Date: Thu, 24 Oct 2024 13:05:06 -0700 Subject: [PATCH] WIP: add tracing for cycle iteration --- src/function/execute.rs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/function/execute.rs b/src/function/execute.rs index 00e85067..406c176e 100644 --- a/src/function/execute.rs +++ b/src/function/execute.rs @@ -81,13 +81,24 @@ where if revisions.cycle_heads.contains(&database_key_index) { if let Some(last_provisional) = opt_last_provisional { if let Some(provisional_value) = &last_provisional.value { + tracing::debug!( + "{database_key_index:?}: execute: \ + I am a cycle head, comparing last provisional value \ + {provisional_value:#?} with new value {new_value:#?}" + ); // If the new result is equal to the last provisional result, the cycle has // converged and we are done. if !C::values_equal(&new_value, provisional_value) { + tracing::debug!( + "{database_key_index:?}: execute: not converged, calling cycle_fn" + ); // We are in a cycle that hasn't converged; ask the user's // cycle-recovery function what to do: match C::recover_from_cycle(db, &new_value, iteration_count) { crate::CycleRecoveryAction::Iterate => { + tracing::debug!( + "{database_key_index:?}: execute: iterate again" + ); iteration_count += 1; revisions.cycle_ignore = false; opt_last_provisional = Some(self.insert_memo( @@ -98,6 +109,9 @@ where continue; } crate::CycleRecoveryAction::Fallback(fallback_value) => { + tracing::debug!( + "{database_key_index:?}: execute: fall back to {fallback_value:#?}" + ); new_value = fallback_value; } } @@ -106,7 +120,7 @@ where } // This is no longer a provisional result, it's our final result, so remove ourself // from the cycle heads, and iterate one last time to remove ourself from all other - // results in the cycle as well. + // results in the cycle as well and turn them into usable cached results. revisions.cycle_heads.remove(&database_key_index); revisions.cycle_ignore = false; self.insert_memo( @@ -116,6 +130,9 @@ where ); continue; } + + tracing::debug!("{database_key_index:?}: execute: result.revisions = {revisions:#?}"); + return self.insert_memo( zalsa, id,