-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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
fix: Do not optimise away packages due to a requirement by a locked package that will be uninstalled #10405
fix: Do not optimise away packages due to a requirement by a locked package that will be uninstalled #10405
Conversation
808aa03
to
e8a3d3b
Compare
Benchmarks. Using same as #9620, starting with https://github.com/drupal/recommended-project/blob/8.9.x/composer.json
I did above to warm cache and then repeated the require:1.0.0, nano and update to get results below. I am on a laptop, MacBook Pro though, so there's variances...
Below is 2.2.1 stable without the fix, it looks slower but it's probably pretty much the same nearly and only minuscule change and the variance I put down to me testing it with a laptop.
Finally, when running latest main and disabling the optimisation, to ensure it is still beneficial, results show hopeful still as the rule count is massively increased without this. Granted the time saving does seem to be small still but this is a test with a single drupal module only.
|
...r/Test/DependencyResolver/Fixtures/poolbuilder/filter-impossible-oackages-only-required.test
Outdated
Show resolved
Hide resolved
614224a
to
4ca82b3
Compare
…ackage that will be uninstalled Fixes composer#10394
4ca82b3
to
f572c9f
Compare
@Seldaek The current set of comments I implemented, and the fixed test is properly reproducing again - no idea how I missed that test issue 😞 I will just double confirm that the scenario in the original issue is resolved still. |
Yes, this resolved the repository example in the original issue. |
Great, thanks, will review again when I get a chance. |
Think this may also need tests for similar situations with replace/provide to make sure it works correctly in that case? |
…, including scenarios not yet optimised
I added some tests for both those scenarios. Currently the scenarios for replace/provide are not optimised for so I tried to note that in the test. It at least means we can check that it is behaving as expected currently and if optimisation is added down the line for provide/replace the test can be updated accordingly. It's worth noting... whilst doing these tests I noticed that "allowTransitiveDeps" doesn't work for providers. If the provider is a root requirement and is not in the "allowList", and so attempts to update a package that requires the provided package will not unlock the provider. Not sure if this is intentional...? |
This is intentional yes, as many things can provide a package, unlocking these was getting messy and we weren't sure if it would be expected anyway, so we decided to leave it as is. Thanks for the updates, I'll try and review this before 2.2.3 goes out. |
…placed name does filter its dependencies, and fix logic accordingly
7feb798
to
6540b46
Compare
OK turns out the name checking logic was inverted, so it would have broken if something had a replace which was not required by anything, as it would have found name not set in $this->requireConstraintsPerPackage, and it should only ignore if none of the names are referenced, not if any of them is. Fixed that and added an additional test which was breaking before (although it covers the opposite case, a replacer required by the name it replaces but not by its own name, but it's the same problem really). Otherwise looks good to me, thanks! |
Thank you all for all your work on this. I have tested the situations in which I ran across the issue and all look to be fixed, so 🎉 |
Fixes #10394, introduced by #9620
As explained in that issue when I did the optimisation to filter out packages from the pool that would ultimately never be installed due to a locked packages requirements, I hadn't considered that when packages are removed... they may still be in the set of locked packages.
This PR updates the optimisation to ignore any locked package which isn't required by any package in the pool - as that will, as I understand, mean the package is going to be removed and it's requirements will be moot. I have considered the case where a package IS required somewhere in the pool, or even an older version for example, and in those cases the package would have been unlocked when using
-W
anyway. So I believe this is the correct fix.I tested it against the scenario in #10394 and when running the second command in the following set:
You then get an error about PHPUnit is locked.
When then running the second command with
-W
then before this fix (2.2.1), you get the following:With this PR merged it is now successful.
I will run the same timing/memory tests I did with the original PR to make sure the update is not making the optimisation useless...
@Seldaek thanks for bringing it to my attention - this will definitely need scrutiny to make sure the approach is right!