felixfbecker / php-language-server

PHP Implementation of the VS Code Language Server Protocol 🆚↔🖥
ISC License
1.15k stars 185 forks source link

Memory usage #479

Open umpirsky opened 7 years ago

umpirsky commented 7 years ago

Using it with atom/ide-php, it consumes ~1.2G of RAM. Is that expected?

felixfbecker commented 7 years ago

Depends on how big your project is. What do the logs say?

umpirsky commented 7 years ago

@felixfbecker How can I check logs?

felixfbecker commented 7 years ago

Depends on your client

umpirsky commented 7 years ago

@felixfbecker It has 25298 PHP files including vendors.

felixfbecker commented 7 years ago

That's a pretty big project, so that is kinda expected atm. Not saying there is no potential for memory optimisation though. Do you need the whole folder open in your IDE?

umpirsky commented 7 years ago

@felixfbecker Yes, it's a large project. And yes, I need whole folder.

I'm not sure how the server works, but the way I see it is that it needs some resources to index all the symbols etc, but once that's done, what is taking so much RAM? Shouldn't it just incrementally index and have everything else cached?

felixfbecker commented 7 years ago

It does that, but the index is in memory.

umpirsky commented 7 years ago

@felixfbecker Aaah, I see. Big project - big index. I guess keeping it anywhere else would be too slow.

umpirsky commented 7 years ago

@felixfbecker Does it parse only php files?

felixfbecker commented 7 years ago

Exactly. Keeping it in memory allows it to be look up definitions, completions, symbols etc fast. That said, there are definitely ways to store less data in the Definition class so it takes less RAM per index item. Yes, it only parses PHP files.

umpirsky commented 7 years ago

@felixfbecker I see. It would be nice if it can detect what features are enabled, for example I don't use declarationLine and documentation hover, that would probably save lots of memory because they are large strings.

felixfbecker commented 7 years ago

they could also be resolved on-demand if that doesn't impact perf

umpirsky commented 7 years ago

@felixfbecker Worth a try? What would be memory decrease in that case?

felixfbecker commented 7 years ago

I don't know, I never memory-profiled the language server (I wouldn't know what tool to use from the tip of my head)

staabm commented 7 years ago

You could use blackfire.io for perf and memory profilling

umpirsky commented 7 years ago

@felixfbecker Blackfire, xdebug or memory_get_usage().

felixfbecker commented 7 years ago

I wasn't aware that XDebug does memory profiling? memory_get_usage() is already used to log memory usage, but that doesn't tell what application parts actually use the most memory

umpirsky commented 7 years ago

@felixfbecker I googled this out https://derickrethans.nl/xdebug-and-tracing-memory-usage.html

josecanciani commented 6 years ago

@felixfbecker are there any plans of removing the index from memory? Have you though using sqlite for example? My project has 26k php files. I tried it with vscode and it's impossible to use. Indexing takes too much time too, by storing data in a database you can avoid big reindexing and just update what changed from the last time.

SYip commented 5 years ago

@felixfbecker are there any plans of removing the index from memory? Have you though using sqlite for example? My project has 26k php files. I tried it with vscode and it's impossible to use. Indexing takes too much time too, by storing data in a database you can avoid big reindexing and just update what changed from the last time.

That is a great idea. My notebook has only 4 GB of ram where the language server take 1 Gb. It is impossible to do development with framework like laravel or symfony. Moving the database to disk should save most of the ram and re-indexing time.

apapsch commented 5 years ago

The issue is exacerbated when several language servers are running due to multiple projects. As a workaround I'm using earlyoom to kill off the language server: https://github.com/rfjakob/earlyoom.

Kenny2github commented 3 years ago

I found a temporary workaround on Linux: Enable swap (I used this article). Language server ran with no issues. I fallocated 4G.