redhat-developer / vscode-java

Java Language Support for Visual Studio Code
Eclipse Public License 2.0
2.07k stars 430 forks source link

Slow builds due to large number of project files #2982

Closed Carson-yy closed 1 year ago

Carson-yy commented 1 year ago

d0bc8853 Building [Done] 85a443d4 Validate documents [Done] 99449c46 Building: 85% Refreshing '/cloudeasy-cloudmanage'. [854/1000]

Many project files, frequent Building, smart code hints and slow jumps!!!(较大项目开发过程中,编写代码过程中频繁编译,经常出现代码提示慢,跳转实现慢甚至语法检测都会延迟好几秒才会完成!)

image image

parthasaradhie commented 1 year ago

I'm also facing the same issue. Where if you Java project is monolithic with large files or a single Java file containing more than 400 line of code everything becomes slow

snjeza commented 1 year ago

@yaegar @parthasaradhie could you attach a project example reproducing the issue?

parthasaradhie commented 1 year ago

I can't share the logs and project details because of company security policy. But few details like It's spring boot project with more than 200 Java classes and if the file has more than 400 lines then the content assist and cmd+click on method is slow

Other than that if file is small then it's almost smooth

Mac os Intel chip Java server is running default Java 17

Carson-yy commented 1 year ago

I can't share the logs and project details because of company security policy. But few details like It's spring boot project with more than 200 Java classes and if the file has more than 400 lines then the content assist and cmd+click on method is slow

Other than that if file is small then it's almost smooth

Mac os Intel chip Java server is running default Java 17

me too

snjeza commented 1 year ago

I can't share the logs and project details because of company security policy. But few details like It's spring boot project with more than 200 Java classes and if the file has more than 400 lines then the content assist and cmd+click on method is slow Other than that if file is small then it's almost smooth

Could you provide more details? How long does it take? Could you show your settings.json? Do you have some other extensions? Do you use lombok?

parthasaradhie commented 1 year ago

Here is video recording for above scenario.

  1. content assist is too slow
  2. The error line processing very slow

https://user-images.githubusercontent.com/12638462/224463780-4acdbb68-fd45-462f-9ef1-19f6705019ea.mp4

Attaching the detailed log (class names and file names are obscured) https://gist.github.com/parthasaradhie/34bca17c57e45e39e5a0bb35621ed9f6

snjeza commented 1 year ago

@parthasaradhie Which VS Code version are you using? Could you show your server log?

parthasaradhie commented 1 year ago

Vscode Version: 1.76.0 Language Support for Java(TM) by Red Hat: 1.15 Debugger for Java: v0.49.2023022723 IntelliCode: v1.2.30 Maven for Java: v0.40.4 Project Manager for Java: v0.21.1

Also one more point is if i run the springboot application in Debug mode. the content assist and all other functionalities will become even slower of response time of more than 10-15 seconds

Here are the server logs: https://gist.github.com/parthasaradhie/79c82e3a9dbd10c21c64d9b24d38f395

snjeza commented 1 year ago

@parthasaradhie @yaegar Could you test VS Code 1.16.3?

parthasaradhie commented 1 year ago

@snjeza Good work Few Observation after testing:

  1. Not only content assist but everything became lot faster than before like 100% faster (reference, method usages and all)
  2. Lombok is completely broken not at all working

Let me know if anything else needed to test.

snjeza commented 1 year ago

Lombok is completely broken not at all working

@parthasaradhie You may want to take a look at https://github.com/redhat-developer/vscode-java/issues/2983#issuecomment-1458753354

parthasaradhie commented 1 year ago

@snjeza I have enabled the Lombok and getting the same issue as above with 1.16.3 It decreased the performance

snjeza commented 1 year ago

@parthasaradhie I can't reproduce the issue.

lombok5

You can enable lombok with 1.16.3. Could you show your settings.json?

parthasaradhie commented 1 year ago

@snjeza I have successfully enabled the lombok. Its working as expected. But The content assist, method reference navigation performances has degraded a lot 1.16.3 doesnt improve any performance, show similar effects as shown in the above video of mine

But one thing I noted is if i disable the lombok everything is working smooth.

` "java.configuration.maven.notCoveredPluginExecutionSeverity": "ignore",

"java.autobuild.enabled": false,

"java.jdt.ls.lombokSupport.enabled": false,

"java.jdt.ls.vmargs": "-XX:+UseParallelGC -XX:GCTimeRatio=4 -XX:MetaspaceSize=300M -XX:AdaptiveSizePolicyWeight=90 -Dsun.zip.disableMemoryMapping=true -Xmx5G -Xms2G -Xlog:disable -XX:-HeapDumpOnOutOfMemoryError -javaagent:{{extensionpath}}/redhat.java-1.15.0-darwin-x64/lombok/lombok-1.18.24.jar", `

snjeza commented 1 year ago

@parthasaradhie could you try to set

"java.references.includeAccessors": false,
"java.implementationsCodeLens.enabled": false,
"java.referencesCodeLens.enabled": false,
"java.jdt.ls.vmargs": "-XX:+UseParallelGC -XX:GCTimeRatio=4 -XX:MetaspaceSize=300M -XX:AdaptiveSizePolicyWeight=90 -Dsun.zip.disableMemoryMapping=true -Xmx5G -Xms2G -Xlog:disable -XX:-HeapDumpOnOutOfMemoryError -javaagent:<path_to_lombok-1.18.27.jar.jar",

lombok-1.18.27

could you show your pom.xml or build.gradle?

parthasaradhie commented 1 year ago

@snjeza I cant provide the pom.xml And I can confirm we are not doing much processing or have plugins installed only docker (runs at delploy time) and de-lombok(runs at compile time)

used your lombok 1.18.27 in settings.xml and pom.xml(1.18.26)

content assist :

Red squiggly line (shows error)

Got this below error one time :

[Error - 01:22:16] Client Language Support for Java: connection to server is erroring. Shutting down server.
[Error - 01:22:16] Client Language Support for Java: connection to server is erroring. Shutting down server.
[Error - 01:22:16] Client Language Support for Java: connection to server is erroring. Shutting down server.
[Error - 01:22:18] Stopping server timed out
[Error - 01:22:18] Stopping server failed
Error: Stopping the server timed out
    at //extensions/redhat.java-1.16.3/dist/extension.js:2:918472
[Error - 01:22:18] Stopping server failed
Error: Stopping the server timed out
    at //extensions/redhat.java-1.16.3/dist/extension.js:2:918472
[Error - 01:22:18] Stopping server failed
Error: Stopping the server timed out
    at /extensions/redhat.java-1.16.3/dist/extension.js:2:918472
WARNING: Using incubator modules: jdk.incubator.foreign, jdk.incubator.vector
[Error - 01:22:31] Client Language Support for Java: connection to server is erroring. Shutting down server.
[Error - 01:22:31] Client Language Support for Java: connection to server is erroring. Shutting down server.
snjeza commented 1 year ago

used your lombok 1.18.27 in settings.xml and pom.xml(1.18.26)

It is fine.

cmd+space is still slow after "." like (test.(cmd+spce)) but results are getting <6 sec

@parthasaradhie Could you describe the test class?

parthasaradhie commented 1 year ago

@snjeza

the test class has 1500 lines of code with almost 70 imports (56 are lombok classes) use spring boot @autowired for dependency injection approximately 30 methods are there (16 are public) our project uses close to 150 dependencies using maven

snjeza commented 1 year ago

@parthasaradhie Could you show an example of your lombok class?

Could you try to set the following properties:

"java.references.includeAccessors": false,
"java.inlayHints.parameterNames.enabled": "none",
"java.implementationsCodeLens.enabled": false,
"java.referencesCodeLens.enabled": false,
"java.configuration.maven.defaultMojoExecutionAction": "ignore",
"java.completion.postfix.enabled": false,
"editor.snippetSuggestions": "none",
"java.completion.matchCase": "off",
"java.completion.maxResults": 100,
parthasaradhie commented 1 year ago

@snjeza

snjeza commented 1 year ago

@parthasaradhie Could you check https://github.com/snjeza/vscode-test/raw/master/java-1.16.4.vsix ? You can check the issue with or without the properties from https://github.com/redhat-developer/vscode-java/issues/2982#issuecomment-1465313123

parthasaradhie commented 1 year ago

@snjeza

My Observations for above build:

  1. automatic content assist(like on . or type) is faster than previous build with and without that settings.
  2. content assist with manual trigger like cmd+space is also improved with and without that settings.
  3. content assist after new keyword is slow for both manual and automatic with and without that settings.
  4. The error Red squiggly line is still laggay and taking 3-5 sec to respond with and without that settings.
  5. The only difference for applying the above setting is, with above settings applied and after we open the large java file imminently content assist will work faster. wherein if that is removed content assist will work faster after everything loads
snjeza commented 1 year ago

@parthasaradhie Could you check https://github.com/snjeza/vscode-test/raw/master/java-1.16.5.vsix

  1. The error Red squiggly line is still laggay and taking 3-5 sec to respond with and without that settings.

I can't reproduce this. Could you provide more details?

parthasaradhie commented 1 year ago

@snjeza

Attaching a video for your reference . here you can observer the red line even to show that there is a error takes 5sec and to disappear that red line is very laggy and the file is > 1500 lines (used the above config you have provided and using 1.16.5 provided above) attaching logs for the same : https://gist.github.com/parthasaradhie/c3c6a17cff8129c6a457cec55636a8e1

https://user-images.githubusercontent.com/12638462/225063759-aef46aae-a11f-4b98-ad61-77d1a6266999.mov

snjeza commented 1 year ago

here you can observer the red line even to show that there is a error takes 5sec and to disappear that red line is very laggy and the file is > 1500 lines

@parthasaradhie Do you mean on a red line in the editor?

I have checked your log and completion lasts <= 1116ms (1.1second)

parthasaradhie commented 1 year ago

@snjeza

Exactly I'm confused after seeing logs, in the video it's clearly seen its defenetly taking more than 4 seconds. I think either there might be issue in log time calculation or if server is really responding in 1.1 Sec the why is it taking 4 sec to reflect in the UI

I tried with my colleague Mac machine the behaviour is still the same

snjeza commented 1 year ago

Exactly I'm confused after seeing logs, in the video it's clearly seen its defenetly taking more than 4 seconds.

@parthasaradhie Does it only happen the first time?

parthasaradhie commented 1 year ago

@snjeza it happens all the time but only in these kind of large files >500 line or lot of Lombok classes imported like that

snjeza commented 1 year ago

@parthasaradhie Does 1.16.5 improves CA compared to pre release or 1.15?

... lot of Lombok classes imported like that

I will try to simulate this case. Which lombok annotations are you using?

parthasaradhie commented 1 year ago

@snjeza Every pojo class is created with Lombok in this repo Every pojo has @data @NoargConstructor @Allargconstructor @builder

snjeza commented 1 year ago

Exactly I'm confused after seeing logs, in the video it's clearly seen its defenetly taking more than 4 seconds.

@parthasaradhie Could you, please, add

"java.jdt.ls.vmargs": "-Dlog.level=ALL -Djdt.ls.debug=false <your_vmargs>",

and repeat your screencast and/or log?

parthasaradhie commented 1 year ago

@snjeza

Sharing the video for the same. Here there is a record where response time is 3.9 sec also sharing logs for the same. One observation I found here is LS is processing all the opened files in the editor irrespective of the file I'm editing.

Test2.java is exact replica of Test.java Like in the below Video you can see Two files Test.java, Test2.java opened in VScode even though i'm editing only Test.java in logs I can see LS is processing the Two files. See if this helps in improving it.

If I close the Test2.java LS is not processing the Test2.java but only the file that im editing(Test.java).

https://gist.github.com/parthasaradhie/f74fa76ee00233104019c906b1135b25

https://user-images.githubusercontent.com/12638462/225188419-d2c5367f-2bbb-47b2-92df-9f8836b9aaf6.mov

snjeza commented 1 year ago

Sharing the video for the same. Here there is a record where response time is 3.9 sec also sharing logs for the same.

Could you, please, check how it works without lombok?

One observation I found here is LS is processing all the opened files in the editor irrespective of the file I'm editing.

We have to process all opened files. It is possible that editing Test.java fixes or introduces an error in Test2.java. Steps to reproduce:

parthasaradhie commented 1 year ago

@snjeza

Could you, please, check how it works without lombok?

I have repetead the same test on the same project DE-lomboked (using delomboked plugin) Observations

https://gist.github.com/parthasaradhie/eec24a25fb187f7c50e8c974a7545564

https://user-images.githubusercontent.com/12638462/225515299-590b1070-10d6-4b7e-89bd-165e05abe113.mov

snjeza commented 1 year ago

I feel because of some lombok processing its getting lagged.

You are right. Lombok injects its own ast parser - https://github.com/projectlombok/lombok/blob/master/src/core/lombok/eclipse/EclipseAST.java#L62 Are you using lombok.config?

parthasaradhie commented 1 year ago

Are you using lombok.config?

Nope this project desnt uses any custom config

snjeza commented 1 year ago

@parthasaradhie Could you try to add

"java.jdt.ls.vmargs": "-Dlombok.disableConfig=true -Dlog.level=ALL -Djdt.ls.debug=false <your_vmargs>",
parthasaradhie commented 1 year ago

@snjeza its still the same content assist is lot faster but error red line and method (cmd+click) is slower.

snjeza commented 1 year ago

...but error red line...


public class Test {
private void Test() {
}

}



@parthasaradhie Could you try to replace `private void Test() ` with `private void test()`?
snjeza commented 1 year ago

... method (cmd+click) is slower

It should be faster with -Dlombok.disableConfig=true especially if your packages have many segments/directories.

parthasaradhie commented 1 year ago

@snjeza your right, I have been using your extension for a while with above settings, content assist ,method navigation and Lombok processing works faster than the base extension version. But one notable difference is it not as fast as intellij editor but its faster to an acceptable usage. Appreciate your hardwork 9n this Basically I want to replace intellij with vscode here

rgrunber commented 1 year ago

Definitely lombok related (see bottom).

image

snjeza commented 1 year ago

@parthasaradhie @rgrunber Could you check https://github.com/snjeza/vscode-test/raw/master/java-1.17.3.vsix

settings.json

"java.jdt.ls.vmargs": "-Dlombok.disableConfig=true -Dlog.level=ALL -Djdt.ls.debug=false -javaagent:/path_to_lombok-1.18.27.jar<your_vmargs>",
"java.jdt.ls.lombokSupport.enabled": false,
rgrunber commented 1 year ago

Is there anything left to do here or can this be closed due to https://github.com/eclipse/eclipse.jdt.ls/pull/2535 & https://github.com/eclipse/eclipse.jdt.ls/pull/2574 .