mirror of
https://github.com/astral-sh/uv.git
synced 2025-11-22 20:45:25 +00:00
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.
This commit is contained in:
parent
1cff7c3774
commit
e2f3ad0e28
1 changed files with 31 additions and 0 deletions
|
|
@ -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 {
|
match &self.resolution_strategy {
|
||||||
ResolutionStrategy::Highest => Self::select_candidate(
|
ResolutionStrategy::Highest => Self::select_candidate(
|
||||||
version_map.iter().rev(),
|
version_map.iter().rev(),
|
||||||
|
|
@ -175,11 +181,21 @@ impl CandidateSelector {
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut prerelease = None;
|
let mut prerelease = None;
|
||||||
|
let mut steps = 0;
|
||||||
for (version, file) in versions {
|
for (version, file) in versions {
|
||||||
|
steps += 1;
|
||||||
if version.any_prerelease() {
|
if version.any_prerelease() {
|
||||||
if range.contains(version) {
|
if range.contains(version) {
|
||||||
match allow_prerelease {
|
match allow_prerelease {
|
||||||
AllowPreRelease::Yes => {
|
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
|
// If pre-releases are allowed, treat them equivalently
|
||||||
// to stable distributions.
|
// to stable distributions.
|
||||||
return Some(Candidate::new(package_name, version, file));
|
return Some(Candidate::new(package_name, version, file));
|
||||||
|
|
@ -204,10 +220,25 @@ impl CandidateSelector {
|
||||||
|
|
||||||
// Always return the first-matching stable distribution.
|
// Always return the first-matching stable distribution.
|
||||||
if range.contains(version) {
|
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));
|
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 {
|
match prerelease {
|
||||||
None => None,
|
None => None,
|
||||||
Some(PreReleaseCandidate::NotNecessary) => None,
|
Some(PreReleaseCandidate::NotNecessary) => None,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue