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

[PoolOptimizer] Improve performance of keep package #10546

Closed
wants to merge 2 commits into from

Conversation

Toflar
Copy link
Contributor

@Toflar Toflar commented Feb 18, 2022

This branch is based on #10545 (I'll rebase once it's merged).

I can consistently save like 1.5 - 2 seconds of the pool optimizer working thanks to this super simple change 🙈

@@ -339,6 +339,11 @@ private function markPackageForRemoval($id)
*/
private function keepPackage(BasePackage $package, $identicalDefinitionsPerPackage, $packageIdenticalDefinitionLookup)
{
// Already marked to keep
if (!isset($this->packagesToRemove[$package->id])) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO this should use array_key_exists instead.

But maybe just personal preference :-)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isset is faster AFAIK as it's not a function, but as per https://gist.github.com/alcaeus/536156663fac96744eba77b3e133e50a it seems the PHP 8 benchmarks have them pretty much equal. But anyway I am happy with isset here.

@Seldaek
Copy link
Member

Seldaek commented Feb 19, 2022

Makes a lot of sense :) Please rebase on 2.2 I guess it doesn't hurt to get that in there, as it's such a small change.

@Seldaek Seldaek added this to the 2.2 milestone Feb 19, 2022
@Seldaek Seldaek added the Solver label Feb 19, 2022
@Seldaek
Copy link
Member

Seldaek commented Feb 25, 2022

Merged in 2.2 as 8179d1e

@Seldaek Seldaek closed this Feb 25, 2022
@Toflar Toflar deleted the improve-keep-package branch February 25, 2022 10:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants