Skip to content

Commit fd71135

Browse files
wolfvtdejager
andcommitted
try async resolvo
Co-Authored-By: Tim de Jager <tim@prefix.dev>
1 parent b5a1bd0 commit fd71135

File tree

4 files changed

+26
-6
lines changed

4 files changed

+26
-6
lines changed

Cargo.toml

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[workspace]
22
members = ["crates/*"]
3+
resolver = "2"
34

45
# See: https://docs.rs/insta/latest/insta/#optional-faster-runs
56
[profile.dev.package.insta]
@@ -144,3 +145,6 @@ walkdir = "2.4.0"
144145
windows-sys = { version = "0.52.0", default-features = false }
145146
zip = { version = "0.6.6", default-features = false }
146147
zstd = { version = "0.13.0", default-features = false }
148+
149+
[patch.crates-io]
150+
resolvo = { git = "https://github.com/aochagavia/resolvo.git", branch = "concurrent-metadata-fetching" }

crates/rattler_solve/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ hex = { workspace = true }
2525
tempfile = { workspace = true }
2626
rattler_libsolv_c = { workspace = true, optional = true }
2727
resolvo = { workspace = true, optional = true }
28+
tokio = { workspace = true, optional = true }
29+
futures = { workspace = true, optional = true }
2830

2931
[dev-dependencies]
3032
criterion = { workspace = true }
@@ -41,6 +43,7 @@ url = { workspace = true }
4143
[features]
4244
default = ["libsolv_c"]
4345
libsolv_c = ["rattler_libsolv_c", "libc"]
46+
resolvo = ["dep:resolvo", "dep:tokio", "dep:futures"]
4447

4548
[[bench]]
4649
name = "bench"

crates/rattler_solve/src/resolvo/conda_util.rs

+18-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
use crate::resolvo::{CondaDependencyProvider, SolverMatchSpec};
2+
use futures::future::FutureExt;
23
use rattler_conda_types::Version;
34
use resolvo::{Dependencies, SolvableId, SolverCache, VersionSetId};
45
use std::cmp::Ordering;
56
use std::collections::HashMap;
6-
77
/// Returns the order of two candidates based on the order used by conda.
88
#[allow(clippy::too_many_arguments)]
99
pub(super) fn compare_candidates<'a>(
@@ -47,11 +47,19 @@ pub(super) fn compare_candidates<'a>(
4747
Ordering::Equal => {}
4848
};
4949

50+
// return Ordering::Equal;
51+
5052
// Otherwise, compare the dependencies of the variants. If there are similar
5153
// dependencies select the variant that selects the highest version of the dependency.
5254
let (a_dependencies, b_dependencies) = match (
53-
solver.get_or_cache_dependencies(a),
54-
solver.get_or_cache_dependencies(b),
55+
solver
56+
.get_or_cache_dependencies(a)
57+
.now_or_never()
58+
.expect("get_or_cache_dependencies failed"),
59+
solver
60+
.get_or_cache_dependencies(b)
61+
.now_or_never()
62+
.expect("get_or_cache_dependencies failed"),
5563
) {
5664
(Ok(a_deps), Ok(b_deps)) => (a_deps, b_deps),
5765
// If either call fails, it's likely due to solver cancellation; thus, we can't compare dependencies
@@ -147,7 +155,10 @@ pub(super) fn find_highest_version<'a>(
147155
match_spec_highest_version
148156
.entry(match_spec_id)
149157
.or_insert_with(|| {
150-
let candidates = solver.get_or_cache_matching_candidates(match_spec_id);
158+
let candidates = solver
159+
.get_or_cache_matching_candidates(match_spec_id)
160+
.now_or_never()
161+
.expect("get_or_cache_matching_candidates failed");
151162

152163
// Err only happens on cancellation, so we will not continue anyways
153164
let candidates = if let Ok(candidates) = candidates {
@@ -156,9 +167,11 @@ pub(super) fn find_highest_version<'a>(
156167
return None;
157168
};
158169

170+
let pool = solver.pool();
171+
159172
candidates
160173
.iter()
161-
.map(|id| solver.pool().resolve_solvable(*id).inner())
174+
.map(|id| pool.resolve_solvable(*id).inner())
162175
.fold(None, |init, record| {
163176
Some(init.map_or_else(
164177
|| {

rust-toolchain

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.70.0
1+
1.75.0

0 commit comments

Comments
 (0)