1
0
Fork 0
composer/tests/Composer/Test
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
2017-02-20 18:52:17 +00:00
..
Autoload Merge remote-tracking branch 'nicolas-grekas/apcu' 2016-12-07 00:21:13 +01:00
Command Add tests 2016-09-12 17:20:58 +02:00
Config CS fixes 2016-01-26 13:07:18 +00:00
Console Support bg colors and more clearing values in html output formatter 2015-06-12 17:23:18 +01:00
DependencyResolver Improve memory usage resolving dependencies 2017-02-20 18:52:17 +00:00
Downloader Properly fix git excludes. 2016-12-24 03:19:50 +03:00
EventDispatcher Merge branch '1.2' 2016-12-06 17:04:39 +01:00
Fixtures Fix git shortening, it is sunday.. 2016-12-11 17:04:24 +01:00
IO Fix tests 2016-02-29 15:50:04 +00:00
Installer Make sure we do not overwrite binaries but only re-create missing ones, refs #5127 2016-07-02 16:35:09 +01:00
Json Resolve references in ComposerSchemaTest 2017-01-03 11:57:35 +01:00
Mock Set xdebug version in environment, fixes #5967 2016-12-15 21:20:41 +00:00
Package Add ignore filters option to archive command 2017-01-11 16:21:44 -06:00
Plugin Add test case for strict types declaration 2016-06-01 10:00:37 +02:00
Repository Fix urlencoding of gitlab dots, fixes #6064 2017-01-27 18:01:24 +01:00
Util Merge branch '1.2' 2016-12-06 17:04:39 +01:00
AllFunctionalTest.php Fix support for testing exit code 2016-08-15 00:30:20 -04:00
ApplicationTest.php Fix tests 2016-07-12 17:12:50 +01:00
CacheTest.php try to use unique test directories 2016-01-26 09:41:21 +01:00
ComposerTest.php Fail over from source to dist and vice versa when downloads fail 2014-02-24 18:40:33 +01:00
ConfigTest.php Fix tests 2016-11-30 23:56:43 +01:00
DefaultConfigTest.php CS fixes 2016-01-26 13:07:18 +00:00
InstallerTest.php Use unique cache dir for integration tests as well 2016-04-01 12:07:42 +01:00
XdebugHandlerTest.php Clear xdebug version if restart fails, fixes #5995 2016-12-27 18:46:21 +00:00