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

VSCode reloads Java projects on each startup which takes a very long time #2643

Closed
xxc-zsz opened this issue Aug 23, 2022 · 44 comments
Closed
Labels
need verify The fix is available, need verify from user performance

Comments

@xxc-zsz
Copy link

xxc-zsz commented Aug 23, 2022

I am in the process of switching from Eclipse to VSCode for Java Development - so far, I have been able to setup a workspace folder with all my Java projects in it and all works fine.

However, every time I restart VSCode, all projects are rebuilding (showing me "Opening Java Projects: check details") which takes a very long time (about 5 minutes) - in comparision, when I am re-opening my Eclipse workspace with the same amount of projects, it only takes ~30 seconds for everything to be ready. Is there something I am doing wrong or can't VSCode "remember" Java projects as good as Eclipse?

@snjeza
Copy link
Contributor

snjeza commented Aug 23, 2022

@xxc-zsz What OS are you using? Do you use maven, gradle?

@THWU
Copy link

THWU commented Aug 24, 2022

Hi @snjeza
I had a similar problem, but my situation was that the build stalled.
This issue affects other features of VSCode (such as Source Control)
If I disable "Language Support for Java(TM)" extension, source control works fine.
This problem had begun in the last few days

Maven project
VSCode: v1.70.2
Language Support for Java(TM): v1.9.0

@THWU
Copy link

THWU commented Aug 24, 2022

Hi @snjeza I had a similar problem, but my situation was that the build stalled. This issue affects other features of VSCode (such as Source Control) If I disable "Language Support for Java(TM)" extension, source control works fine. This problem had begun in the last few days

Maven project VSCode: v1.70.2 Language Support for Java(TM): v1.9.0

I found #2577 (comment) can solve my problem.
Sorry, i miss this issue.

@jdneo
Copy link
Collaborator

jdneo commented Oct 25, 2022

@xxc-zsz Did you still observe the problem with the latest pre-release? There are several fixes regarding perf done recently.

You can click this button to turn on the pre-release channel
image

@jdneo jdneo added the need verify The fix is available, need verify from user label Oct 25, 2022
@youngky-h
Copy link

I have same problem here... I run vscode server in docker container. It took more than 5 minutes for loading java project...

System used:
Host: ubuntu 22.04
Docker Image: ubuntu 20.04
VSCode: 1.74.1
Language Support For Java: 1.13.0
Java on Docker: OpenJDK 11.0.17

@benjaminbauer
Copy link

benjaminbauer commented Jan 3, 2023

I am experiencing the same problem running in a devcontainer. The project does not even contain much Java, it is mostly used to build things with maven.

Host: MacOs (aarch64)
Docker image (devcontainer): bullseye
VS Code: 1.74.2
Language Support For Java: 1.13.0
openjdk version "17.0.5" 2022-10-18 LTS

My initial thought was, that file I/O on docker on macOs is not the fastest. This can be improved by making the used folder a volume. Can someone tell me, what folder this extension puts its index in (assuming the indexing of the project is the slow part)?

I tried the pre-release version, did not noticeably differ wrt this issue. The task seems stuck on one item when reading the saved build state. Once that is done, it finishes almost instantly.

14c87596 Repository registry initialization [Done]
8dfb9fde Importing Maven project(s) [Done]
00df47a1 Synchronizing projects [Done]
3c3fe080 Synchronizing projects [Done]
25a05498 Background task: 50% Reading saved build state for project XXX [495/1000]

@tarekahf
Copy link

tarekahf commented Apr 2, 2023

I'm facing the same problem and switched back to eclipse. Any update on this issue?

@tarekahf
Copy link

In eclipse, it take less than a minute to load several huge java projects and you are ready to run the tests. But, in vscode, you have to wait until you see the thumbs up icon in the status bar, which can take between 2 to 5 minutes for one maven project with 5 relatively large modules. During the loading process, nothing works like intelisens, running tests... etc.. You have to sit and wait...

@snjeza
Copy link
Contributor

snjeza commented Apr 27, 2023

@GourabIX @tarekahf Could you, please, provide a project example?

@jcgaming-official
Copy link

I am facing the same problem, any update regarding this issue?

@snjeza
Copy link
Contributor

snjeza commented May 7, 2023

@jcgaming-official You can try to set

"java.jdt.ls.vmargs": "-Daether.dependencyCollector.impl1=df <your VM args",

to your settings.json.
Could you provide a project example?

@tarekahf
Copy link

tarekahf commented May 7, 2023

Try this project to reproduce the issue:

https://github.com/javalite/jar-explorer

Everytime you open the project, open a Java source file and watch how the code is being compiled. This is a small project so compilation might finish quickly. But, it will always compile and you can click on view details to see the progress in the terminal window.

Let me if you need more information...

@rajmetti
Copy link

facing the same issue, at first vs code opened projects very fast like 1 or 2 mins, don't know what happened after updating in oct/ nov in 2023, every time i open java project in vscode, it is taking like 20 mins to load all the projects.

@tarekahf
Copy link

facing the same issue, at first vs code opened projects very fast like 1 or 2 mins, don't know what happened after updating in oct/ nov in 2023, every time i open java project in vscode, it is taking like 20 mins to load all the projects.

You mean Oct/Nov 2022?

@rajmetti
Copy link

my bad, yes that is 2022

@overtomanu
Copy link

overtomanu commented Nov 1, 2023

I am still facing this issue on Oct / Nov 2023 on Fedora. My Java spring boot projects are cleaned on startup causing protobuf generated sources to be not present in maven submodule, which then shows redlines all over the place on other submodules which depend on it.

@tarekahf
Copy link

tarekahf commented Nov 1, 2023

I'm always facing the same problem. It takes about 7 minutes to load and run the unit test in VS code. In eclipse, for the same project, it takes 40 seconds.

@snjeza
Copy link
Contributor

snjeza commented Nov 1, 2023

@overtomanu @tarekahf Could you, please, provide a project example?

@tarekahf
Copy link

tarekahf commented Nov 1, 2023

@overtomanu @tarekahf Could you, please, provide a project example?

I already provided one, see my previous post above. I'll try to make a screen recording for both.

@overtomanu
Copy link

overtomanu commented Nov 2, 2023

@snjeza I have opened around 8 to 10 work related projects. These projects are spring boot projects with some of them having proto files, nothing out of the ordinary. I will try to get sample project's to reproduce this issue when i get time.

@Alirez14
Copy link

Alirez14 commented Apr 11, 2024

I also have problems here please improve this it takes 35 min each time to load the project, and I need to use lightweight mode but then I cannot debug it's so annoying
@jdneo I use the pre-release version

@jcgaming-official
Copy link

I also have problems here please improve this it takes 35 min each time to load the project, and I need to use lightweight mode but then I cannot debug it's so annoying @jdneo I use the pre-release version

I found a solution and it us the best. To fix this issue, just switch your OS into Linux. Yes I am using that now and it's open smoothly

@cervantesandres
Copy link

I'm facing the same problem. I have about 70 java projects and it's taking more than 35 minutes. Not sure why it has to reload everything. It should just be reloading the deltas.

@snjeza
Copy link
Contributor

snjeza commented May 20, 2024

@cervantesandres Could you try VS Code Pre-Release? It includes the fix for #3637

@cervantesandres
Copy link

@snjeza Could you clarify what you're referring to by "VS Code Pre-Release"?

@fbricon
Copy link
Collaborator

fbricon commented May 20, 2024

Select the pre-release vscode-java version

Screenshot 2024-05-21 at 01 44 18

@cervantesandres
Copy link

cervantesandres commented May 21, 2024

@fbricon @snjeza Switching to Pre-Release didn't resolve the issue; Java building still takes around 35 minutes.
Seems like every class is getting compiled when the plugin opens

image

@snjeza
Copy link
Contributor

snjeza commented May 21, 2024

@cervantesandres Could you try the steps from eclipse-jdtls/eclipse.jdt.ls#3150 (comment)? Step 6 (building) is the same, but step 7 (reloading) has improved significantly.

@cervantesandres
Copy link

@snjeza to clarify, you want me to try these 7 steps?
image

@snjeza
Copy link
Contributor

snjeza commented May 21, 2024

to clarify, you want me to try these 7 steps?

Yes. You should use your project instead of quarkus-langchain4j

@cervantesandres
Copy link

@snjeza I followed the steps you recommended, yet I'm still experiencing no improvement in time efficiency. My workspace comprises 70 repositories, each of which is a Java project.

@cervantesandres
Copy link

@snjeza I'd appreciate the opportunity to discuss what I'm seeing over a call. Could you please let me know your availability so we can arrange a suitable time?

@snjeza
Copy link
Contributor

snjeza commented May 21, 2024

@cervantesandres You have to wait for the build to finish in step 6.

@cervantesandres
Copy link

@snjeza I've revised the steps, and now the process takes between 8 to 12 minutes. While it's an improvement, waiting for the Java reload to complete still feels too long.

@snjeza
Copy link
Contributor

snjeza commented May 23, 2024

@cervantesandres Could you provide your project? You can send it to my email snjezana.peco@redhat.com

@cervantesandres
Copy link

@snjeza Regrettably, I'm unable to share it as it's proprietary code. Let me provide some context: I manage a workspace in Visual Studio Code comprising over 70 Git Java web repositories. These projects are unrelated to each other. However, in VSCode, they all share the same reference libraries. In Eclipse, each web project has its own reference libraries. This setup might be causing VSCode to perceive them as a single project, necessitating a refresh for every change.

image image

@snjeza
Copy link
Contributor

snjeza commented May 23, 2024

@cervantesandres What projects are you using: Eclipse, Maven, Gradle?

@cervantesandres
Copy link

@snjeza Initially, all projects were developed in Eclipse without using build automation tools like Maven or Gradle. We are now transitioning to VSCODE.

@snjeza
Copy link
Contributor

snjeza commented May 23, 2024

Eclipse projects should work fine.
Could you show your settings.json file and your .project .classpath files?

@cervantesandres
Copy link

@snjeza I identified the problem: when I imported the folder containing all my Java programs into VSCode, it treated it as a single project. To resolve this, I created a new workspace and added each folder individually. Now, they are treated as separate projects within a single workspace.

In Eclipse, you can refer to other project within the workspace. Is there an option like that in VSCode? I have a common project that is reference in every other project.
image

@libnoon
Copy link

libnoon commented Jun 3, 2024

I was hit by the slowness issue too, it could take 10 minutes each time.
But then I switched to the Pre-Release version of the plugin (currently v1.32.2024053108), and had no issues since then.

@tarekahf
Copy link

tarekahf commented Jun 3, 2024

I was hit by the slowness issue too, it could take 10 minutes each time. But then I switched to the Pre-Release version of the plugin (currently v1.32.2024053108), and had no issues since then.

No kidding! I must give it a shot!

@gsarkardev
Copy link

The release version of the extension pack for Java (v0.27.0) resolves this issue. Projects don't get re-compiled every time, and it takes around 25s for 4 complex Java Spring Boot projects to become ready. First time compilation has also become noticeably faster.

@rgrunber
Copy link
Member

I'm going to close this issue, given that the past few commenters have indicated that recent versions of the extension seem to have fixed this. The following issues, which resulted in fixes, may have also fixed this one :

Feel free to request re-opening if not the case, but it might be better to file a new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need verify The fix is available, need verify from user performance
Projects
None yet
Development

No branches or pull requests