168 Commits (c66bb0b1d06454cb73e6cd65b6be470417fae5ff)

Author SHA1 Message Date
Nils Adermann 6b2edeae56 Fix solver problem exceptions with unexpected contradictory "Conclusions"
This 5 character fix comes with a solver test as well as a functional
installer test essentially verifying the same thing. The solver test is
more useful when working on the solver. But the functional test is less
likely to be accidentally modified incorrectly during refactoring, as
every single package, version and link in the rather complex test
scenario is essential, and a modified version of the test may very well
still result in a successful installation but no longer verify the bug
described below.

Background:

In commit 451bab1c2c from May 19, 2012 I
refactored literals from complex objects into pure integers to reduce
memory consumption. The absolute value of an integer literal is the id
of the package it refers to in the package pool. The sign indicates
whether the package should be installed (positive) or removed (negative),

So a major part of the refactoring was swapping this call:

$literal->getPackageId()

For this:

abs($literal)

Unintentionally in line 554/523 I incorrectly applied this change to the
line:

$this->literalFromId(-$literal->getPackageId());

It was converted to:

-abs($literal);

The function literalFromId used to create a new literal object. By using
the abs() function this change essentially forces the resulting literal
to be negative, while the minus sign previously inverted the literal, so
positive into negative and vice versa.

This particular line is in a function meant to analyze a conflicting
decision during dependency resolution and to draw a conclusion from it,
then revert the state of the solver to an earlier position, and attempt
to solve the rest of the rules again with this new "learned" conclusion.

Because of this bug these conclusions could only ever occur in the
negative, e.g. "don't install package X". This is by far the most likely
scenario when the solver reaches this particular line, but there are
exceptions.

If you experienced a solver problem description that contained a
statement like "Conclusion: don't install vendor/package 1.2.3" which
directly contradicted other statements listed as part of the problem,
this could likely have been the cause.
6 years ago
Rob 7079cdb70d
Merge pull request #7458 from staabm/patch-3
Define variable only when actually used
6 years ago
Markus Staab 86d5de2965
Define variable only when actually used 6 years ago
Markus Staab 42516901f1
Removed another unnecessary abs() call 6 years ago
Markus Staab 0e16dbabde
Removed another unnecessary abs() call 6 years ago
Markus Staab e3a23f4ae6
Remove unnecessary abs() calls
Literal cannot be negative at this point
6 years ago
Yanick Witschi d82bdc04ac Improved debugging output 6 years ago
Yanick Witschi 5435877bd9 Improve SAT resolving developer debug information 6 years ago
Gabriel Caruso 3d262bd637 Fixes from PHPStan level 0
More fixes from PHPStan level 0
7 years ago
Jordi Boggiano 122e422682 CS fixes 8 years ago
rubenrua 4e1887a721 Improve memory usage resolving dependencies
It is known that composer update takes a lot of memory: #5915, #5902,

I am playing with a profiler (@blackfireio) to make a demo in my local
PHP meetup (@phpvigo) and I found out a way to use less memory. These
are my first tests:

* Private project using PHP 5.6:
  * Memory: from 1.31GB to 1.07GB
  * Wall Time: from 2min 8s to 1min 33s

* symfony-demo using PHP 7.1 in my old mac book:
  * Memory: from 667MB to 523MB
  * Wall Time: from  5min 29s to 5min 28s

Not use an array inside conflict rules is this improvement main idea:

```php
<?php
//Memory 38MB
gc_collect_cycles();
gc_disable();

class Rule
{
    public $literals;

    public function __construct(array $literals)
    {
        $this->literals = $literals;
    }
}

$rules = array();

$i = 0;
while ($i<80000){ //
    $i++;

    $array = array(-$i, $i);
    $rule = new Rule($array);
    $rules[] = $rule;
}
```

```php
<?php
//Memory 11.1MB
gc_collect_cycles();
gc_disable();

class Rule2Literals
{
    public $literal1;
    public $literal2;

    public function __construct($literal1, $literal2)
    {
        $this->literal1 = $literal1;
        $this->literal2 = $literal2;
    }
}

$rules = array();

$i = 0;
while ($i<80000){ //
    $i++;

    $rule = new ConflictRule(-$i, $i);
    $rules[] = $rule;
}
```

More info https://github.com/composer/composer/pull/6168
8 years ago
Nicolas Grekas daf84bea33 Enhance solver perf by removing count() 8 years ago
Niels Keurentjes 8e78ce9a43 Add extra logging before and after SAT solving 9 years ago
Niels Keurentjes b059cbe37c Removed unused variables and includes, fixed functions being called with more arguments than declared. 9 years ago
Rob Bast 1c7016de45 remove dead code/class 9 years ago
Rob Bast 1bf03e9621 fixed various docblocks and class properties in solver 9 years ago
Rob Bast b523fc0b7b ran fixers 9 years ago
Jordi Boggiano ce08582671 Fix CS 9 years ago
Nils Adermann 6e81f63635 Reduce memory footprint of rules by storing data in blob
Not declaring the job property saves significant amounts of memory as
most rules leave it as null
9 years ago
Nils Adermann 5b1b96b61e Output the number of rules used in the solver for profiling purposes 9 years ago
Nils Adermann 75c501251d Revert "Merge remote-tracking branch 'naderman/load-no-providers'"
This reverts commit 3e85f82373, reversing
changes made to b025d0982b.
9 years ago
Nils Adermann ec5416f03c loadDev parameter is nonsense, properly load packages in create command 10 years ago
Nils Adermann da02c53540 Update the composer repository whatprovides test to a loadrecursively test 10 years ago
Nils Adermann 090711b21c Completely move loading of packages from composer repo to pool 10 years ago
Nils Adermann 4d0db5add6 POC Implementation of loading only explicitly named package data 10 years ago
isoroku e0657b60a2 Fix misspellings 10 years ago
Vladimir Kartaviy 813fd0b703 Added missing $learnedWhy property 10 years ago
Nils Adermann 26598c4a9a Remove unnecessary pool reference from rules 10 years ago
Nils Adermann d77400ade2 Make ruleById lookup table in rule set public
Saves about 500k function calls on a packagist update
10 years ago
Nils Adermann c6af09b1da Make project id public
Reduction of rougly 1.3 million function calls on packagist update
10 years ago
Nils Adermann ef41f136f8 Literals on rule are now public
This causes a reduction of ~500k function calls for packagist composer
update (~14 million total).
10 years ago
Jordi Boggiano 94926218e8 CS fixes 10 years ago
Jordi Boggiano ec0463a400 Add tests for platform packages required by root and avoid creating rules altogether instead of disabling them, refs #3320 10 years ago
alu b7fa302b90 add ignore-platform-package-requirements for update/install commands. 10 years ago
Jordi Boggiano e23665be59 Fix replacers being picked if whatProvide was called before building the package whitelist, fixes #2991, fixes #2962 11 years ago
Nils Adermann 5b80144ad0 Resolve job packages after whitelist generation 11 years ago
Jordi Boggiano 0a3df27403 Remove dead code, fixes #2363 11 years ago
Jordi Boggiano 0700cd9186 Adjust according to feedback 12 years ago
Jordi Boggiano db4055b778 Put a higher prio on replacers of the same vendor as the required package 12 years ago
Jordi Boggiano 514a3cde77 CS fixes 12 years ago
Jordi Boggiano 5d78fa6ce6 Report typos in package name if no version matches 12 years ago
Pascal Borreli 83fd3967f0 Fixed PHPDoc 12 years ago
Pascal Borreli 5eead93250 Fixed typos 12 years ago
Jordi Boggiano 6a03e4f9ac Code optimizations: Avoiding counting repeatedly 12 years ago
Nils Adermann 27d8904abe resetToOffset method was moved to the Decisions class a while ago 12 years ago
Jordi Boggiano ef637c8f1a CS fixes 12 years ago
Adrien Brault 4263fe9255 Fix Solver CS 12 years ago
Nils Adermann cc7632489d Make problem report messages more readable
Added pretty strings to constraints
12 years ago
Nils Adermann 12abff8b4c Simplify branch handling code 12 years ago
Nils Adermann 5b1a48663e DecisionQueueFree is no longer needed 12 years ago