Skip to content

Commit

Permalink
chore: Add more tracing
Browse files Browse the repository at this point in the history
Signed-off-by: Julien Jerphanion <git@jjerphan.xyz>
  • Loading branch information
jjerphan committed Jul 17, 2024
1 parent 8e47d5b commit 2107341
Show file tree
Hide file tree
Showing 5 changed files with 186 additions and 26 deletions.
31 changes: 31 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash

set -euxo pipefail

export PREFIX=/home/jjerphan/.local/miniforge3/envs/mamba
export BUILD_PREFIX=$PREFIX
export CARGO_BUILD_TARGET=x86_64-unknown-linux-gnu

cmake -B build \
-GNinja \
-DRust_CARGO_TARGET=${CARGO_BUILD_TARGET} \
-DCMAKE_AR=$BUILD_PREFIX/bin/x86_64-conda-linux-gnu-ar \
-DCMAKE_CXX_COMPILER_AR=$BUILD_PREFIX/bin/x86_64-conda-linux-gnu-gcc-ar \
-DCMAKE_C_COMPILER_AR=$BUILD_PREFIX/bin/x86_64-conda-linux-gnu-gcc-ar \
-DCMAKE_RANLIB=$BUILD_PREFIX/bin/x86_64-conda-linux-gnu-ranlib \
-DCMAKE_CXX_COMPILER_RANLIB=$BUILD_PREFIX/bin/x86_64-conda-linux-gnu-gcc-ranlib \
-DCMAKE_C_COMPILER_RANLIB=$BUILD_PREFIX/bin/x86_64-conda-linux-gnu-gcc-ranlib \
-DCMAKE_LINKER=$BUILD_PREFIX/bin/x86_64-conda-linux-gnu-ld \
-DCMAKE_STRIP=$BUILD_PREFIX/bin/x86_64-conda-linux-gnu-strip \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER \
-DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY \
-DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY \
-DCMAKE_FIND_ROOT_PATH="$PREFIX;$BUILD_PREFIX/x86_64-conda-linux-gnu/sysroot" \
-DCMAKE_INSTALL_PREFIX=$PREFIX \
-DCMAKE_INSTALL_LIBDIR=lib \
-DCMAKE_PROGRAM_PATH="$BUILD_PREFIX/bin;$PREFIX/bin" \
-DRust_CARGO_TARGET=${CARGO_BUILD_TARGET}

cd build
ninja install
6 changes: 6 additions & 0 deletions src/internal/id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,12 @@ impl From<SolvableId> for u32 {
#[derive(Copy, Clone, PartialOrd, Ord, Eq, PartialEq, Debug, Hash)]
pub(crate) struct ClauseId(u32);

impl Display for ClauseId {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "ClauseId({})", self.0)
}
}

impl ClauseId {
/// There is a guarentee that ClauseId(0) will always be
/// "Clause::InstallRoot". This assumption is verified by the solver.
Expand Down
32 changes: 31 additions & 1 deletion src/solver/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,24 @@ impl<D: DependencyProvider> SolverCache<D> {
Some(candidates) => Ok(candidates),
None => {
let package_name = self.provider.version_set_name(version_set_id);

tracing::debug!(
"Getting matching candidates for package: {:?}",
package_name
);
let candidates = self.get_or_cache_candidates(package_name).await?;
tracing::debug!("Got {:?} matching candidates", candidates.candidates.len());

let matching_candidates = self
.provider
.filter_candidates(&candidates.candidates, version_set_id, false)
.await;

tracing::debug!(
"Filtered {:?} matching candidates",
matching_candidates.len()
);

Ok(self
.version_set_candidates
.insert(version_set_id, matching_candidates))
Expand All @@ -198,16 +209,30 @@ impl<D: DependencyProvider> SolverCache<D> {
Some(candidates) => Ok(candidates),
None => {
let package_name = self.provider.version_set_name(version_set_id);

tracing::debug!(
"Getting NON-matching candidates for package: {:?}",
package_name
);
let candidates = self.get_or_cache_candidates(package_name).await?;
tracing::debug!(
"Got {:?} NON-matching candidates",
candidates.candidates.len()
);

let matching_candidates = self
let matching_candidates: Vec<SolvableId> = self
.provider
.filter_candidates(&candidates.candidates, version_set_id, true)
.await
.into_iter()
.map(Into::into)
.collect();

tracing::debug!(
"Filtered {:?} matching candidates",
matching_candidates.len()
);

Ok(self
.version_set_inverse_candidates
.insert(version_set_id, matching_candidates))
Expand All @@ -228,6 +253,11 @@ impl<D: DependencyProvider> SolverCache<D> {
Some(candidates) => Ok(candidates),
None => {
let package_name = self.provider.version_set_name(version_set_id);
tracing::debug!(
"Getting sorted matching candidates for package: {:?}",
package_name
);

let matching_candidates = self
.get_or_cache_matching_candidates(version_set_id)
.await?;
Expand Down
39 changes: 17 additions & 22 deletions src/solver/clause.rs
Original file line number Diff line number Diff line change
Expand Up @@ -611,49 +611,44 @@ pub(crate) struct ClauseDisplay<'i, I: Interner> {
impl<'i, I: Interner> Display for ClauseDisplay<'i, I> {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match self.kind {
Clause::InstallRoot => write!(f, "install root"),
Clause::InstallRoot => write!(f, "InstallRoot"),
Clause::Excluded(solvable_id, reason) => {
write!(
f,
"{} excluded because: {}",
solvable_id.display(self.interner),
"Excluded({:?}, {})",
solvable_id,
self.interner.display_string(reason)
)
}
Clause::Learnt(learnt_id) => write!(f, "learnt clause {learnt_id:?}"),
Clause::Learnt(learnt_id) => write!(f, "Learnt({:?})", learnt_id),
Clause::Requires(solvable_id, version_set_id) => {
write!(
f,
"{} requires {} {}",
solvable_id.display(self.interner),
self.interner
.display_name(self.interner.version_set_name(version_set_id)),
"Requires({:?}, {})",
solvable_id,
self.interner.display_version_set(version_set_id)
)
}
Clause::Constrains(s1, s2, version_set_id) => {
write!(
f,
"{} excludes {} by {}",
s1.display(self.interner),
s2.display(self.interner),
self.interner.display_version_set(version_set_id),
"Constrains({:?}, {:?}, {})",
s1,
s2,
self.interner.display_version_set(version_set_id)
)
}
Clause::Lock(locked, forbidden) => {
Clause::ForbidMultipleInstances(s1, s2, name) => {
write!(
f,
"{} is locked, so {} is forbidden",
locked.display(self.interner),
forbidden.display(self.interner),
"ForbidMultipleInstances({:?}, {:?}, {})",
s1,
s2,
self.interner.display_name(name)
)
}
Clause::ForbidMultipleInstances(_, _, name_id) => {
write!(
f,
"only one {} allowed",
self.interner.display_name(name_id)
)
Clause::Lock(locked, other) => {
write!(f, "Lock({:?}, {:?})", locked, other)
}
}
}
Expand Down
Loading

0 comments on commit 2107341

Please sign in to comment.