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

Solver hangs with too many repos #628

Closed
jeroen opened this issue May 8, 2024 · 4 comments
Closed

Solver hangs with too many repos #628

jeroen opened this issue May 8, 2024 · 4 comments
Labels
bug an unexpected problem or unintended behavior

Comments

@jeroen
Copy link
Member

jeroen commented May 8, 2024

As discussed earlier, I run into a problem where the solver hangs if there are too many repos.

> pak::pkg_install('ATACseqQC', dependencies=TRUE)
✔ Updated metadata database: 5.50 MB in 13 files.Updating metadata database ... done
.................... 

Would there be a way to give some hint to pak to prevent the combinatorial explosion in the solver?

One way to reproduce is this container:

docker run --rm -it --env MY_UNIVERSE=https://bioc.r-universe.dev/ --entrypoint=R ghcr.io/r-universe-org/build-wasm:latest

You can also reproduce it with another container running ubuntu:24.04 and setting:

options(repos = c(
    binaries = "https://bioc.r-universe.dev/bin/linux/noble/4.4",
    universe = "https://bioc.r-universe.dev", 
    CRAN = "https://p3m.dev/cran/__linux__/noble/latest",
    BioCsoft = "https://bioconductor.org/packages/3.20/bioc", 
    BioCann = "https://bioconductor.org/packages/3.20/data/annotation",
    BioCexp = "https://bioconductor.org/packages/3.20/data/experiment",
    fallback = "https://cloud.r-project.org", 
    archive = "https://cranhaven.r-universe.dev"
))
@gaborcsardi gaborcsardi added the bug an unexpected problem or unintended behavior label May 8, 2024
@pat-s
Copy link

pat-s commented Sep 3, 2024

I am probably hitting the same issue after adding a cranlike repo with many packages and trying to install a package with a medium to large dep tree.

It works when installing a package without or only a few deps.

There isn't any debug/verbose mode to narrow down what is happening inside the resolver, is it?

@gaborcsardi
Copy link
Member

You can debug the R code as usual (debug(), browser(), etc.), and the the C code as usual, with gdb or lldb.

@jeroen
Copy link
Member Author

jeroen commented Nov 8, 2024

Some notes from the past days:

The problem occurs when there are multiple repos sharing many of the same packages but different versions. In this case the solver will consider each possible combination of package versions, resulting in a combinatorial explosion of solutions.

Hopefully r-lib/pkgdepends#392 relieves most of the problem. This heuristic filters out the older version of two packages, if they share exactly the same dependencies (and therefore the older version is never part of the solution).

Another way to improve the situation is to ensure pak can recognize binary package via a Platform field in the PACKAGES file. Because pak prefers binaries of source packages, this will also reduce the number of potential solutions (this is the reason that CRAN and P3M can be used together without problem).

@gaborcsardi
Copy link
Member

OK, things seem to be working well now, so I'll close this issue, until somebody runs into problems again. For the record, some possible improvements:

  • use a better solver, e.g. highs,
  • expose the timeout argument of lpSolve::lp(),
  • implement a simpler solver that we can try first, which selects the "latest best" version of each package. The problem with this is that it possibly only helps with simple cases, for which the ILP solver is also fast, so we gain nothing in practice.
  • try to auto-detect difficult cases, where many packages have multiple versions available and warn the user about this.

@jeroen jeroen changed the title Resolver hangs with too many repos Solver hangs with too many repos Nov 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

3 participants