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

High CPU usage caused by java platform se binary #29

Closed
zwwi opened this issue Mar 16, 2020 · 12 comments
Closed

High CPU usage caused by java platform se binary #29

zwwi opened this issue Mar 16, 2020 · 12 comments
Assignees
Labels
1-bug 🐛 Issue type: Bug report (something isn't working as expected) 2-confirmed Issue status: Confirmed, reproducible bug in LTeX 3-fixed Issue resolution: Issue has been fixed on the develop branch

Comments

@zwwi
Copy link

zwwi commented Mar 16, 2020

Describe the bug
This is not really a bug. But when I enabled the LTeX extension, there was a high cpu usage caused by java platform se binary.
I like this extension. Thank you for developing this, but the fan noise is a bit annoying...

Steps to reproduce
Steps to reproduce the behavior:
Use vs code + latex workshop, enable ltex, after a few minutes, there would be a high cpu usage.

Version information
List here the version information of the relevant software.

  • Operating system: Windows 10
  • VS Code: 1.43.0
  • LTeX: 4.7.10
  • LTeX language extensions: English (en-us)
  • Java: x.xx (usually from java -version)
    java version "1.8.0_241"
@zwwi zwwi added 1-bug 🐛 Issue type: Bug report (something isn't working as expected) 2-unconfirmed Issue status: Bug that needs to be reproduced (all new bugs have this label) labels Mar 16, 2020
@valentjn
Copy link
Owner

@zwwi When does the high CPU usage occur? When you're opening a new document? When you type something in an open document? Or without doing anything?

It would help a lot if you could attach an example document for which this occurs, or any additional information that helps me reproduce the issue. LT is known to be CPU-demanding when checking, but it shouldn't do anything when not checking.

@valentjn valentjn added the 2-needs-info Issue status: We need more information (usually) from the submitter before continuing label Mar 16, 2020
@zwwi
Copy link
Author

zwwi commented Mar 17, 2020

@valentjn Sorry for the lack of enough information. I checked more carefully, and find this happens when the cursor is hovering over the identified issue and LTeX is checking for quick fixes. Each check normally takes a few second. So you mean this is known, I will then close this issue. Thank you for your quick response.

@zwwi zwwi closed this as completed Mar 17, 2020
@valentjn valentjn added 3-no-action Issue resolution: No action taken (e.g., issue has been withdrawn) and removed 2-needs-info Issue status: We need more information (usually) from the submitter before continuing 2-unconfirmed Issue status: Bug that needs to be reproduced (all new bugs have this label) labels Mar 21, 2020
@valentjn valentjn self-assigned this Mar 21, 2020
@konstantin-schekotihin
Copy link

I still have a problem with LTeX while writing a bit lengthy journal article. Even when I do nothing the checker is heavily loaded and it might take 4 to 5 minutes until the process stops using the CPU. I do not experience this behavior while modifying the same paper in TexStudio, which also uses LanguageTool 4.8 server as a spellchecker.

VisualVM Profiler shows that the process is mostly busy with checking, although I cannot detect what it does exactly. I made a screenshot of the profiler sampling the CPU time during one of such lengthy background checks.
122624

@valentjn valentjn reopened this Apr 6, 2020
@valentjn valentjn added 2-unconfirmed Issue status: Bug that needs to be reproduced (all new bugs have this label) and removed 3-no-action Issue resolution: No action taken (e.g., issue has been withdrawn) labels Apr 6, 2020
@valentjn
Copy link
Owner

valentjn commented Apr 6, 2020

@konstantin-schekotihin Thanks for the profiling. Everything inside org.languagetool.JLanguageTool is LanguageTool (LT) and out of scope for LTEX, whose code is in org.bsplines.languagetool_languageserver. Remaining possibilities for differences to TeXstudio that I see right now are the number of checking calls of LT made by LTEX, the configuration of LT (language, etc.), and the configuration of Java (heap size, etc.).

To help narrowing it down a little, could you post as much useful info from https://github.com/valentjn/vscode-ltex/blob/master/.github/ISSUE_TEMPLATE/bug-report.md as possible, especially the LTEX configuration in your settings.json?

@valentjn valentjn added the 2-needs-info Issue status: We need more information (usually) from the submitter before continuing label Apr 6, 2020
@konstantin-schekotihin
Copy link

Hi Julian,

Thanks for the fast reply and your work!
Unfortunately, I could not reproduce the problem over the last days. I'll try to "catch" it and provide you with the required info.

Best,
Konstantin

@deividrvale
Copy link

I am also having the exact same issue while hovering over a possible problem. The CPU usage go high enough for the laptop fan to get noisy.
Screenshot_20200416_035335
These are the moments that it goes much higher. When I am typing the CPU usage is also high and updates on the issues now takes some time. After leaving the document quiet for a while the cpu level goes down again.
I had to close vs-code and kill the java process a bunch of times now, since as times goes by it gets even harder to get the fixing recommendation and updates on the file.

My environment is:

Operating System: Kubuntu 19.10
KDE Plasma Version: 5.18.3
KDE Frameworks Version: 5.67.0
Qt Version: 5.12.4
Kernel Version: 5.3.0-46-generic
OS Type: 64-bit
Processors: 8 × Intel® Core™ i7-8565U CPU @ 1.80GHz
Memory: 15,6 GiB of RAM
openjdk version "11.0.6" 2020-01-14
OpenJDK Runtime Environment (build 11.0.6+10-post-Ubuntu-1ubuntu119.10.1)
OpenJDK 64-Bit Server VM (build 11.0.6+10-post-Ubuntu-1ubuntu119.10.1, mixed mode, sharing)

LTex Version: 4.9.0,
LTex English support version: 4.9.0,
Visual Studio Code version: 1.44.1 (the standard Microsoft build).

I didn't make any changes on the extension configuration apart from setting the language to "en-US" like it is recommended.

If more information is needed, please let me know.

@valentjn
Copy link
Owner

@deividrvale As it's working for me1, precise steps to reproduce it would help a lot. On a vanilla VS Code installation, what do you have to do in order for the issue to appear? This should include all the steps, including extensions to install, text to type/documents to open, where to hover, etc.

1 I open a long document, wait one minute or so, then the LT diagnostics appear; hovering diagnostics then take 0.5s for the Quick Fix... link to appear in the popup.

@deividrvale
Copy link

deividrvale commented Apr 18, 2020

@valentjn I've tested the extension on others documents and projects of mine and it worked wonderfully. My visual studio is now the vanilla with only extensions being Latex-workshop, vscode-icons, LTex, and LTex English.

I noticed something new though, this problem seems to happens only when I ignore some rule using the option Ignore rule in this sentence.

The ignored rules goes to the file "settings.json" inside the workspace folder ".vscode". When I delete this folder close the file tab and open it again the "Checking for quick fixes..." is almost instantaneous again.

As I ignore more rules it takes longer for the "Checking for quick fixes..." add the recommended action/quick fixes. With the same problems to the CPU usage.

When you have enough rules in this file it takes a real-long time to analyze the file.

For now on I am ignoring rules by just not doing anything instead of adding them to the ignored list.

Please, let me know if this also happens with you, and I must say: thank you for all your work on this extension.

Edit:
Adding rules to the dictionary didn't had any affect on performance for me.

@Markyparky56
Copy link

Would just like to add that I've been seeing something similar to this pretty regularly, I had one "ignore rule in this sentence" entry in my settings.json. I just removed it and restarted VSCode. CPU usage has dropped to basically 0% (before it was sitting at ~14% from just the java process) and the Quick-Fix option now appears instantly instead of after several seconds or never.

@valentjn valentjn added 2-confirmed Issue status: Confirmed, reproducible bug in LTeX and removed 2-needs-info Issue status: We need more information (usually) from the submitter before continuing 2-unconfirmed Issue status: Bug that needs to be reproduced (all new bugs have this label) labels Apr 25, 2020
@valentjn valentjn added the 3-fixed Issue resolution: Issue has been fixed on the develop branch label May 1, 2020
@valentjn
Copy link
Owner

valentjn commented May 1, 2020

Thanks people for the input. I can confirm there was indeed a bug.

For the background: LT has a cache which contains a list of the recently checked sentences (all text is split into sentences by LT). With this cache, when you edit some sentence, LT doesn't have to check all the other unchanged sentences again, which saves a lot of time.

If the setting ltex.ignoreRuleInSentence was not present or just an empty list, everything was fine. However, if at least one rule/sentence pair was present in this setting, LTEX would clear the language cache on every edit. This means on every character stroke, a whole recheck of the document was triggered, which can take a while, depending on the length of document. The rechecks stacked up, so you had to wait several minutes after your final keystroke until LTEX had processed all of the rechecks.

@valentjn
Copy link
Owner

valentjn commented May 1, 2020

Fix released in 4.9.1.

@chirag127
Copy link

Thanks people for the input. I can confirm there was indeed a bug.

okay I got it what is causing high cpu , thanks for confirming the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1-bug 🐛 Issue type: Bug report (something isn't working as expected) 2-confirmed Issue status: Confirmed, reproducible bug in LTeX 3-fixed Issue resolution: Issue has been fixed on the develop branch
Projects
None yet
Development

No branches or pull requests

6 participants