vscode-intelephense icon indicating copy to clipboard operation
vscode-intelephense copied to clipboard

Performance improvements

Open gyzerok opened this issue 4 years ago • 17 comments

Feature description or problem with existing feature I am working with quite large codebase with thousands of files and millions LOC. Some files can be up to 12k LOC.

  1. Hover popups on symbols take seconds to display (maybe 3-5)
  2. Autocomplete doesn't seem to work at all (probably just takes much longer than the typing)
  3. When I type new code it seems that it's parsing is struggling. I get error line under the code I type, which would show errors from after some symbols were typed (however I finished typing correct code already) and this errors will resolve only after tens of seconds.

Describe the solution you'd like Maybe a release heavily focused on performance optimizations 😄

Additional context I can't share any code with you, but if there are any stats I can collect which would help you identify the problem, I can see what I can do.

Perhaps you can also use some large open-source codebases such as Drupal to analyze the bottlenecks.

gyzerok avatar Jul 09 '20 00:07 gyzerok

It looks like on the small files in the same codebase autocomplete actually starts working. So my performance problems must have to do with the fact that I mostly work in a huge files.

gyzerok avatar Jul 10 '20 23:07 gyzerok

Thanks, is it worse when many files are open? Does the code have thorough type declarations and annotations or is this patchy?

bmewburn avatar Jul 11 '20 00:07 bmewburn

Thanks, is it worse when many files are open?

I'll try to check this. However I mostly work with 2 huge files, so only they tend to be open. Either only one or both.

Also there are a lot of usages of globally defined things, which I expect would result in more files being parsed. Dunno if this helps anyhow.

Does the code have thorough type declarations and annotations or is this patchy?

It is patchy. Older code does not have them and newer code mostly does.

gyzerok avatar Jul 11 '20 00:07 gyzerok

Is there any improvement with 1.5 for larger files?

bmewburn avatar Jul 11 '20 04:07 bmewburn

Wow, that was quick! 😄

Thank you! I will check it during my work next week.

gyzerok avatar Jul 12 '20 01:07 gyzerok

Ha, don't get too excited. I don't think it will solve your problems but there was a small performance optimisation in the release.

bmewburn avatar Jul 12 '20 02:07 bmewburn

Oh, I've just noticed that I typed a comment here, but never sent it 😅

It's really hard to say if performance has improved after the 1.5 release. At least it isn't noticeable enough to tell.

gyzerok avatar Jul 18 '20 01:07 gyzerok

I want to add that when I need to require_once a large amount of PHP files (in my case, near 50), the extension is very slow to show code completions. It can take near 10-15 seconds. In smaller files where I don't require_once many files (like 4-5), the issue is not present.

dominiquediotte avatar Aug 10 '20 17:08 dominiquediotte

Intelephense states that it is initialized but it stalls when using the DOCBlock feature. When hovering over usage, the message "Loading..." pops up and that seems to stall as well.

Character of my Code

  • 900 PHP files
  • Significant number of hybrid files (i.e., HTML with embedded PHP) but majority of files are nothing but PHP.
  • For public-facing pages, the set of includes represents about 40 pure PHP files.
  • For the backend, the set of includes represents about 60 pure PHP files.
  • There are somewhere between 50,000 and 70,000 lines of code in PHP files.
  • There are probably around 100 CSS files, of which the two main files represent 4,000 lines of code.
  • There are about 450 JavaScript files.
  • There is a large group of hybrid files that are identically structured and contain the same function definitions. For example, 85 files in the backend have a function declaration for display_form(). These are individual pages and only one is ever running at a time, but clearly Intelephense sees them all in the same development context.
  • I am migrating from Microsoft Expression Web and thus have a structure of "ghost" files in vti* folders. I have excluded them in some projects and not in others; this does not appear to make a difference in stall behavior.

DOCBlock Behavior

  • After entering /** just before a function definition, sometimes the Intelephense option pops up right away, sometimes it takes 20-30 seconds, and sometimes it does not appear at all, even after waiting 30 minutes.
  • If the Intelephense option has not yet popped up, the "Loading..." message pops up on anything over which I hover. If I then delete the DOCBlock comment (/ */**) the Intellisense popups resume, sometimes after a delay lasting up to 30 seconds.

External Influences

  • A few of my projects had .idea folders due to previous experiments with PhpStorm. I eliminated those folders and no change in performance was noted.

FastieSystems avatar Oct 11 '20 16:10 FastieSystems

I did about 6 hours of editing today, all routine. Intelephense performance was terrific. Toward the end, I modified a DOCBlock to mark a function @deprecated. I then continued work until I edited a module that contained a reference to the deprecated function. Intelephense marked the deprecated function and at that point Intelephense stalled. It took about 30 minutes for it to recover.

Upon reflection, I realized this had happened before. I can't say for certain that a deprecated function results in this behavior but it's hard to think of this as coincidental.

FastieSystems avatar Oct 19 '20 03:10 FastieSystems

I have now performed controlled experiments around the deprecated problem I'm experiencing. With VSC and Intelephense running at speed and after a couple of hours of work, I deliberately loaded a module that I knew contained a deprecated function. Upon hover, Intelephense instantly popped up the information about that function. I removed that single line of code and added the replacement. Then Intelephense stalled and took about 5 minutes to recover.

The amount of recovery time varies. I have no data points to share that might explain why. With this morning's test I only had three editors open. If I'm doing something complicated I might have up to ten but I think my average is around 5. I also sometimes have multiple instances of VSC running, editing different projects, This week that has been rare, no more than 20 minutes a day of multiple instances.

FastieSystems avatar Oct 22 '20 17:10 FastieSystems

Is there any possibility that Intelephense could be confused by:

  • A C-style comment that happens to begin with /** but is not actually a DOCBlock?
  • Something that looks like a DOCBlock but does not have any tags?
  • Additional commentary in the block that comes after the tags?

FastieSystems avatar Oct 22 '20 20:10 FastieSystems

It seems that the stalls I have been experiencing have abated with Intelephense 1.6.x.

Thank you.

FastieSystems avatar Jan 15 '21 02:01 FastieSystems

Personally, the issue is still present. Any updates on it?

dominiquediotte avatar Jan 15 '21 04:01 dominiquediotte

Issue still present takes about 11 secs right now to open up suggestions for a class. is there anyway to force build a cache?

Madpeterz avatar Jun 21 '21 12:06 Madpeterz

I would also like to say that performance has been the biggest issue in using intelephense. I'm working on a medium sized monorepo for a microservice project and the language server doesn't perform very well at all (10s of seconds of waiting time in some cases, sometimes it doesn't work at all and sometimes it's performant as you'd expect).

I even removed the cache to let intelephense reindex the project from scratch, but it seems to be a performance bottleneck somewhere else. As it stands, I have to seriously consider not using intelephense/vscode (and therefore look at Jetbrain's product...).

An observation: It seems to me that non-vendor code (i. e. code not contained within a vendor dir) is more responsive than Classes, etc. that have been installed using composer.

P.S.: I reported a similar issue with the same project (before it became a monorepo a while back and thought it had problems with symlinks, however there are no symlinks at play in the new monorepo project structure…)

finn-matti avatar Jun 09 '22 11:06 finn-matti

I haven't had any significant stalls since my last post here 17 months ago. The character of my code (as described in an earlier post) has not changed.

I'm planning to migrate to PhpStorm, but not because Intelephense is causing problems - there are other VSC issues that negatively affect my development style. The improvements in Intelephense have been good enough that the rush to migrate is not so great. PhpStorm is vastly more complex, and its syntax checking and code recommendations can sometimes be over the top and become quite annoying.

There's no question that PhpStorm is fast, but I'd suggest testing it with a monorepo. I'm not an expert on this topic, but it seems to me that multiple projects in the same place create heavy overhead, and that might affect PhpStorm as well. It's easy enough to test, as JetBrains offers generous trial terms.

FastieSystems avatar Jun 09 '22 12:06 FastieSystems