jhawthorn / pub_grub

🍔 A ruby implementation of the PubGrub CDCL-based version solver
MIT License
151 stars 11 forks source link

Add a proper constraint equality #21

Closed deivid-rodriguez closed 1 year ago

deivid-rodriguez commented 1 year ago

This is not a problem in PubGrub itself, but it should make custom integrations with PubGrub better.

While debugging some issues in Bundler, I noticed from pub_grub's debug logs, that incompatibility constraints didn't seem to be merged correctly when across versions with the same dependencies. Since I was seeing output like this:

derived: not autobuild >= 1.10.0.b4, < 1.10.0.rc1
derived: not autobuild >= 1.10.0.rc1, < 1.10.0.rc2
derived: not autobuild >= 1.10.0.rc2, < 1.10.0.rc3
derived: not autobuild >= 1.10.0.rc3, < 1.10.0.rc4
derived: not autobuild >= 1.10.0.rc4, < 1.10.0.rc5
derived: not autobuild >= 1.10.0.rc5, < 1.10.0.rc6
derived: not autobuild >= 1.10.0.rc6, < 1.10.0.rc7
derived: not autobuild >= 1.10.0.rc7, < 1.10.0.rc8
derived: not autobuild >= 1.10.0.rc8, < 1.10.0.rc9

Ended up noticing that in our custom package class in Bundler, which does not inherit from BasicPackageSource in pub_grub, we're comparing VersionConstraints instead of comparing strings like BasicPackageSource.

I could've probably fixed this in Bundler, but I think implementing a proper equality here is good thing.

This change speeds up resolution on this realworld gemfile from the Nix project from ~7 minutes to ~30 seconds on my laptop.

indirect commented 1 year ago

lol oops meant to approve the Bundler PR for the same diff 🤦🏻 well, awesome either way.

deivid-rodriguez commented 1 year ago

Merging since we shipped this in Bundler already.