You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
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
7 years ago
..
Autoload Merge remote-tracking branch 'nicolas-grekas/apcu' 8 years ago
Command Add tests 8 years ago
Config CS fixes 9 years ago
Console Support bg colors and more clearing values in html output formatter 9 years ago
DependencyResolver Improve memory usage resolving dependencies 7 years ago
Downloader Properly fix git excludes. 8 years ago
EventDispatcher Merge branch '1.2' 8 years ago
Fixtures Fix git shortening, it is sunday.. 8 years ago
IO Fix tests 8 years ago
Installer Make sure we do not overwrite binaries but only re-create missing ones, refs #5127 8 years ago
Json Resolve references in ComposerSchemaTest 8 years ago
Mock Set xdebug version in environment, fixes #5967 8 years ago
Package Add ignore filters option to archive command 8 years ago
Plugin Add test case for strict types declaration 8 years ago
Repository Fix urlencoding of gitlab dots, fixes #6064 8 years ago
Util Merge branch '1.2' 8 years ago
AllFunctionalTest.php Fix support for testing exit code 8 years ago
ApplicationTest.php Fix tests 8 years ago
CacheTest.php try to use unique test directories 9 years ago
ComposerTest.php Fail over from source to dist and vice versa when downloads fail 11 years ago
ConfigTest.php Fix tests 8 years ago
DefaultConfigTest.php CS fixes 9 years ago
InstallerTest.php Use unique cache dir for integration tests as well 8 years ago
XdebugHandlerTest.php Clear xdebug version if restart fails, fixes #5995 8 years ago