Skip to content

Commit

Permalink
uv-resolver: rejigger 'trace_resolution'
Browse files Browse the repository at this point in the history
When I first wrote this routine, it was intended to only emit a trace
for the final "unioned" resolution. But we actually moved that semantic
operation to the construction of the resolution *graph*. So there is no
unioned `Resolution` any more.

But this is still useful to see. So I changed this to just emit a trace
of *every* resolution right before constructing the graph.

It might be nice to also emit a trace of the unioned graph too. Or
perhaps we should do that instead if this proves too noisy. (Although
this is only emitted at TRACE level.)
  • Loading branch information
BurntSushi committed Sep 3, 2024
1 parent d6a1446 commit 94a0a0f
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions crates/uv-resolver/src/resolver/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,6 @@ impl<InstalledPackages: InstalledPackagesProvider> ResolverState<InstalledPackag
);
}

Self::trace_resolution(&resolution);
resolutions.push(resolution);
continue 'FORK;
};
Expand Down Expand Up @@ -563,6 +562,7 @@ impl<InstalledPackages: InstalledPackagesProvider> ResolverState<InstalledPackag
resolution.nodes.len()
);
}
Self::trace_resolution(resolution);
}
ResolutionGraph::from_state(
&resolutions,
Expand All @@ -579,17 +579,22 @@ impl<InstalledPackages: InstalledPackagesProvider> ResolverState<InstalledPackag
}

/// When trace level logging is enabled, we dump the final
/// unioned resolution, including markers, to help with
/// set of resolutions, including markers, to help with
/// debugging. Namely, this tells use precisely the state
/// emitted by the resolver before going off to construct a
/// resolution graph.
fn trace_resolution(combined: &Resolution) {
if !tracing::enabled!(Level::TRACE) {
return;
}
if let Some(markers) = combined.markers.fork_markers() {
trace!("Resolution: {:?}", markers);
} else {
trace!("Resolution: <matches all marker environments>");
}
for edge in &combined.edges {
trace!(
"Resolution: {} -> {}",
"Resolution edge: {} -> {}",
edge.from
.as_ref()
.map(PackageName::as_str)
Expand Down Expand Up @@ -619,7 +624,7 @@ impl<InstalledPackages: InstalledPackagesProvider> ResolverState<InstalledPackag
if let Some(marker) = edge.marker.contents() {
write!(msg, " ; {marker}").unwrap();
}
trace!("Resolution: {msg}");
trace!("Resolution edge: {msg}");
}
}

Expand Down

0 comments on commit 94a0a0f

Please sign in to comment.