Skip to content

Rector caching and large code bases #7806

@keulinho

Description

@keulinho

Question

We have a codebase with >7.000 files and want to run rector continuously in the CI to enforce a common code style, catch errors etc.

What should an optimal setup for rector look like? We are currently running in a lot of issues mostly regarding performance, memory usage and caching.

For example it is not possible to run rector on the whole code base at once on a local machine with 32GB RAM, as it will run out of memory during the run.

Our first idea was to run rector on separate sub folders and only run it on 1.000-1.500 classes at once, then at least the commands succeed and are not running out of memory. But with that approach we got problems as the order of the runs seems to change the results, e.g. if i execute rector first on the src/Framework folder and then on the tests folder rector does not find any issues, but if clear the cache and change the order to let it run first on the tests folder it suddenly finds 2 issues.
So it seems like the caching is not relyably working, but on the other hand dissable caching completely is also not a good solution as a full run on >7.000 files takes a long time to complete on a local machine.

Has anyone experienced something similiar? Is there anything that we are missing?
How do you setup rector in bigger projects?

Our current rule config looks like this:

    $rectorConfig->sets([
        LevelSetList::UP_TO_PHP_81,
        SymfonyLevelSetList::UP_TO_SYMFONY_62,
        TwigLevelSetList::UP_TO_TWIG_240,
        PHPUnitLevelSetList::UP_TO_PHPUNIT_90,
    ]);

Thanks 💙

Thanks for creating rector it already helped us a ton in upgrading to new library/php versions ✌️

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions