Merge pull request #259 from jonas-schievink/debug-query-deps

Log `MemoInputs` in human-readable form
This commit is contained in:
Aleksey Kladov 2021-05-05 18:31:52 +03:00 committed by GitHub
commit b5683fec5e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 44 additions and 3 deletions

View file

@ -280,7 +280,7 @@ where
debug!(
"read_upgrade({:?}): result.changed_at={:?}, \
result.durability={:?}, result.dependencies = {:#?}",
result.durability={:?}, result.dependencies = {:?}",
self, result.changed_at, result.durability, result.dependencies,
);
@ -297,7 +297,7 @@ where
}
}
};
debug!("read_upgrade({:?}): inputs={:?}", self, inputs);
debug!("read_upgrade({:?}): inputs={:#?}", self, inputs.debug(db));
panic_guard.memo = Some(Memo {
value,
@ -994,6 +994,47 @@ where
}
}
impl MemoInputs {
fn debug<'a, D: ?Sized>(&'a self, db: &'a D) -> impl std::fmt::Debug + 'a
where
D: DatabaseOps,
{
enum DebugMemoInputs<'a, D: ?Sized> {
Tracked {
inputs: &'a [DatabaseKeyIndex],
db: &'a D,
},
NoInputs,
Untracked,
}
impl<D: ?Sized + DatabaseOps> std::fmt::Debug for DebugMemoInputs<'_, D> {
fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
DebugMemoInputs::Tracked { inputs, db } => fmt
.debug_struct("Tracked")
.field(
"inputs",
&inputs.iter().map(|key| key.debug(*db)).collect::<Vec<_>>(),
)
.finish(),
DebugMemoInputs::NoInputs => fmt.debug_struct("NoInputs").finish(),
DebugMemoInputs::Untracked => fmt.debug_struct("Untracked").finish(),
}
}
}
match self {
MemoInputs::Tracked { inputs } => DebugMemoInputs::Tracked {
inputs: &inputs,
db,
},
MemoInputs::NoInputs => DebugMemoInputs::NoInputs,
MemoInputs::Untracked => DebugMemoInputs::Untracked,
}
}
}
impl std::fmt::Debug for MemoInputs {
fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {

View file

@ -603,7 +603,7 @@ pub(crate) struct ComputedQueryResult<V> {
pub(crate) changed_at: Revision,
/// Complete set of subqueries that were accessed, or `None` if
/// there was an untracked the read.
/// there was an untracked read.
pub(crate) dependencies: Option<FxIndexSet<DatabaseKeyIndex>>,
/// The cycle if one occured while computing this value