Skip to content

Performance regression since 1.0.5 #8637

@mfn

Description

@mfn

Bug Report

Subject Details
Rector version 1.0.5

Runtime of rector did skyrocket with 1.0.5, 1.0.4 was fine.

Before:

 $ time composer rector-tests
> @php vendor/bin/rector process --config=rector-tests.php
 1/1 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%

                                                                                                                        
 [OK] Rector is done!                                                                                                   
                                                                                                                        


real    0m3.728s
user    0m3.077s
sys     0m0.478s

After:

 $ time composer rector-tests
> @php vendor/bin/rector process --config=rector-tests.php
 1/1 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%

                                                                                                                        
 [OK] Rector is done!                                                                                                   
                                                                                                                        


real    0m39.907s
user    0m38.353s
sys     0m0.881s

In both cases I took a single file out of ~3k and just added a blank line.

In both cases it detected correctly only a single modified file, but the execution time is very much different.

Minimal PHP Code Causing Issue

Config(s)
rector-common.php

<?php declare(strict_types = 1);

use Rector\Config\RectorConfig;
use Rector\Php80\Rector\Catch_\RemoveUnusedVariableInCatchRector;
use Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector;
use Rector\Php80\Rector\ClassMethod\AddParamBasedOnParentClassMethodRector;
use Rector\Php80\Rector\FuncCall\ClassOnObjectRector;
use Rector\Php80\Rector\Identical\StrEndsWithRector;
use Rector\Php80\Rector\Identical\StrStartsWithRector;
use Rector\Php80\Rector\NotIdentical\StrContainsRector;
use Rector\Php81\Rector\Array_\FirstClassCallableRector;
use Rector\Php81\Rector\ClassMethod\NewInInitializerRector;

return static function (RectorConfig $rectorConfig): void {
    $rectorConfig->rule(AddParamBasedOnParentClassMethodRector::class);
    $rectorConfig->rule(ClassOnObjectRector::class);
    $rectorConfig->rule(ClassPropertyAssignToConstructorPromotionRector::class);
    $rectorConfig->rule(FirstClassCallableRector::class);
    $rectorConfig->rule(NewInInitializerRector::class);
    $rectorConfig->rule(RemoveUnusedVariableInCatchRector::class);
    $rectorConfig->rule(StrContainsRector::class);
    $rectorConfig->rule(StrEndsWithRector::class);
    $rectorConfig->rule(StrStartsWithRector::class);
};

rector-tests.php

<?php declare(strict_types = 1);

use Rector\Config\RectorConfig;
use Rector\PHPUnit\Set\PHPUnitSetList;

return static function (RectorConfig $rectorConfig): void {
    $rectorConfig->paths([
        __DIR__ . '/tests',
    ]);

    $common = require __DIR__ . '/rector-common.php';
    $common($rectorConfig);

    $rectorConfig->sets([
        PHPUnitSetList::ANNOTATIONS_TO_ATTRIBUTES,
    ]);

    $rectorConfig->importNames();
};

Expected Behaviour

Be as fast as before 😅


I can't share more details, this is a private repo. But let me know if you've any idea what I could test.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions