Skip to content

Commit

Permalink
WIP: add tracing for cycle iteration
Browse files Browse the repository at this point in the history
  • Loading branch information
carljm committed Oct 24, 2024
1 parent 7fcfd7f commit f411766
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/function/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,21 @@ 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) {
// 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(
Expand All @@ -98,6 +106,9 @@ where
continue;
}
crate::CycleRecoveryAction::Fallback(fallback_value) => {
tracing::debug!(
"{database_key_index:?}: execute: fall back to {fallback_value:#?}"
);
new_value = fallback_value;
}
}
Expand All @@ -106,7 +117,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(
Expand All @@ -116,6 +127,9 @@ where
);
continue;
}

tracing::debug!("{database_key_index:?}: execute: result.revisions = {revisions:#?}");

return self.insert_memo(
zalsa,
id,
Expand Down

0 comments on commit f411766

Please sign in to comment.