Skip to content

Investigating PHPStan 1.8 performance #8146

@enumag

Description

@enumag

Bug report

As I mentioned in one thread PHPStan 1.8 seems to be lot slower on my project than version 1.4. Opening this thread to report what I find. Unfortunately since blackfire cancelled their free tier I have no way to investigate in as much detail as I'd like.

Anyway first thing I found is a test class that takes ~25 seconds to analyze. I can't post it publicly but the main issue is likely the two-dimensional associative array in it's @dataProvider function. It looks something like this:

        return [
            'string' => [
                'key' => ValueObject::fromValues(...),
                'key1' => SomeClass::constant
                    && \in_array(
                        AnotherClass::constant,
                        YetAnotherClass::constant,
                        true,
                    ),
                'key2' => SomeClass::constant
                    && \in_array(
                        AnotherClass::constant,
                        YetAnotherClass::constant,
                        true,
                    ),
                'key3' => SomeClass::constant
                    && \in_array(
                        AnotherClass::constant,
                        YetAnotherClass::constant,
                        true,
                    ),
                'key4' => SomeClass::constant
                    && \in_array(
                        AnotherClass::constant,
                        YetAnotherClass::constant,
                        true,
                    ),
                'key5' => SomeClass::constant
                    && \in_array(
                        AnotherClass::constant,
                        YetAnotherClass::constant,
                        true,
                    ),
            ],
            // ... several more arrays like that
        ];

I can sen you the class privately if needed.


Another thing that is really slow is analysis of Doctrine entities. However in this case I assume it's because a custom rule which was loading Doctrine annotations in an inefficient way so I'm trying to optimize that first before making conclusions. See #8144


Aside from that it mostly seems to be a slowdown in general. I'd like to do a comparison of what classes took longer than on the previous version. I'll write a parser for the --debug -vvv results to make it a json instead so that I can compare what classes are taking longer now compared to the old version.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions