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

Improve order of operations when importing multi-module Maven projects. #3150

Merged
merged 1 commit into from
May 17, 2024

Conversation

snjeza
Copy link
Contributor

@snjeza snjeza commented May 6, 2024

Fixes redhat-developer/vscode-java#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

@testforstephen
Copy link
Contributor

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

@snjeza
Copy link
Contributor Author

snjeza commented May 6, 2024

could you pls explain the root cause of this issue?

There are several issues:

  1. ProjectManager.registerWatchers() is called too early -cfb076c#diff-f82616576dc1fa363177feaadbbde3568ec33ec20588a8e7656ba45ded34bc52R330
  2. StandardProjectsManager.configureSettings(Preferences, boolean) is always called from InitHandler.triggerInitialization(Collection) line 292 - IProjectsManager.registerListeners()
  3. JavaCore.setOptions() is called even when the options have not been changed. It causes rebuild - cfb076c#diff-f23d0258ce24117c110acd6753e8490a09fbdf0bc039d662bdffe279c8c28469R362
  4. Java LS updates maven projects always if the root maven project has the .mvn directory - cfb076c#diff-4b8c66d1045232aafc8ad5fc1c52decc87f1e67eb86815b224de947215ba48d2R197

@snjeza
Copy link
Contributor Author

snjeza commented May 6, 2024

test this please

@snjeza snjeza changed the title [WIP] VSCode JLS error when loading project with lot of Maven sub modules VSCode JLS error when loading project with lot of Maven sub modules May 6, 2024
@snjeza snjeza removed the in progress label May 6, 2024
@rgrunber
Copy link
Contributor

rgrunber commented May 7, 2024

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.

@snjeza
Copy link
Contributor Author

snjeza commented May 7, 2024

@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 - redhat-developer/vscode-java#3639

@snjeza
Copy link
Contributor Author

snjeza commented May 7, 2024

@rgrunber I have updated the steps to reproduce. See steps 6 and 7 - #3150 (comment)
Step 6 works with and without the PR. The issue happens in step 7. It can't be reproduced in Eclipse.

@snjeza
Copy link
Contributor Author

snjeza commented May 9, 2024

@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

@rgrunber
Copy link
Contributor

rgrunber commented May 9, 2024

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.

@maxandersen
Copy link

Was the use of of Lombok the trigger or how?

@snjeza
Copy link
Contributor Author

snjeza commented May 9, 2024

Was the use of of Lombok the trigger or how?

@maxandersen There are several issues. Please see #3150 (comment)

@snjeza
Copy link
Contributor Author

snjeza commented May 9, 2024

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 #3150 (comment) issue 4

Copy link
Contributor

@rgrunber rgrunber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few questions and comments.

@@ -577,7 +580,7 @@ public void didChangeConfiguration(DidChangeConfigurationParams params) {
try {
boolean isAutobuildEnabled = preferenceManager.getPreferences().isAutobuildEnabled();
boolean autoBuildChanged = ProjectsManager.setAutoBuilding(isAutobuildEnabled);
if (jvmChanged || nullAnalysisOptionsUpdated && isAutobuildEnabled) {
if ((jvmChanged || nullAnalysisOptionsUpdated) && isAutobuildEnabled) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! So if we had any old issues of builds being triggered on a jvm change / null analsysis options update despite it being off, this would fix that also ?

Comment on lines +201 to +211
boolean hasMavenProjects = false;
for (IProject project : ProjectUtils.getAllProjects()) {
if (ProjectUtils.isMavenProject(project)) {
hasMavenProjects = true;
break;
}
}
projectManager.setShouldUpdateProjects(hasMavenProjects);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't the part in the else always need to run because update(Preferences) is guaranteed to be called from BaseInitHandler.handleInitializationOptions(..) ? That runs before the build is finished so this is definitely always triggered.

If so then I would think you don't need the shouldUpdateProjects API, but let me know if I'm wrong.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@snjeza snjeza changed the title VSCode JLS error when loading project with lot of Maven sub modules [WIP] VSCode JLS error when loading project with lot of Maven sub modules May 15, 2024
@snjeza
Copy link
Contributor Author

snjeza commented May 15, 2024

@rgrunber I have updated the PR.

@snjeza snjeza changed the title [WIP] VSCode JLS error when loading project with lot of Maven sub modules VSCode JLS error when loading project with lot of Maven sub modules May 15, 2024
@snjeza snjeza changed the title VSCode JLS error when loading project with lot of Maven sub modules [WIP] VSCode JLS error when loading project with lot of Maven sub modules May 15, 2024
@snjeza snjeza changed the title [WIP] VSCode JLS error when loading project with lot of Maven sub modules VSCode JLS error when loading project with lot of Maven sub modules May 16, 2024
@snjeza
Copy link
Contributor Author

snjeza commented May 16, 2024

test this please

@rgrunber rgrunber added this to the End May 2024 milestone May 17, 2024
Copy link
Contributor

@rgrunber rgrunber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Improve order of operations when importing multi-module Maven projects.

- Reduce unnecessary calls to updating projects

- Reduce unnecessary calls to updating projects

Signed-off-by: Snjezana Peco <snjezana.peco@redhat.com>
@snjeza
Copy link
Contributor Author

snjeza commented May 17, 2024

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

@rgrubner I have done it.

@rgrunber rgrunber changed the title VSCode JLS error when loading project with lot of Maven sub modules Improve order of operations when importing multi-module Maven projects. May 17, 2024
@rgrunber rgrunber merged commit bfd86a5 into eclipse-jdtls:master May 17, 2024
6 of 7 checks passed
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

Successfully merging this pull request may close these issues.

bug: 🐛 VSCode JLS error when loading project with lot of Maven sub modules
4 participants