Php-language-server: Intellisense slow on 5k files

Created on 3 Feb 2017  路  37Comments  路  Source: felixfbecker/php-language-server

I like the new auto completion tool and, I have a Laravel project that parses the files like so:

All 5568 PHP files parsed in 253 seconds. 178 MiB allocated.

When I type $someVar-> it takes about 2 seconds until the suggestions show up.

perf

Most helpful comment

I had to switch to PHP Intelephense.

All 37 comments

Hmm, aggregating the completion results should be O(n).
This would be interesting to profile.

Not sure if you saw this in the release notes of VSCode 1.9, but there is a php parser they are working on

https://github.com/Microsoft/tolerant-php-parser

Might be helpful in some way...

Yes, I am aware of it 馃檪

I have a similar issue on a Code igniter project. The autocompletion for class methods doesnt even pop up until I hit ctrl + space, then takes a few seconds. If i delete the -> and do it again, same thing. it doesnt cache the results either. but that is probably a different issue?

@autoferrit afaik the results are not cached, but only the files where we get the results right. I think that's the bottleneck, yes.

CTRL + Space takes about 12 seconds for me. I do have 10k PHP files:

All 10140 PHP files parsed in 16 seconds. 504 MiB allocated.

macOS: 10.13
3,7 GHz Quad-Core
12 GB RAM
PHP: 7.1.10
Extension: 1.5.2
Code: 1.17.2

Hi! @felixfbecker willing to work on this -- Do you have any suggestions on the best place to start? Profiling it with XDebug?

Has anything help now?

I had to switch to PHP Intelephense.

@binarious is it faster?

@lndj It just works for me. Suggestions and method signatures show up instantly on very large projects.

@TheColorRed
Have you disabled VSCode built-in suggestions? Try to set "php.suggest.basic" to false in settings.

Same trouble, about 15 seconds, Yii2 basic project. And i switch to PHP Intelephense.

I've also switched to Intelephense for now. Unfortunately Intelephense has it's own set of issues, but I can't live with autocomplete times of over 5 seconds in my project.

I noticed @bmax didn't get any response to his offer to work on this in over 4 months. Can we expect this to be resolved at some point in the near future, or are we out of luck for the time being?

@Vercoutere I ended up not putting any time into working on this because there happened to be a couple of other PR's started. I'm not sure why they haven't been merged. I have heard good things about Intelephense though.

Is the slowness coming from this:

CompletionProvider.php Lines 246-251

            foreach ($this->index->getDefinitions() as $fqn => $def) {
                foreach ($prefixes as $prefix) {
                    if (substr($fqn, 0, strlen($prefix)) === $prefix && $def->isMember) {
                        $list->items[] = CompletionItem::fromDefinition($def);
                    }
                }
            }

There is no trie index or anything like that, but everything is always looped through and it filters the matching ones in the loop?

Has there been any updates on fixing this?

@felixfbecker Is it really neccessary to check each definition whether it starts with the prefix? Visual Studio Code is able to filter out, too?

Same issue here... Takes up to 15 seconds on ctrl + space. Looking for a solution.

A little discouraging that a few attempts have been made by community to fix this but not enough attention has been given to review it. The main purpose of this project is to assist developers in writing code faster. Unfortunately it fails at it right now due to these long standing performance problems. @felixfbecker, thank you for all your efforts! It's greatly appreciated, and I'm sorry to complain, but I felt like it's important to say this.

Is anyone interested in bringing https://github.com/felixfbecker/php-language-server/pull/599 over the finish line?

I could do that, but only in two weeks(having a trip from tomorrow until next week). Hope someone else can do that earlier. :)

We of the emacs-php community are eagerly awaiting this merge :) Thanks to everyone who put time into this PR! It's going to be big for the community

Another member of the emacs-php community - just wanted to echo what @cmatzenbach said above! Thank you so much for all of your work! This is gonna make programming in PHP a much better experience in emacs.

@felixfbecker I saw that the PR seems to be basically done. Is it possible somehow to test @jens1o's branch of php-language-server locally in vscode-php-intellisens?

Yes, all you need to do is symlink your local language server repo clone into ~/.vscode/extensions/felixfbecker.php-intellisense-x.x.x/vendor/felixfbecker/language-server

Thanks for the ping. Forgot to push. This is the current thing I've on. However, some tests are still failing currently. https://github.com/jens1o/php-language-server/commit/f45c44f463bc763384cfab617ed1aecb02a126d8

Feel free to open a work-in-progress PR

[Info - 9:39:44 PM] All 5316 PHP files parsed in 8 seconds. 394 MiB allocated.

It's getting parsed for me in less seconds but yeah doesn't change the fact it's slow in auto completing. Can't wait for a fix!

@MichaelBelgium if you can't wait, help out :)

@MichaelBelgium if you can't wait, help out :)

Is this what needs to be done?

Yes

Okay, thanks for taking your time. :)

Okay, thanks for taking your time. :)

Anytime :) if it's only a simple merge ... surprised nobody did it before me.

:tada: This issue has been resolved in version 5.4.3 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket:

I had to switch to PHP Intelephense.

Same, the issue is still happening, had to switch, now it's instant..

Was this page helpful?
0 / 5 - 0 ratings