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

Completion cache resets after file recompilation resulting in slow code completion #847

Closed
Yanpas opened this issue Nov 14, 2018 · 22 comments

Comments

@Yanpas
Copy link

Yanpas commented Nov 14, 2018

I have large enough project (about 8000 java files). Code completion works fast if you do not edit a file, but if you do some edits you will wait for any kind of suggestion for several seconds. Typing code becomes a headache.

STR:

  1. Open large project and one java file
  2. Try to edit some lines of code : cut and paste, request autocompletion. It should be fast
  3. Open any ten files in the same project, don't touch them, just open
  4. Repeat step 2, performance will get terribly slow.

Screencast:
peek 2018-11-14 14-42

@fbricon
Copy link
Contributor

fbricon commented Nov 14, 2018

Can you tell if it's a regression or not? What's your project topology? Maven/Gradle? Number of modules? files per modules? number of dependencies?

@Yanpas
Copy link
Author

Yanpas commented Nov 14, 2018

I can't tell whether it's a regression, since I'm using it for about one month.
Project uses Eclipse's .classpth. There are several maven and gradle projects in working tree, but maven and gradle support is disabled.

Project consists of 220 jar dependencies (<classpathentry kind="lib" in .classpath) and 80 source entries

grepped all sources and calculated number of srcs

cat .classpath | grep 'kind="src"' | awk '{print $3}' | sed -rne 's_path="(.+)".+_\1_p' > flds
cat flds | while read fl; do echo -n "$fl ";  { find $fl -name '*.java' | wc -l ; }; done

Most projects consist of about 10 source files, 10 projects about 100 files and one of more than thousand.

@Yanpas
Copy link
Author

Yanpas commented Nov 14, 2018

PC specs:
Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
32 gigs of RAM

java language server eats 4.9 gigs of RAM

java user settings:

{
   "java.completion.guessMethodArguments": true,
    "java.completion.overwrite": false,
    "java.decompiler.fernflower": {
        "udv": true,
        "ind": "    "
    },
    "java.errors.incompleteClasspath.severity": "ignore",
    "java.format.settings.profile": "GoogleStyle",
    "java.format.settings.url": "/home/yan/.config/eclipse-java-style.xml",
    "java.import.gradle.enabled": false,
    "java.jdt.ls.vmargs": "-noverify -Xmx5G -XX:+UseG1GC -XX:+UseStringDeduplication -XX:+CompactStrings",
    "java.signatureHelp.enabled": true
}

java workspace settings:

{
    "java.import.maven.enabled": false,
}

@fbricon
Copy link
Contributor

fbricon commented Nov 14, 2018

How's the performance in Eclipse?

@fbricon
Copy link
Contributor

fbricon commented Nov 14, 2018

Can you enable"java.trace.server":"verbose", then get the logs from the output view after :

  • code-completion without editing
  • code-completion while editing

@fbricon
Copy link
Contributor

fbricon commented Nov 14, 2018

do you have things like automatic save enabled?
can you try after disabling auto build ("java.autobuild.enabled": false)

@fbricon
Copy link
Contributor

fbricon commented Nov 14, 2018

Project consists of 220 jar dependencies (<classpathentry kind="lib" in .classpath) and 80 source entries

is that in just 1 project .classpath?

@Yanpas
Copy link
Author

Yanpas commented Nov 14, 2018

How's the performance in Eclipse?

Eclipse editing works fluent and instant, no matter how I edit. But the project was loading much longer (1-2 minutes I guess)

@Yanpas
Copy link
Author

Yanpas commented Nov 14, 2018

Project consists of 220 jar dependencies (<classpathentry kind="lib" in .classpath) and 80 source entries

is that in just 1 project .classpath?

yes

@Yanpas
Copy link
Author

Yanpas commented Nov 14, 2018

I've noticed that when I reloaded vscode window and relauched server it became much faster (2-3 times). Still slower than eclipse and feels lagging. But initially it consumes 2.5 gigs of ram. After 1-2 days of usage it uses max available RAM (5 gigs).

@Yanpas
Copy link
Author

Yanpas commented Nov 14, 2018

do you have things like automatic save enabled?

"files.autoSave": "off",

can you try after disabling auto build ("java.autobuild.enabled": false)

tried, didn't noticed any difference

@Yanpas
Copy link
Author

Yanpas commented Nov 14, 2018

@Yanpas
Copy link
Author

Yanpas commented Nov 14, 2018

Nonverbose log when I made some edits, entered Array and pressed code completion:

[Trace - 18:17:53] Sending notification 'textDocument/didChange'.
[Trace - 18:17:53] Sending request 'textDocument/completion - (797)'.
[Trace - 18:17:53] Received response 'textDocument/completion - (797)' in 147ms.
[Trace - 18:17:53] Sending request 'completionItem/resolve - (798)'.
[Trace - 18:17:53] Sending request 'workspace/executeCommand - (799)'.
[Trace - 18:17:53] Sending request 'textDocument/codeAction - (800)'.
[Trace - 18:17:53] Sending notification 'textDocument/didChange'.
[Trace - 18:17:53] Received response 'completionItem/resolve - (798)' in 101ms.
[Trace - 18:17:53] Sending request 'completionItem/resolve - (801)'.
[Trace - 18:17:53] Received response 'completionItem/resolve - (801)' in 2ms.
[Trace - 18:17:53] Sending notification 'textDocument/didChange'.
[Trace - 18:17:54] Sending request 'completionItem/resolve - (802)'.
[Trace - 18:17:54] Received response 'completionItem/resolve - (802)' in 3ms.
[Trace - 18:17:54] Sending notification 'textDocument/didChange'.
[Trace - 18:17:54] Sending request 'workspace/executeCommand - (803)'.
[Trace - 18:17:54] Sending request 'textDocument/codeAction - (804)'.
[Trace - 18:17:54] Sending notification '$/cancelRequest'.
[Trace - 18:17:54] Received response 'textDocument/codeAction - (800)' in 604ms. Request failed: The request (id: 800, method: 'textDocument/codeAction') has been cancelled (-32800).
[Trace - 18:17:54] Sending request 'textDocument/documentSymbol - (805)'.
[Trace - 18:17:54] Received notification 'language/progressReport'.
[Trace - 18:17:54] Received notification 'language/progressReport'.
[Trace - 18:17:55] Sending request 'completionItem/resolve - (806)'.
[Trace - 18:17:55] Received response 'completionItem/resolve - (806)' in 2ms.
[Trace - 18:17:55] Received notification 'language/progressReport'.
[Trace - 18:17:55] Received notification 'language/progressReport'.
[Trace - 18:17:55] Received notification 'textDocument/publishDiagnostics'.
[Trace - 18:17:55] Sending notification 'textDocument/didChange'.
[Trace - 18:17:55] Received notification 'textDocument/publishDiagnostics'.
[Trace - 18:17:55] Received notification 'textDocument/publishDiagnostics'.
[Trace - 18:17:55] Sending request 'workspace/executeCommand - (807)'.
[Trace - 18:17:55] Sending notification '$/cancelRequest'.
[Trace - 18:17:55] Sending request 'textDocument/documentSymbol - (808)'.
[Trace - 18:17:56] Sending request 'textDocument/codeAction - (809)'.
[Trace - 18:17:56] Sending notification '$/cancelRequest'.
[Trace - 18:17:56] Sending notification 'textDocument/didChange'.
[Trace - 18:17:56] Sending request 'textDocument/completion - (810)'.
[Trace - 18:17:56] Received notification 'textDocument/publishDiagnostics'.
[Trace - 18:17:56] Received notification 'language/progressReport'.
[Trace - 18:17:56] Received response 'textDocument/documentSymbol - (805)' in 1825ms. Request failed: The request (id: 805, method: 'textDocument/documentSymbol') has been cancelled (-32800).
[Trace - 18:17:56] Received response 'textDocument/codeAction - (804)' in 1925ms. Request failed: The request (id: 804, method: 'textDocument/codeAction') has been cancelled (-32800).
[Trace - 18:17:56] Sending request 'workspace/executeCommand - (811)'.
[Trace - 18:17:56] Sending request 'textDocument/codeAction - (812)'.
[Trace - 18:17:56] Sending notification '$/cancelRequest'.
[Trace - 18:17:56] Sending notification '$/cancelRequest'.
[Trace - 18:17:56] Sending request 'textDocument/completion - (813)'.
[Trace - 18:17:56] Sending notification '$/cancelRequest'.
[Trace - 18:17:56] Sending request 'textDocument/documentSymbol - (814)'.
[Trace - 18:17:56] Received notification 'language/progressReport'.
[Trace - 18:17:57] Received notification 'language/progressReport'.
[Trace - 18:17:57] Received notification 'language/progressReport'.
[Trace - 18:17:57] Received notification 'language/progressReport'.
[Trace - 18:17:57] Received notification 'textDocument/publishDiagnostics'.
[Trace - 18:17:57] Received notification 'textDocument/publishDiagnostics'.
[Trace - 18:17:57] Received notification 'textDocument/publishDiagnostics'.
[Trace - 18:17:58] Sending request 'textDocument/codeAction - (815)'.
[Trace - 18:17:58] Sending notification '$/cancelRequest'.
[Trace - 18:17:58] Received notification 'textDocument/publishDiagnostics'.
[Trace - 18:17:58] Received notification 'language/progressReport'.
[Trace - 18:17:58] Received response 'workspace/executeCommand - (799)' in 4611ms.
[Trace - 18:17:58] Received response 'workspace/executeCommand - (803)' in 4008ms.
[Trace - 18:17:58] Received response 'textDocument/codeAction - (809)' in 2439ms.
[Trace - 18:17:58] Received response 'workspace/executeCommand - (807)' in 2657ms.
[Trace - 18:17:58] Received response 'textDocument/documentSymbol - (808)' in 2557ms.
[Trace - 18:17:58] Received response 'textDocument/completion - (810)' in 2297ms.
[Trace - 18:17:58] Received response 'workspace/executeCommand - (811)' in 2054ms.
[Trace - 18:17:58] Received response 'textDocument/codeAction - (812)' in 2054ms.
[Trace - 18:17:58] Received response 'textDocument/completion - (813)' in 2058ms.
[Trace - 18:17:58] Received response 'textDocument/codeAction - (815)' in 469ms.
[Trace - 18:17:58] Received response 'textDocument/documentSymbol - (814)' in 1985ms.
[Trace - 18:17:58] Sending request 'completionItem/resolve - (816)'.
[Trace - 18:17:58] Received response 'completionItem/resolve - (816)' in 2ms.

@fbricon
Copy link
Contributor

fbricon commented Nov 14, 2018

can you disable all java extensions but the red hat one?

@Yanpas
Copy link
Author

Yanpas commented Nov 14, 2018

Still the same. about 4 seconds it takes to execute textDocument/documentSymbol

@Yanpas
Copy link
Author

Yanpas commented Apr 8, 2019

Finally I've pointed out the reason of lags. No matter how much edits you do to the current file and how often do you save it.

  1. Open large project and one java file
  2. Try to edit some lines of code : cut and paste, request autocompletion. It should be fast
  3. Open any ten files in the same project, don't touch them, just open
  4. Repeat step 2, performance will get terribly slow. (I see Validate documents progress bar on each edit, but seems it's progress bar is unrelated to performance)

@fbricon
Copy link
Contributor

fbricon commented Apr 8, 2019

Thanks for the heads up, that's very useful information. @snjeza is currently looking at some performance improvements that might help here (or not)

@snjeza snjeza self-assigned this Apr 8, 2019
@Yanpas
Copy link
Author

Yanpas commented Apr 9, 2019

It also looks like closing files gets good performance back. I've made two profiling samples: 1 (one file opened) and M (about 12 files opened):

tmp.zip

@snjeza
Copy link
Contributor

snjeza commented Apr 9, 2019

@Yanpas
Copy link
Author

Yanpas commented Apr 9, 2019

@snjeza yeah, much better, I think it resolves this issue.

@fbricon
Copy link
Contributor

fbricon commented Apr 9, 2019

@snjeza which changes are in your custom build? all of the pending PRs?

@snjeza
Copy link
Contributor

snjeza commented Apr 9, 2019

@snjeza which changes are in your custom build? all of the pending PRs?

@fbricon I have created a new PR.

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

No branches or pull requests

3 participants