New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
High memory consumption of LSP process "PropertyLauncher" can lead to excessive garbage collection and subsequent slow down #212
Comments
Leak suspects from MAT: |
@martinlippert I'm not sure what this background process does. Does it analyse spring beans only or the whole project or the whole workspace? |
@hbrands asked:
The workspace. It does try to avoid analyzing projects that don't look like they are using spring (decided by looking at the dependencies of the project). |
According to SpringProjectUtil.java a project is considered, if spring-core* and/or spring-boot* is on it's classpath? |
I can confirm that all projects in the workspace directly or indirectly reference spring-core in their classpath (by all using a base project that's dependent on spring). |
@hbrands very interesting numbers, even though I would have hoped that the language servers AST analysis is not that memory intensive and it seems to be in your case. What version of STS4 do you use? And what is max heap setting for your IDE itself and how much of that does it consume, if you do a full rebuild, for example? Would be extremely interesting to see that. The leak suspects from the MAT analysis look not extremely suspicious, seems like the regular scanning of the ASTs for the projects (when the language server kicks off) and JDT internals showing up there. The main question will be if JDT is consuming so much memory for a good reason (and does basically the same than in the regular IDE) or do we do something wrong while using JDT or not freeing up that memory early enough for some reason? Sounds like we need to investigate further. Lets first look at the other numbers (the one I asked above) and then decide how to move on here. |
@martinlippert I'm using Eclipse for Java Enterprise Developers with STS 4.1.2 and STS 3.9.7 Add-On installed. I'm using Eclipse with the following memory settings: I've attached a Visual GC screenshot for full workspace rebuild. |
Note that other plugins like m2e, Checkstyle and PMD were also running on the full rebuild. Java-Version used is Oracle JDK 1.8.0_191. |
@hbrands when you go to https://dist.springsource.com/snapshot/STS4/nightly-distributions.html, you can download a nightly CI build of STS4 (or use the update site mentioned at the top to update an existing install to the latest nightly build). This new build contains two things:
To set specific VM arguments for the language server, please add a specific system property to your eclipse.ini file (or SpringToolSuite4.ini, depending on your install): For example, you could add a line like this:
The individual arguments are comma separated and the value of this property is split into the individual pieces using This should allow you to experiment with larger max heap spaces for the language server process. I very much hope that this will help a bit. The second thing that I added creates additional performance-related log output from the language server. To enable the logging, you can enable the checkbox in the preferences for The lines that I am interested in are: |
@hbrands The latest builds include a few additional options and improvements and it would be awesome if you could give them a try, so that we can learn about the effects. The first option that you should set for the language server (via the mechanism described above) is:
This disables the newly introduced cache for symbols. Since the cache avoids re-parsing the whole workspace every time you started up the language server for the first time, it would not allow us to analyze the behavior for scanning the whole workspace anymore. Therefore please disable that when running from the latest builds. The second option is:
This skips certain parts of the parsing while scanning the whole workspace. This is not particularly useful for real world usage (since we need to NOT ignore method bodies for certain symbols), I would be very interested to see how that affects the memory consumption of the language server process. So it would be great if you could give the latest CI build a try, set both options in the ini file via:
and watch the memory consumption. For this test, please do not increase the max heap space yet. Once we have that data, you could try to increate the heap space (if still necessary), and remove the option to disable the caching. That should help a lot going forward. Looking forward to hearing from you with the results. |
As soon as build B1586 appears on this nightly download page, it should be ready for you: |
@martinlippert Attached are the log files for four runs:
2.) boot_debug_ignoremethodbodies : 3.) boot_debug_2g : 4.) boot_debug_3g : Notes: I noted in the logs "o.s.i.v.c.boot.app.cli.SpringBootApp - check for spring jmx beans ..." with four retries, not sure if this is important. I triggered the parsing by opening a java file, no spring app was started. Spring Boot projects are edrewe-serverapp and edrewe-transmission-server. A traditional spring app is in edrewe-webapp. But note, that edrewe-ui is not used in these servers so that project parsing is not really needed?! |
That is awesome, thanks a lot for spending the time and running these tests, much much appreciated. Can you run one more check? I would love to get my hands on a head dump when the JVM is running out of memory. Can you add something like this to the VM args for the boot language server?
You could also specify a path where to store the heap dump by adding and send me that head dump somehow? That would be excellent... :-) |
Oh, and I would be interested in the heap dump for your third config only (not all of them): boot_debug_2g |
@martinlippert So how can I share this 2 GB heap dump with you? E-Mail is no option. Any FTP address available? |
Dropbox? |
I don't have a dropbox account. Can I upload the file to your dropbox nevertheless? |
Yepp, can do that, just need your email... :-) |
The heap dump is quite interesting, thanks a lot for that. I think for the next release (4.2.0), we have these two things implemented that should improve the situation for you a lot:
With this, I would close this issue and mark it as resolved for the 4.2.0 release. Nevertheless, I will not stop to work on the memory consumption and overall performance of this, but in separate, more specific issues. Also feel free to create new issues for whatever you find, including performance and memory issues. Since you have a fairly large workspace, those experiences are super valuable for us. |
Any news on this? Would be interesting to see why |
Did you see my comment |
@martinlippert What do you think is the limiting factor for spikes in heap usage, the size of the whole workspace or the size of individual projects in the workspace? Do you think splitting up big projects into smaller ones will help here? |
Thanks for looking into the issue and providing help and customization options! |
Oh, yes, right, so that answers the question... :-) |
Initially the language server parses all the files in a project as one big batch. This has the advantage that a lot of information (especially the lookup and type resolution information) is cached and shared when parsing each individual file. Re-creating that state for every single file would be super expensive. On the other side, the more files you have in your project, the more is parsed in this batch mode and the more memory this batch parsing allocates. This is the reason for the spike in the heap dump. So splitting this up into smaller projects would help indeed, since you would end up running multiple batch parses (one for each smaller project), resulting in less heap usage per batch (probably, somewhat hard to predict). GC would be able to free up the space from the previous batch parsing before the next one runs. But I don't think the tooling should force you to a specific project structure. It should really be able to deal with larger projects and larger workspaces. Therefore I think making progress in this "ignore method bodies" area (as described above) makes a lot of sense anyway and should reduce the spike in heap usage.
Most of the heap is indeed used by the JDT parser internally, so nothing that I can change right away, but I will contact the JDT folks about it. Maybe we can find additional ways to reduce the memory consumption or to use the parser differently to reduce the memory consumption. Maybe running the parsing in more fine-grained batch sizes would be an improvement (would trade less memory for slightly less performance though).
Yeah, I agree, if we can find a way to reduce the scope of the parsing to fewer projects, that would help, too, of course. Not sure yet what the best way is here. Maybe we should open a separate issue for that and share ideas/thoughts over there. WDYT? |
👍 With your applied changes so far we should be able rollout STS 4.2.0. |
Sounds good. I also noticed that you use the STS3 Add-On pack. What do you need the STS3 Add-On pack for? I am looking for feedback about what is missing in STS4. So what are you missing in STS4 that makes you install the STS3 Add-On ? |
@martinlippert From |
The question for me is: which parts of the XML tooling of STS3 do you use and would like to continue to have? My goal is to allow you to do everything you need in STS4 only some day in the future and we will not be able to port everything from STS3 over to STS4. Therefore learning about your requirements/priorities would help to prioritize the work... :-) |
It's basically code completion support in XML files and refactoring support for XML files. I'm not sure what other parts you are refering to? Anyway, we're in the process of migrating to Java config, so in a few months XML support isn't that important for us anymore. |
@hbrands I implemented an additional optimization for the symbol indexing infrastructure, so that you don't need to configure your language server with If you want to give it a try, feel free to download a nightly build from here: https://dist.springsource.com/snapshot/STS4/nightly-distributions.html In case you give it a try, it would be super interesting to see the log output (includes a bit of timing information for the parsing) and a screenshot of the memory consumption over time (in case you have time for this). Thanks!!! |
Eclipse 201812 on Windows 10 Prof, , STS 4.1.2 (and STS 3.9.7 Add on):
With our closed-source Eclipse projects and workspace we noticed that the background thread "PropertiesLauncher" quickly fills up its heap space. In particular, with the attached VisualGC it could be noticed that the old generation in the heap was full and a lot of full garbage collection cycles happened, causing CPU load:
The text was updated successfully, but these errors were encountered: