Skip to content

Commit 04a1e32

Browse files
authored
Merge pull request #560 from MichaReiser/reduce-tracing-verbosity
Reduce tracing output of memo
2 parents 05c7fbe + e994e7f commit 04a1e32

File tree

3 files changed

+40
-3
lines changed

3 files changed

+40
-3
lines changed

src/function/maybe_changed_after.rs

+9-2
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ where
7272
tracing::debug!(
7373
"{database_key_index:?}: maybe_changed_after_cold, successful claim, \
7474
revision = {revision:?}, old_memo = {old_memo:#?}",
75+
old_memo = old_memo.tracing_debug()
7576
);
7677

7778
// Check if the inputs are still valid and we can just compare `changed_at`.
@@ -105,7 +106,10 @@ where
105106
let verified_at = memo.verified_at.load();
106107
let revision_now = zalsa.current_revision();
107108

108-
tracing::debug!("{database_key_index:?}: shallow_verify_memo(memo = {memo:#?})",);
109+
tracing::debug!(
110+
"{database_key_index:?}: shallow_verify_memo(memo = {memo:#?})",
111+
memo = memo.tracing_debug()
112+
);
109113

110114
if verified_at == revision_now {
111115
// Already verified.
@@ -140,7 +144,10 @@ where
140144
let zalsa = db.zalsa();
141145
let database_key_index = active_query.database_key_index;
142146

143-
tracing::debug!("{database_key_index:?}: deep_verify_memo(old_memo = {old_memo:#?})",);
147+
tracing::debug!(
148+
"{database_key_index:?}: deep_verify_memo(old_memo = {old_memo:#?})",
149+
old_memo = old_memo.tracing_debug()
150+
);
144151

145152
if self.shallow_verify_memo(db, zalsa, database_key_index, old_memo) {
146153
return true;

src/function/memo.rs

+26
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use std::fmt::Formatter;
12
use std::sync::Arc;
23

34
use arc_swap::{ArcSwap, Guard};
@@ -168,4 +169,29 @@ impl<V> Memo<V> {
168169
output.mark_validated_output(db, database_key_index);
169170
}
170171
}
172+
173+
pub(super) fn tracing_debug(&self) -> impl std::fmt::Debug + '_ {
174+
struct TracingDebug<'a, T> {
175+
memo: &'a Memo<T>,
176+
}
177+
178+
impl<T> std::fmt::Debug for TracingDebug<'_, T> {
179+
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
180+
f.debug_struct("Memo")
181+
.field(
182+
"value",
183+
if self.memo.value.is_some() {
184+
&"Some(<value>)"
185+
} else {
186+
&"None"
187+
},
188+
)
189+
.field("verified_at", &self.memo.verified_at)
190+
.field("revisions", &self.memo.revisions)
191+
.finish()
192+
}
193+
}
194+
195+
TracingDebug { memo: self }
196+
}
171197
}

src/function/specify.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,11 @@ where
8181
revisions,
8282
};
8383

84-
tracing::debug!("specify: about to add memo {:#?} for key {:?}", memo, key);
84+
tracing::debug!(
85+
"specify: about to add memo {:#?} for key {:?}",
86+
memo.tracing_debug(),
87+
key
88+
);
8589
self.insert_memo(db, key, memo);
8690

8791
// Record that the current query *specified* a value for this cell.

0 commit comments

Comments
 (0)