Skip to content

Commit f700c39

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

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/function/execute.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,24 @@ 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) {
92+
tracing::debug!(
93+
"{database_key_index:?}: execute: not converged, calling cycle_fn"
94+
);
8795
// We are in a cycle that hasn't converged; ask the user's
8896
// cycle-recovery function what to do:
8997
match C::recover_from_cycle(db, &new_value, iteration_count) {
9098
crate::CycleRecoveryAction::Iterate => {
99+
tracing::debug!(
100+
"{database_key_index:?}: execute: iterate again"
101+
);
91102
iteration_count += 1;
92103
revisions.cycle_ignore = false;
93104
opt_last_provisional = Some(self.insert_memo(
@@ -98,6 +109,9 @@ where
98109
continue;
99110
}
100111
crate::CycleRecoveryAction::Fallback(fallback_value) => {
112+
tracing::debug!(
113+
"{database_key_index:?}: execute: fall back to {fallback_value:#?}"
114+
);
101115
new_value = fallback_value;
102116
}
103117
}
@@ -106,7 +120,7 @@ where
106120
}
107121
// This is no longer a provisional result, it's our final result, so remove ourself
108122
// from the cycle heads, and iterate one last time to remove ourself from all other
109-
// results in the cycle as well.
123+
// results in the cycle as well and turn them into usable cached results.
110124
revisions.cycle_heads.remove(&database_key_index);
111125
revisions.cycle_ignore = false;
112126
self.insert_memo(
@@ -116,6 +130,9 @@ where
116130
);
117131
continue;
118132
}
133+
134+
tracing::debug!("{database_key_index:?}: execute: result.revisions = {revisions:#?}");
135+
119136
return self.insert_memo(
120137
zalsa,
121138
id,

0 commit comments

Comments
 (0)