Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prefer solving for explicitly required dependencies first #60

Closed
baszalmstra opened this issue Aug 6, 2024 · 7 comments · Fixed by #61
Closed

Prefer solving for explicitly required dependencies first #60

baszalmstra opened this issue Aug 6, 2024 · 7 comments · Fixed by #61

Comments

@baszalmstra
Copy link
Contributor

In prefix-dev/pixi#1708 it was noted that the solver does not prefer selecting explicitly requested packages. We should experiment with whether adding that to the decision heuristic is possible and doesn't affect performance too badly.

My idea would be to prefer deciding on explicitly required dependencies first before considering transitive dependencies.

@jjerphan @wolfv Do you have thoughts? Have you experimented with this before?

@baszalmstra baszalmstra changed the title Prefer solving for direct dependencies first Prefer solving for explicitly required dependencies first Aug 6, 2024
@traversaro
Copy link
Member

To provide a bit more context from prefix-dev/pixi#1708 : I guess this could be a point of confusion for people migrating from conda, where (if I am not wrong) this is taked into account.

@jjerphan
Copy link
Member

jjerphan commented Aug 6, 2024

Thank you for opening the discussion.

I have not explored it yet, but I think it is worth it.

@jaimergp
Copy link

We do this in conda-libmamba-solver already, to an extent. See how we sort specs being passed to libsolv at https://github.com/conda/conda-libmamba-solver/blob/65788b94f161ace961bcfefe3d8c6cb17c6b0851/conda_libmamba_solver/state.py#L501-L524

@jjerphan
Copy link
Member

jjerphan commented Aug 12, 2024

How about tackling conda/conda#13861 first or in parallel?

@jjerphan
Copy link
Member

jjerphan commented Aug 12, 2024

Similarly to conda as pointed out by Jaime in #60 (comment), mamba defines a custom comparable to sort MatchSpecs before solving the problems

@baszalmstra
Copy link
Contributor Author

We do this in conda-libmamba-solver already, to an extent. See how we sort specs being passed to libsolv at conda/conda-libmamba-solver@65788b9/conda_libmamba_solver/state.py#L501-L524

This only works because to my knowledge libsolv does not implement a heuristic to determine which requirements to visit first. So the order in which the requirements are passed in is also the order in which libsolve will try to solve the problem.

Resolvo is different in that it can decide to reorder the requirements to solve first based on heuristics. This can drastically speed it up. However, it also means that it might decide to solve a requirement that was provided by the user after first solving for a transitive dependency. The order in which the requirements are provided also doesn't matter (not entirely true but in practice it is).

With #61 , requirements that are requested directly by the user are prioritized over other requirements this has the benefit that user requests are maximized over transitive dependencies. But the input order of requirements is still relatively unimportant.

How about tackling conda/conda#13861 first or in parallel?

We can do this in parallel I think. I still have to measure the performance impact of #61 properly but other than that I dont see any other negative side effects.

@traversaro
Copy link
Member

Thanks @baszalmstra !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants