Skip to content

Commit f411766

Browse files
committed
WIP: add tracing for cycle iteration
1 parent 7fcfd7f commit f411766

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/function/execute.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,21 @@ where
8181
if revisions.cycle_heads.contains(&database_key_index) {
8282
if let Some(last_provisional) = opt_last_provisional {
8383
if let Some(provisional_value) = &last_provisional.value {
84+
tracing::debug!(
85+
"{database_key_index:?}: execute: \
86+
I am a cycle head, comparing last provisional value \
87+
{provisional_value:#?} with new value {new_value:#?}"
88+
);
8489
// If the new result is equal to the last provisional result, the cycle has
8590
// converged and we are done.
8691
if !C::values_equal(&new_value, provisional_value) {
8792
// We are in a cycle that hasn't converged; ask the user's
8893
// cycle-recovery function what to do:
8994
match C::recover_from_cycle(db, &new_value, iteration_count) {
9095
crate::CycleRecoveryAction::Iterate => {
96+
tracing::debug!(
97+
"{database_key_index:?}: execute: iterate again"
98+
);
9199
iteration_count += 1;
92100
revisions.cycle_ignore = false;
93101
opt_last_provisional = Some(self.insert_memo(
@@ -98,6 +106,9 @@ where
98106
continue;
99107
}
100108
crate::CycleRecoveryAction::Fallback(fallback_value) => {
109+
tracing::debug!(
110+
"{database_key_index:?}: execute: fall back to {fallback_value:#?}"
111+
);
101112
new_value = fallback_value;
102113
}
103114
}
@@ -106,7 +117,7 @@ where
106117
}
107118
// This is no longer a provisional result, it's our final result, so remove ourself
108119
// from the cycle heads, and iterate one last time to remove ourself from all other
109-
// results in the cycle as well.
120+
// results in the cycle as well and turn them into usable cached results.
110121
revisions.cycle_heads.remove(&database_key_index);
111122
revisions.cycle_ignore = false;
112123
self.insert_memo(
@@ -116,6 +127,9 @@ where
116127
);
117128
continue;
118129
}
130+
131+
tracing::debug!("{database_key_index:?}: execute: result.revisions = {revisions:#?}");
132+
119133
return self.insert_memo(
120134
zalsa,
121135
id,

0 commit comments

Comments
 (0)