Skip to content
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

STS 4 high cpu and ram usage when Code Mining and Live Boot Hint Decorators are both enabled in Windows 10 #292

Closed
tparry3 opened this issue May 17, 2019 · 17 comments
Milestone

Comments

@tparry3
Copy link

tparry3 commented May 17, 2019

In STS 4 there is constant, high cpu usage along with large amounts of memory used when Code Mining is enabled along with Live Boot Hint Decorators for certain spring boot projects. I have a very small project that can reproduce it with released STS 4 (or Eclipse with STS 4 plugin) on Windows 10. Nightly builds of both show the same pattern.

Steps to reproduce:

Windows 10 - fully patched
STS 4 (or latest Eclipse with STS 4 plugin)
STS configured to run with Java 1.8 JRE with tools.jar added to the lib directory or Open JDK 11
Enable Code Mining
Enable Live Boot Hint Decorators
Import the uploaded database-demo project archive

Open all three java files in the IDE:
DatabaseDemoApplication.java
PersonJdbcDAO.java
Person.java

@tparry3
Copy link
Author

tparry3 commented May 17, 2019

database-demo.zip
Added sample code that reproduces the issue.

@tparry3 tparry3 closed this as completed May 17, 2019
@tparry3 tparry3 reopened this May 17, 2019
@tparry3
Copy link
Author

tparry3 commented May 17, 2019

It seems like the Code Mining feature and the Live Boot Hint Detectors are messing each other up in an infinite loop. Disable one or the other and everything runs normally.

@kdvolder
Copy link
Member

kdvolder commented May 17, 2019

Was able to reproduce the high CPU usage. As soon as I opened DatabaseDemoApplication the Java process got pretty big and repeatedly spiking CPU. It's not really 'terrible' for me as it doesn't rise to a point yet where it actually makes the CPU so hot that the fan kicks in. What I'm seeing is repeated short spikes at about around every 5 seconds.

cpu-spikes-code-lenses

I think this probably comes from the fact that in STS the live information we display in code lenses is 'dynamic' and it gets refreshed every 5 seconds. The refreshes we trigger probably somehow also causes the codeminings to refresh. I see that codeminings is showing over 2000 references for the 'logger' field. So I imagine this might be part of the reason why the codeminings are a bit CPU intensive in finding all those references.

This is all bit speculative at this point, so I'll have to try and analyze it more.

@kdvolder
Copy link
Member

Opening more files causes pretty much constant high CPU.

kdvolder added a commit that referenced this issue May 17, 2019
...nothing has changed. The refresh can be very expensive
if user has enabled code minings.

See: #292
@kdvolder
Copy link
Member

I've pushed something that avoid the CPU spikes simply by checking whether the highlights/codelenses from our language server have changed since last time. When they haven't changed we don't trigger a refresh and this totally avoids the periodic CPU spikes.

There's a few more things we might be able to do to also improve the case where the refresh does actually get executed. @BoykoAlex is exploring this a bit at the moment.

@kdvolder
Copy link
Member

@tparry3 The changes I pushed out have already made their way through the build pipeline. You can try it out by downloading a snapshot/nightly STS 4 distribution from here: http://dist.springsource.com/snapshot/STS4/nightly-distributions.html

@spring-projects-issues
Copy link

(comment in Pivotal Tracker added by Alex Boyko:)

I have pushed the fix for not updating CMs when CodeLens for Live Beans setting is off. We are waiting for feedback from the bug raiser now I think.

@spring-projects-issues
Copy link

(comment in Pivotal Tracker added by Martin Lippert:)

I tested this with the latest nightly CI build and it looks to me like there is a fundamental issue. I used a fresh, vanilla STS 4.2.2 CI build and imported the project, then enabled the general code minings from Eclipse, but nothing shows up in the editor.

As soon as I add the actuators to the app and start it, so that the live hovers are triggered, those live hovers show up, including their code minings, together with the JDT code minings. Stopping the app thereafter removes the live hovers, but keeps the JDT code minings showing.

We need to fix this. The JDT code minings should always work, independent of the Boot LS code minings showing up or not. Maybe there is something going wrong with our additional "enable code minings in editors automatically" implementation.

@tparry3
Copy link
Author

tparry3 commented May 20, 2019

I agree. JDT code minings are independent of the Boot LS code minings.

Also, I pulled the nightly build from last night. The Preferences screen for 'Spring Boot Language Server' is completely blank for me. No options showing. No text at all. Just a blank pane.

@martinlippert martinlippert added this to the 4.2.2.RELEASE milestone May 21, 2019
@BoykoAlex
Copy link
Contributor

@tparry3 Spring Boot Language Server page is blank (for the moment) because its content has been moved to two sub-nodes: Boot Java and XML pages:
Screen Shot 2019-05-21 at 10 33 20

@spring-projects-issues
Copy link

(comment in Pivotal Tracker added by Alex Boyko:)

@mlippert I enabled CMs under Java->Editor ->Code Minings opens Main class of Pe Clinic and i see 1 reference for PetClinicApplication CM without enabling Boot LS Code Lenses. It starts showing up after a little while not right away.

@spring-projects-issues
Copy link

(comment in Pivotal Tracker added by Alex Boyko:)

Close/Open editor and they'll start showing up if they don't show for already opened editors. I don't think it's a problem with Boot LS Code Lens vs JDT Code Minings. It's rather Java CMs update problem. They show up with Boot LS CMs because receiving Boot LS Code Lense triggers CMs refresh and all of them show up: JDT and ours.
Pretty sure the problem is with JDT CMs only.

@kdvolder
Copy link
Member

It's rather Java CMs update problem.

I agree, doesn't seem like that's our problem. If JDT code minings don't appear when you just enable JDT code minings from JDT preferences... seems like that's JDT's problem/bug. It shouldn't be up to us to trigger a code mining refresh when nothing related to our own code minings has changed.

In fact to avoid the CPU spikes, our efforts in addressing this ticket has been towards avoiding these refreshes as much as possible.

@spring-projects-issues
Copy link

(comment in Pivotal Tracker added by Martin Lippert:)

I have a regular Java project (non-boot) in my workspace and re-opening the java editor with java editor code minings enabled shows the minings (references in my case). Switching the preference on/off works fine after re-opening the java editor.

However, all this is in a plain Eclipse 2019-03 install. The latest STS4 CI doesn't behave the same. Once I switched the code minings off once, they never come back in a java editor.

Are you sure we don't interfere with that mechanism?

@spring-projects-issues
Copy link

(comment in Pivotal Tracker added by Martin Lippert:)

This works in the STS 4.2.1 release, too, but not in the latest STS 4.2.2 nightly, both on Eclipse 2019-03.

Here is what I do:

  • enable code minings for java editors in the preferences (the JDT preferences)
  • open a java file
  • reference minings appear
  • open the preference again
  • disable code minings and hit "apply", they disappear immediately
  • enable them again and hit "apply", nothing happens
  • close the preferences
  • close and re-open the java editor

In Eclipse 2019-03 and STS 4.2.1, the reference minings appear again after a short while, in STS 4.2.2 CI, they don't.

@kdvolder
Copy link
Member

kdvolder commented May 22, 2019

I'm not 100% sure we are not responsible for this problem.

However, this:

the reference minings appear again after a short while in STS 4.2.2 CI, they don't.

That sort of make perfect sense since the 'CPU spike fix' means we do no longer trigger a code minings refreshe every 5 seconds unless something changed in terms of our own code miniings. In the old version every 5 seconds we trigger a refresh, no matter what.

@kdvolder
Copy link
Member

I just tried latest CI build and if I do the steps as described... the code minings do come back for me in the last step. Everything else behaves as you describe. (So the code minings do not come back immediately when I re-enable them). Also I do not have to open/close the editor. Making a change in the editor by typing in it also brings code minings back.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants