mamba-org / mamba

The Fast Cross-Platform Package Manager
https://mamba.readthedocs.io
BSD 3-Clause "New" or "Revised" License
6.89k stars 353 forks source link

RFC — Towards a new solver for `libmamba` #3387

Open jjerphan opened 3 months ago

jjerphan commented 3 months ago

Context

libsolv has been used since the creation of mamba.

While libsolv is a fundamental dependency of libmamba, its maintenance comes with challenges for mamba but also for conda-forge generally (for instance, see https://github.com/conda-forge/libsolv-feedstock/issues/92 and https://github.com/conda-forge/openmpi-feedstock/issues/153).

[!NOTE]
For more context, see those notes.

Proposed solution

Based on a POC, which shows that resolvo have more or less the same performance as libsolv.

Proposed plan

[!NOTE]
This plan gives the general direction but is not exhaustive. It might evolve overtime.

Architecture redesign: inheriting classes

Motivation:

Schematically, currently we have:

before

Then we would have: after

In this order:

Alternative solver

Hind-M commented 3 months ago

The general plan seems legit broadly speaking.

jjerphan commented 3 months ago

Regarding the Database, we could use a base class as you suggested, or try and isolate the parts specific to libsolv in a specific class to use inside Database (because resolvo's API could be very different) but at least Database is already connected to the rest of mamba and hopefully we won't need to change much.

I should have mentioned that resolvo's public API exposes a DependencyProvider (similar to a Database) and a Solver. Based on the initial POC, I am quite confident that we could have similar abstractions for resolvo.

Most of the design points are mostly based on the assumption that introducing bases classes is the right pathway and that the current other abstractions than Database and Solver can be decoupled from libsolv, but we need to validate that this is the right approach (I am pretty sure there are other designs which would avoid having a set of base classes and solver-specific sets of concrete classes).


Edit: For alternatives, I wonder whether template classes with a common template type parameter for the solver could help.

JohanMabille commented 1 month ago

The overall plan looks good, I have some minor concerns, partially because I don't know very well this part of mamba (so some of my concerns might be irrelevant or redundant):

jjerphan commented 1 month ago
  1. IIRC, resolvo does not have the equivalent of a RepoInfo
  2. This was started on this branch: https://github.com/jjerphan/mamba/tree/alt-solver
  3. Resolvo exposes a DependencyProvider, which can be implemented to have something close to a DataBase but the RepoInfo isn't actually totally decoupled. My intuition is that it will be decoupleable.
  4. For virtuality, yes. Migrating to C++20 is not trivial because bits of the std have been removed in this last version of C++.
  5. Yes, we need to think about this together. I am wondering how to best adapt the Python API, then.