Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce tracing output of memo #560

Merged
merged 1 commit into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/function/maybe_changed_after.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ where
tracing::debug!(
"{database_key_index:?}: maybe_changed_after_cold, successful claim, \
revision = {revision:?}, old_memo = {old_memo:#?}",
old_memo = old_memo.tracing_debug()
);

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

tracing::debug!("{database_key_index:?}: shallow_verify_memo(memo = {memo:#?})",);
tracing::debug!(
"{database_key_index:?}: shallow_verify_memo(memo = {memo:#?})",
memo = memo.tracing_debug()
);

if verified_at == revision_now {
// Already verified.
Expand Down Expand Up @@ -140,7 +144,10 @@ where
let zalsa = db.zalsa();
let database_key_index = active_query.database_key_index;

tracing::debug!("{database_key_index:?}: deep_verify_memo(old_memo = {old_memo:#?})",);
tracing::debug!(
"{database_key_index:?}: deep_verify_memo(old_memo = {old_memo:#?})",
old_memo = old_memo.tracing_debug()
);

if self.shallow_verify_memo(db, zalsa, database_key_index, old_memo) {
return true;
Expand Down
26 changes: 26 additions & 0 deletions src/function/memo.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use std::fmt::Formatter;
use std::sync::Arc;

use arc_swap::{ArcSwap, Guard};
Expand Down Expand Up @@ -168,4 +169,29 @@ impl<V> Memo<V> {
output.mark_validated_output(db, database_key_index);
}
}

pub(super) fn tracing_debug(&self) -> impl std::fmt::Debug + '_ {
struct TracingDebug<'a, T> {
memo: &'a Memo<T>,
}

impl<T> std::fmt::Debug for TracingDebug<'_, T> {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
f.debug_struct("Memo")
.field(
"value",
if self.memo.value.is_some() {
&"Some(<value>)"
} else {
&"None"
},
)
.field("verified_at", &self.memo.verified_at)
.field("revisions", &self.memo.revisions)
.finish()
}
}

TracingDebug { memo: self }
}
}
6 changes: 5 additions & 1 deletion src/function/specify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,11 @@ where
revisions,
};

tracing::debug!("specify: about to add memo {:#?} for key {:?}", memo, key);
tracing::debug!(
"specify: about to add memo {:#?} for key {:?}",
memo.tracing_debug(),
key
);
self.insert_memo(db, key, memo);

// Record that the current query *specified* a value for this cell.
Expand Down
Loading