laravel-idea / plugin

Laravel Idea plugin for PhpStorm
https://laravel-idea.com/
176 stars 7 forks source link

[Bug]: PhpStorm CPU Usage ranges from 100% to 500% with paid version #623

Closed jaygoodswp closed 10 months ago

jaygoodswp commented 2 years ago

Bug description

I have the paid version of Laravel Idea and with the plugin enabled, PhpStorm uses an insane amount of CPU time. My fans were at max speed all day yesterday. This morning, after disabling many plugins, I came across this one and disabled it and that fixed the issue. If it were a free plugin, then I wouldn't complain and would find something else but I've paid for a license. This started after updating PhpStorm to 2022.2.1 and then updating all of my plugins (Update All in Preferences / Plugins).

Plugin version

5.7.3.221

Operating system

MacOS

Steps to reproduce

Enable the plugin and open a Laravel project.

Relevant log output

Here is a link to a zip file containing all of the info I could get out of PhpStorm.

https://drive.google.com/file/d/1riT9JdhYPJhPPddbNk-3Owo8Ql4KTDXi/view?usp=sharing
olivernybroe commented 2 years ago

Do you perhaps have any other laravel plugins installed? They can sometimes collide in weird ways.

jaygoodswp commented 2 years ago

I disabled most of the plugins, except for Javascript and PHP. Do the logs that I sent show anything useful?

From: Oliver Nybroe @.> Date: Friday, September 2, 2022 at 8:14 AM To: laravel-idea/plugin @.> Cc: jay goodswp.com @.>, Author @.> Subject: Re: [laravel-idea/plugin] [Bug]: PhpStorm CPU Usage ranges from 100% to 500% with paid version (Issue #623)

Do you perhaps have any other laravel plugins installed? They can sometimes collide in weird ways.

— Reply to this email directly, view it on GitHubhttps://github.com/laravel-idea/plugin/issues/623#issuecomment-1235491317, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACJWPNAOEQ5RZA77B2CJA4TV4H4RFANCNFSM6AAAAAAQBQXTIY. You are receiving this because you authored the thread.Message ID: @.***>

jaygoodswp commented 2 years ago

Alright, so I disabled all plugins, except for Laravel Idea, and then re-enabled the ones I needed one at a time. I'm sure I'm missing some functionality but for now, the CPU usage is not spiking. I'll look each time I enable a plugin and try to report back if the symptoms return.

Screen Shot 2022-09-05 at 11 02 40 AM
jaygoodswp commented 2 years ago

I spoke too soon. The problem is back but only when I work on a particular project which has lots of code and lots of blade templates. So, it's like it's spending all of its time indexing. Right now, I have to turn off the plugin when working in this one project.

jaygoodswp commented 2 years ago

I updated to the latest version yesterday and this still happens on large projects. Can someone look at the indexing or similar to figure out why so much CPU is used and maybe put in a short delay in each iteration of the loop(s)?

adelf commented 2 years ago

hello, @jaygoodswp. I suppose sharing this project for me is not an option, right?

jaygoodswp commented 2 years ago

If the source code was mine, I would share it but it’s not ☹ It just has many, many, many blade files. The guy who wrote it, wrote it for re-use. Most templates are used more than once, hence the reason for doing it. I suspect the plugin is scanning these blade files. As for controllers, models, etc., there is an average amount and so I don’t think it’s that. I have other projects with more controllers and models and the plugin works fine.

From: Adel @.> Date: Sunday, September 11, 2022 at 12:09 PM To: laravel-idea/plugin @.> Cc: jay goodswp.com @.>, Mention @.> Subject: Re: [laravel-idea/plugin] [Bug]: PhpStorm CPU Usage ranges from 100% to 500% with paid version (Issue #623)

hello, @jaygoodswphttps://github.com/jaygoodswp. I suppose sharing this project for me is not an option, right?

— Reply to this email directly, view it on GitHubhttps://github.com/laravel-idea/plugin/issues/623#issuecomment-1243004994, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACJWPNFVOIDUI727G3OASRDV5YG4FANCNFSM6AAAAAAQBQXTIY. You are receiving this because you were mentioned.Message ID: @.***>

adelf commented 2 years ago

You can try to profile indexing by yourself.

Screenshot 2022-09-11 at 22 42 27
jaygoodswp commented 2 years ago

I’ve done that. It’s included in the files that I sent to you (same ones I sent to JetBrains).

From: Adel @.> Date: Sunday, September 11, 2022 at 1:43 PM To: laravel-idea/plugin @.> Cc: jay goodswp.com @.>, Mention @.> Subject: Re: [laravel-idea/plugin] [Bug]: PhpStorm CPU Usage ranges from 100% to 500% with paid version (Issue #623)

You can try to profile indexing by yourself.

[Screenshot 2022-09-11 at 22 42 27]https://user-images.githubusercontent.com/2818394/189543918-2e75e595-6929-4153-9ef9-8a29a9599a99.png

— Reply to this email directly, view it on GitHubhttps://github.com/laravel-idea/plugin/issues/623#issuecomment-1243020261, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACJWPNGPANSPDXWGG3LAMWLV5YR6HANCNFSM6AAAAAAQBQXTIY. You are receiving this because you were mentioned.Message ID: @.***>

adelf commented 2 years ago

Thanks. I found one issue in these logs and fixed it. The next release will be published next week(13-20 Sep).

jaygoodswp commented 2 years ago

Awesome!!! Thank you so much!

From: Adel @.> Date: Sunday, September 11, 2022 at 5:51 PM To: laravel-idea/plugin @.> Cc: jay goodswp.com @.>, Mention @.> Subject: Re: [laravel-idea/plugin] [Bug]: PhpStorm CPU Usage ranges from 100% to 500% with paid version (Issue #623)

Thanks. I found one issue in these logs and fixed it. The next release will be published next week(13-20 Sep).

— Reply to this email directly, view it on GitHubhttps://github.com/laravel-idea/plugin/issues/623#issuecomment-1243059234, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACJWPNDQOCEYHGF22KASYUDV5ZO6DANCNFSM6AAAAAAQBQXTIY. You are receiving this because you were mentioned.Message ID: @.***>

jamiethorpe commented 2 years ago

I'm using the 30 day trial and experiencing the same issue. Looking forward to a fix because so far this plugin is great.

Edit - For some extra context, I'm using Windows and WSL2, so it doesn't seem to be platform specific.

jaygoodswp commented 2 years ago

I knew it had to be affecting more than me? Can we get a release sooner since this can be considered critical since the plugin can’t be used in its current state?

From: jamiethorpe @.> Date: Tuesday, September 13, 2022 at 12:09 PM To: laravel-idea/plugin @.> Cc: jay goodswp.com @.>, Mention @.> Subject: Re: [laravel-idea/plugin] [Bug]: PhpStorm CPU Usage ranges from 100% to 500% with paid version (Issue #623)

I'm using the 30 day trial and experiencing the same issue. Looking forward to a fix because so far this plugin is great.

— Reply to this email directly, view it on GitHubhttps://github.com/laravel-idea/plugin/issues/623#issuecomment-1245701731, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACJWPND6ZIW2UAZBHVKU6PLV6CYMHANCNFSM6AAAAAAQBQXTIY. You are receiving this because you were mentioned.Message ID: @.***>

adelf commented 2 years ago

Could try the new 5.8.2 release and check?

jaygoodswp commented 2 years ago

Yes and it worked beautifully. I've had the large project open for 2 hours now and CPU usage is normal. Thank you so much - I really appreciate!

adelf commented 2 years ago

Thank you, @jaygoodswp. Your log files really helped.

jamiethorpe commented 2 years ago

@adelf @jaygoodswp I had success for about 4 hours and then had it start happening again, but not quite as bad as before. This time it would spike the CPU to 75-80% instead of almost 100%.

idea.laravel-idea.log

Edit - CPU started jumping to 100% as well, but it's not happening as much as before.

Adding my system specs in case that's of use

image

jaygoodswp commented 2 years ago

And I'm actually having problems with the index not refreshing after the update. This is on the large projects.

jaygoodswp commented 2 years ago

Additionally, after noticing that the index was not refreshing, I noticed that the CPU was pegged again, between 200 and 450%.

adelf commented 2 years ago

@jamiethorpe I only see a lot of messages from copylot in the log and it took about 11 second to index everything after startup at 9:30 today.

jaygoodswp commented 2 years ago

This is a cool plugin and all - I love the features - but if it doesn't work correctly for large projects, it's not useful for me. I'm sure it could be lots of things (we're all developers, right?) but maybe you could just add a few millisecond delay in the loops that refresh the index?

adelf commented 2 years ago

It's hard to debug such issues. "Indefinite indexing" still continues?

These can help to get some info:

image

And maybe "Activity monitor..." at the same menu.

jamiethorpe commented 2 years ago

@adelf I also didn't see much in the logs that would be helpful. I'll continue working with the plugin and will let you know if I experience the issue again today. I didn't see that it was actually during indexing that the CPU was spiking, but I'll try to keep an eye on that and I'll run the Indexing Diagnostics and Activity Monitor if it occurs. I can definitely say your last update improved things.

jaygoodswp commented 2 years ago

I understand that it’s difficult to troubleshoot. I’m just asking that a delay be added to the loops so that when it does get to the bug, it doesn’t completely spike the CPU usage. Just a simple sleep(10); // milliseconds – on each iteration can make all the difference.

From: Adel @.> Date: Thursday, September 15, 2022 at 4:55 AM To: laravel-idea/plugin @.> Cc: jay goodswp.com @.>, State change @.> Subject: Re: [laravel-idea/plugin] [Bug]: PhpStorm CPU Usage ranges from 100% to 500% with paid version (Issue #623)

It's hard to debug such issues. "Indefinite indexing" still continues?

These can help to get some info: [image]https://user-images.githubusercontent.com/2818394/190374511-a6fbec49-6ac1-4892-84ab-5bfd04667b01.png

And maybe "Activity monitor..." at the same menu.

— Reply to this email directly, view it on GitHubhttps://github.com/laravel-idea/plugin/issues/623#issuecomment-1247869103, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACJWPNFLUC6OQR5EESOLJRLV6LXA5ANCNFSM6AAAAAAQBQXTIY. You are receiving this because you modified the open/close state.Message ID: @.***>

jamiethorpe commented 2 years ago

Here's what I received from the Activity Monitor when the CPU started spiking:

812.6 127.8 101.4 lang.impl (in com.intellij) 53.7 Plugin PHP: php.lang.parser (in com.jetbrains) 28.1 25.7 Plugin PHP: php.lang (in com.jetbrains) 21.9 Plugin PHP: php.lang.lexer (in com.jetbrains) 18.2 lang (in com.intellij)

I'll try to gather more info throughout the day.

jamiethorpe commented 2 years ago

I also took a memory snapshot and profiled the CPU from within PHPStorm. Hopefully these will help.

https://drive.google.com/file/d/1ThohK2palLH2dNidP7wLPyr3WB-Mf-lu/view?usp=sharing https://drive.google.com/file/d/1nViVlbMLfXUxxEGgy7P4HWfEaPVvdMWu/view?usp=sharing

adelf commented 2 years ago

One user provided me with a project where he experience CPU spikes. I've found a feature which can be a reason for them. Testing it now.

jamiethorpe commented 2 years ago

@adelf Any luck so far? My trial is almost up and I really like the plugin, but it's tough to use when it maxes out the CPU.

jaygoodswp commented 2 years ago

Same for me. I paid for a license and it’s unusable at this point (it stays disabled).

From: jamiethorpe @.> Date: Wednesday, September 28, 2022 at 2:16 PM To: laravel-idea/plugin @.> Cc: jay goodswp.com @.>, State change @.> Subject: Re: [laravel-idea/plugin] [Bug]: PhpStorm CPU Usage ranges from 100% to 500% with paid version (Issue #623)

@adelfhttps://github.com/adelf Any luck so far? My trial is almost up and I really like the plugin, but it's tough to use when it maxes out the CPU.

— Reply to this email directly, view it on GitHubhttps://github.com/laravel-idea/plugin/issues/623#issuecomment-1261359971, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACJWPNE52BJKPFHKCSIJZ3DWASKQ7ANCNFSM6AAAAAAQBQXTIY. You are receiving this because you modified the open/close state.Message ID: @.***>

adelf commented 2 years ago

I'll release a new version tomorrow. I can't find a reason for this, so I'll just add some options to turn off some of my features. I hope it'll help you right now and maybe give me some helpful info...

adelf commented 2 years ago

Please, try the 6.0 version. I optimized PHP type recognition and turned it off during indexing. I hope it will help. Also, if it won't help, it can be fully turned off here:

jaygoodswp commented 2 years ago

When will the new version be released?

adelf commented 2 years ago

It's already released.

jaygoodswp commented 2 years ago

Do you have any documentation or reference describing what these options do (just in case I have to disable)?

jaygoodswp commented 2 years ago

It's still happening with these options disabled. After bursting to ~300%, it remains constant at around 100% with occasional spikes at ~450%. Please see screen shots.

Screen Shot 2022-09-30 at 8 58 30 AM Screen Shot 2022-09-30 at 9 01 14 AM Screen Shot 2022-09-30 at 9 02 11 AM

I'm disabling the plugin AGAIN...

jaygoodswp commented 2 years ago

@adelf How do we install an older version of the plugin? Like, if I wanted to go three versions back (two versions before 5.8), in an attempt to get a version that doesn't peg the CPU. Thanks!

adelf commented 2 years ago

@jaygoodswp https://plugins.jetbrains.com/plugin/13441-laravel-idea/versions you can find needed versions here. ".222" is for PhpStorm 2022.2, ".221" is for PhpStorm 2022.1, etc.

I'm really sorry about that. Indexing is fully ruled by PhpStorm. However, it uses some plugin functions, but I don't know which one is the reason for this.

If you find a version without this bug, it might help me to investigate.

wblondel commented 1 year ago

Hi,

I also have this problem with very large Blade files (4000+ lines). I disabled inspections on Blade files, it improved the situation a bit BUT I still have massive CPU usage every time I make a change on these files, freezing the whole IDE.

I am not sure if the problem is Laravel Idea or the bundled Blade plugin.

Any action in the IDE takes forever as long as I have a large Blade file open.

PhpStorm 2022.3.1 Build #PS-223.8214.64, built on December 22, 2022 Runtime version: 17.0.5+1-b653.23 aarch64 VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o. Laravel Idea 6.2.2.223

jaygoodswp commented 1 year ago

Hey William! I have found that I cannot use the plugin for large projects. It’s great for getting projects started, but for existing projects that have been around for a while and, as a result, have grown significantly, I have to disable the plugin. It seems that it’s difficult to debug, but there’s definitely a conflict happening between PhpStorm and the plugin.

adelf commented 1 year ago

You can try to do this to reduce CPU usage by plugin.

Turn off Laravel Idea inspections

image

Turn off type providers:

image

Turn off some Eloquent features:

image
jaygoodswp commented 1 year ago

I just found this in PhpStorm.

  1. Go to Help | Find Action
  2. Type in Registry and click to open
  3. Change the values below and see if it helps. I'll report back with my findings. I would try this before disabling the plugin features. Screen Shot 2023-01-07 at 11 14 37 AM
jaygoodswp commented 1 year ago

Update: That helped with the majority of my projects (together with the @adelf's suggestions). I still have one project that causes PhpStorm to use the max threads (2) all the time UNTIL I shut off the plugin. Once it's turned off, usage goes down to below 20%.

ismaail commented 1 year ago

Disabling the option Blade variables type provider in Laravel Idea/Languages/Blade solves the issue for me.

marcusmoore commented 1 year ago

Turning off Implicit Eloquent method usages searcher (might use a lot of CPU resources) did it for me.

FWIW, this eloquent model was the one I noticed the issue on the most.