From e2f3ad0e284ef5c63ca42b2d6c0c4ea4da92bb4d Mon Sep 17 00:00:00 2001 From: Andrew Gallant Date: Wed, 14 Feb 2024 13:41:01 -0500 Subject: [PATCH] puffin-resolver: add some trace calls This commit adds some logging to candidate selection during resolution. The idea with these logs is to get a signal on how much "exploring" the resolver does in specific examples. For example, this logs helped me realize that at least in some cases, candidate selection was looking through a long list of versions even when its range consisted of exactly one version. We'll use this fact in a later commit. --- .../puffin-resolver/src/candidate_selector.rs | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/crates/puffin-resolver/src/candidate_selector.rs b/crates/puffin-resolver/src/candidate_selector.rs index c1c69af07..b2765fe99 100644 --- a/crates/puffin-resolver/src/candidate_selector.rs +++ b/crates/puffin-resolver/src/candidate_selector.rs @@ -130,6 +130,12 @@ impl CandidateSelector { } }; + tracing::trace!( + "selecting candidate for package {:?} with range {:?} with {} versions", + package_name, + range, + version_map.len() + ); match &self.resolution_strategy { ResolutionStrategy::Highest => Self::select_candidate( version_map.iter().rev(), @@ -175,11 +181,21 @@ impl CandidateSelector { } let mut prerelease = None; + let mut steps = 0; for (version, file) in versions { + steps += 1; if version.any_prerelease() { if range.contains(version) { match allow_prerelease { AllowPreRelease::Yes => { + tracing::trace!( + "found candidate for package {:?} with range {:?} \ + after {} steps: {:?} version", + package_name, + range, + steps, + version, + ); // If pre-releases are allowed, treat them equivalently // to stable distributions. return Some(Candidate::new(package_name, version, file)); @@ -204,10 +220,25 @@ impl CandidateSelector { // Always return the first-matching stable distribution. if range.contains(version) { + tracing::trace!( + "found candidate for package {:?} with range {:?} \ + after {} steps: {:?} version", + package_name, + range, + steps, + version, + ); return Some(Candidate::new(package_name, version, file)); } } } + tracing::trace!( + "exhausted all candidates for package {:?} with range {:?} \ + after {} steps", + package_name, + range, + steps, + ); match prerelease { None => None, Some(PreReleaseCandidate::NotNecessary) => None,