eclipse.jdt.ls icon indicating copy to clipboard operation
eclipse.jdt.ls copied to clipboard

VSCode JLS error when loading project with lot of Maven sub modules

Open snjeza opened this issue 1 year ago • 11 comments

Fixes https://github.com/redhat-developer/vscode-java/issues/3637

Steps to reproduce:

  1. exit VS Code
  2. Clean the workspace directory
  3. clone the repository quarkus-langchain4j
  4. cd quarkus-langchain4j
  5. code .
  6. wait for the build to finish
  7. reload the VS Code window (it freezes without the PR; takes several seconds with the PR or VS Code 1.32.0)

Test vsix

snjeza avatar May 06 '24 00:05 snjeza

@snjeza could you pls explain the root cause of this issue?

testforstephen avatar May 06 '24 05:05 testforstephen

could you pls explain the root cause of this issue?

There are several issues:

  1. ProjectManager.registerWatchers() is called too early -https://github.com/eclipse-jdtls/eclipse.jdt.ls/pull/3150/commits/cfb076c10a86523d734942f29364d0d90aa6634f#diff-f82616576dc1fa363177feaadbbde3568ec33ec20588a8e7656ba45ded34bc52R330
  2. StandardProjectsManager.configureSettings(Preferences, boolean) is always called from InitHandler.triggerInitialization(Collection<IPath>) line 292 - IProjectsManager.registerListeners()
  3. JavaCore.setOptions() is called even when the options have not been changed. It causes rebuild - https://github.com/eclipse-jdtls/eclipse.jdt.ls/pull/3150/commits/cfb076c10a86523d734942f29364d0d90aa6634f#diff-f23d0258ce24117c110acd6753e8490a09fbdf0bc039d662bdffe279c8c28469R362
  4. Java LS updates maven projects always if the root maven project has the .mvn directory - https://github.com/eclipse-jdtls/eclipse.jdt.ls/pull/3150/commits/cfb076c10a86523d734942f29364d0d90aa6634f#diff-4b8c66d1045232aafc8ad5fc1c52decc87f1e67eb86815b224de947215ba48d2R197

snjeza avatar May 06 '24 18:05 snjeza

test this please

snjeza avatar May 06 '24 18:05 snjeza

From testing this out, I don't see a major improvement in terms of build time or memory :

On quarkus-langchain4j project : Prior to this change, initialization & "service ready" took about 75s and build time took around 190s. With this change, it's about the same (based on report from telemetry/event).

Without PR Screenshot from 2024-05-07 14-49-14

With PR Screenshot from 2024-05-07 14-57-58

We can still look at the changes here on their own based on whether they are an improvement (logically) but it's probably best if the commenters on MacOS can verify whether the change does anything for them in the issue.

rgrunber avatar May 07 '24 19:05 rgrunber

@rgrunber Could you try to restart the server after it has been successfully built? When restarting, the server freezes without the patch. With the patch, it takes several seconds. I suppose @philippart-s and @maxandersen have faced the issue when restarting the server,

@rgrunber You can try to restart the keycloak with and without the PR too - https://github.com/redhat-developer/vscode-java/issues/3639

snjeza avatar May 07 '24 20:05 snjeza

@rgrunber I have updated the steps to reproduce. See steps 6 and 7 - https://github.com/eclipse-jdtls/eclipse.jdt.ls/pull/3150#issue-2279821730 Step 6 works with and without the PR. The issue happens in step 7. It can't be reproduced in Eclipse.

snjeza avatar May 07 '24 21:05 snjeza

@rgrunber The workspace is always rebuilt when "java.jdt.ls.lombokSupport.enabled": true. Try to set "java.jdt.ls.lombokSupport.enabled": false and restart the workspace.

Note: quarkus-langchain4j and keycloak have been built properly. my settings.json:

{
    "java.import.generatesMetadataFilesAtProjectRoot": true,
    "java.compile.nullAnalysis.mode": "disabled",
    "java.gradle.buildServer.enabled": "off",
    "java.server.launchMode": "Standard",
    "java.jdt.ls.vmargs": "-Dlog.level=ALL -Djdt.ls.debug=true -XX:+UseParallelGC -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -Dsun.zip.disableMemoryMapping=true -Xmx6G -Xms512m -Xlog:disable",
    "java.import.exclusions": [
        "**/node_modules/**",
        "**/node/**",
        "**/js/**",
        "**/distribution/**",
        "**/themes/**",
        "**/testsuite/**",
    ],
    "java.trace.server": "messages",
    "java.jdt.ls.lombokSupport.enabled": false,

reload

snjeza avatar May 09 '24 12:05 snjeza

I'm pretty confident this will improve things. In particular (prior to this PR), If I attempted to reload the workspace, I would see :

image

Basically a bunch of jobs to update individual projects. With your PR, this no longer happens and the language server never gets stuck or runs out of memory.

I did notice there's some extra build jobs in the case of lombok support being enabled but at least the builds were not getting stuck. I think all that's left for me is to go through each of the changes.

rgrunber avatar May 09 '24 16:05 rgrunber

Was the use of of Lombok the trigger or how?

maxandersen avatar May 09 '24 19:05 maxandersen

Was the use of of Lombok the trigger or how?

@maxandersen There are several issues. Please see https://github.com/eclipse-jdtls/eclipse.jdt.ls/pull/3150#issuecomment-2096688871

snjeza avatar May 09 '24 19:05 snjeza

Basically a bunch of jobs to update individual projects. With your PR, this no longer happens and the language server never gets stuck or runs out of memory.

@rgrunber Please see https://github.com/eclipse-jdtls/eclipse.jdt.ls/pull/3150#issuecomment-2096688871 issue 4

snjeza avatar May 09 '24 19:05 snjeza

@rgrunber I have updated the PR.

snjeza avatar May 15 '24 21:05 snjeza

test this please

snjeza avatar May 16 '24 00:05 snjeza

Only other change I would make is to the commit message. Rename this to something like :

@rgrubner I have done it.

snjeza avatar May 17 '24 18:05 snjeza