DEVSENSE / phptools-docs

PHP Tools public content
Apache License 2.0
82 stars 10 forks source link

Excesive CPU Usage #705

Open navarro41yt opened 1 month ago

navarro41yt commented 1 month ago

I use this extension (free version) for all my open php projects. One day ago I got an issue, my CPU was 100% workload. When I opened the Task Manager there it was, devsense.php.ls consuming nearly the 100% of the CPU.

I didn't encounter a solution so y ended up using other extensions. Finally i returned to this extension and everything looked good, but in 1 file the process would go to 100% and make impossible to program.

I ended up finding what causes this error: Imagine you have this heredoc (ignore the names):

$html = <<<HTML
    {$this->getSelect($this->x->a,'A',MyClass::CONSTANT_A,isRequired: true)}
    {$this->getSelect($this->x->b,'B',MyClass::CONSTANT_B,isRequired: true)}
    {$this->getSelect($this->x->c,'C',MyClass::CONSTANT_C,isRequired: true)}
    {$this->getSelect($this->x->d,'D',MyClass::CONSTANT_D,isRequired: false)}
HTML;

This won't make the process go to 100% but this:

$html = <<<HTML
    {$this->getSelect(
        $this->x->a,
        'A',
        MyClass::CONSTANT_A,
        isRequired: true)}
    {$this->getSelect(
        $this->x->b,
        'B',
        MyClass::CONSTANT_B,
        isRequired: true)}
    {$this->getSelect(
        $this->x->c,
        'C',
        MyClass::CONSTANT_C,
        isRequired: true)}
    {$this->getSelect(
        $this->x->d,
        'D',
        MyClass::CONSTANT_D,
        isRequired: false)}
HTML;

This will make the process go in a loop

I have nothing more to say, if you're reading this because your devsense.php.ls is at 100% load you can "fix" it this way, although your method will be larger.

jakubmisek commented 1 month ago

Thank you for digging into it.

Sadly it's not happening to me with this code :/

markovicdenis commented 2 weeks ago

In my case, after restarting extension host for whatever reason one core of vscode plugin hosts keeps 100% forever. Very annoying, tbh.

EDIT: seems not to be related to php tools, sorry for false positive (turns out it was the phpstan vscode extension, swordev/phpstan)

jakubmisek commented 2 weeks ago

Have you seen what's the name of the process causing it?

angus-mcritchie commented 4 days ago

I'm also experiencing this issue, which seems related to the devsense.php.ls command.

It essentially makes my VS Code unusable, as the PHP IntelliSense freezes. I cannot navigate to files through Ctrl + click, and there is no auto-completion.

Most of the time, it sits at 99 or 100%, but everything still works as expected. But a few times a day, it jumps to a crazy high CPU usage, like 1,300%+, as below.

Output of sudo htop

image

It's hard to pinpoint what is causing the issue, e.g. a specific piece of code, the number of files open, etc. What are your recommended steps to help troubleshoot this, @jakubmisek ?