composer / semver

Semantic versioning utilities with the addition of version constraints parsing and checking.
MIT License
3.15k stars 76 forks source link

Create smarter constraints #31

Closed Seldaek closed 8 years ago

Seldaek commented 8 years ago

Not sure if feasible at all nor how easy or efficient it would be, but I think it'd be worth investigating if we can turn ^1.0|^2.0 into >=1.0 && <3.0-dev when parsing constraints. Basically merge contiguous ORs into one bigger OR. It'd make things more efficient when comparing but obviously it shouldn't take 10x longer to generate or it'll offset the gains.

stof commented 8 years ago

is this actually a bottleneck when resolving the dependencies ?

Btw, there is some discussion about this in https://github.com/Roave/SecurityAdvisories/issues/21 where the builder already merges overlapping ranges but not yet consecutive ranges (but perf is OK there, as this is running in the builder, not for people using the package)

Seldaek commented 8 years ago

I don't know what the gain would be to be honest, just an idea as we see more and more of these crop up for things like symfony3 support or php7 (although there due to the jump from 5 to 7 this trick won't help..).

stof commented 8 years ago

@Seldaek I suggest profiling first, to know whether this impacts the resolution a lots. You could create a repository with packages using constraints like ^1.0|^2.0 and another repository containing the same packages but with >=1.0 && <3.0-dev. Then, if it has a significant impact on dependency resolution, it might be worth trying to automate this merging of constraint and see whether it takes more time than the gain or no. But if the solver gains are not significant, there is no need to spend time implementing a constraint merger, which would add overhead

Seldaek commented 8 years ago

Yup I fully agree. I just wrote it down because I thought of it and I'm trying to reduce the amount of random stuff I have in local TODOs vs public issue trackers. Don't have time to investigate now, but if anyone wants to run with it that's great!

Seldaek commented 8 years ago

Fixed by #33