Skip to content

Whole project recompiles with each keystroke #1765

Open

Description

@xster

Sometime between version 0.64.1 and now, the build triggering behavior seems to have changed. Whereas changes within a file still produced a reasonably fast auto-complete, it seems like each keystroke now triggers a rebuild of the entire project including the edited file, other files in the project and all declared Java dependencies. This seems to generally make auto-complete unusable since one is likely typing around the time auto-complete is needed and if each keystroke triggers a 1 minute build, auto-complete is generally always loading.

Perhaps it's possible to restrict the rebuilding to the edited file, or cache all the symbols from the previous build until the next build is ready?

Environment
  • Operating System: macOS 10.15
  • JDK version: 11.0.4
  • Visual Studio Code version: 1.52.1
  • Java extension version: 0.64.1
Additional Informations

When I start typing, it triggers the below in the Java Build Status pane. Each build takes a few minutes.

8394ded0 Building [Done]
ba7e2d19 Validate documents [Done]
00cd587d Publish Diagnostics [Done]
c9fb754c Building [Done]
467b8d20 Building [Done]
a25e99a1 Validate documents [Done]
411b4544 Publish Diagnostics [Done]
c1bd89da Building [Done]
240f6be2 Building [Done]
a3536bca Building [Done]
6cea6ad2 Building [Done]

Activity

  1. testforstephen commented on Jan 14, 2021

    @testforstephen
    Collaborator

    Duplicated with #996

    The "Building" message you saw in the status panel is just a fake message, not representing a compilation operation.

  2. testforstephen commented on Jan 14, 2021

    @testforstephen
    Collaborator

    Java extension version: 0.64.1

    Your Java extension version is a little old, could you update all Java extensions to the latest version and try again?

    AFAIK, the side Java extensions such as Java test runner pushed a bunch of performance improvement against the auto completion performance in the past few months.

    BTW, do you enable file auto save? the file save is probably triggering the auto build job.

  3. xster commented on Jan 15, 2021

    @xster
    Author

    Thanks.

    File auto save is off. I'm trying now on 0.73.0 with Java 11. Same symptom. I think the "building" messages are actually doing something, since each of them breaks down (while running) into a building 123/1000 files message.

  4. deekshithanand commented on Jan 18, 2021

    @deekshithanand

    I can confirm this issue for me. Each keystroke causes the circular arrow to rotate and I get similar messages like shared above. I had disabled java autobuild and auto save was disabled by default for me

  5. dbarvitsky commented on Aug 11, 2022

    @dbarvitsky

    The "Publish Diagnostics" takes the longest for me. I frequently see java processes (2 of them because of the hybrid mode) in the background hugging the CPU (200-300% spikes), notably after the change to a Java file is made. It slows down the intellisence, and one has to wait for good 10-30 seconds for the auto-completion hints to appear. I attempted the following:

    • setting user-level "telemetry.telemetryLevel": "crash" - didn't have any effect (would be nice if Java respected that, actually).
    • setting workspace-level "redhat.telemetry.enabled": null or false - seems like does not have any effect and only applies to the Kubernetes plugin.
    • reloading the vscode, clearing the Java workspace cache, etc - nothing worked.

    If I can make a suggestion:

    • it would be nice if background compilation could be debounced somehow (i.e. start background build after a few seconds of accumulating changes and after there has been no changes for couple more seconds). This way we would not have "wasted" compilation cycles as user types.
    • do not block intellisense and auto-completion on background tasks. I'd rather have it slightly out of date but immediately available rather than waiting half of minute for it to come back with a better result. For things like refactoring I don't mind waiting though.
  6. kkilictepe commented on Sep 3, 2022

    @kkilictepe

    Same here. Intellisense performance is terrible. Any update?

  7. DrewCCannedy commented on Oct 24, 2022

    @DrewCCannedy

    Same issue, would love an update.

  8. snjeza commented on Oct 24, 2022

    @snjeza
    Collaborator

    @DrewCCannedy @kkilictepe @dbarvitsky @deekshithanand @xster Could you provide a project example reproducing the issue?

  9. kkilictepe commented on Oct 25, 2022

    @kkilictepe

    @snjeza I cant share as I am working on a commercial project.Anything else (logs etc?) that I can provide but the project codes itself?
    My project is huge, with a lot of internal dependencies.

  10. d3milord commented on Oct 27, 2022

    @d3milord

    I actually found out what could be the issue.
    I started with the same problem as described by @xster with a cyclic Building,Validate,Publish routine at each keystroke.

    After I've searched for build in the full settings page, I found that the extension "Language Support for Java(TM) by Red Hat" (ID: redhat.java) has a setting named "Java > Autobuild: Enabled" ("java.autobuild.enabled") set at True by default.
    It triggers (as the name says) an automatic build after some event (code/text changes). After I disabled it the automatic fire of the build has stopped. It only keeps doing the "Validating" step at each keystroke and sometimes the "Publish" one.

    Probably the Validating step is controlled by the intellisense to validate the code at each change. It could be made after a delay, but for me it's not impacting the performance a lot as the Build step.

    Intellisense speeded up even in complex legacy projects and it seems the entire usability has improved.
    Actually I'm still trying to find out what are the downsides of haing disabled that autobuild.

    Let me know if you know something about that feature.

  11. snjeza commented on Oct 27, 2022

    @snjeza
    Collaborator

    @d3milord
    If you set java.autobuild.enabled=true , Java LS will build your workspace only when you save a file.
    Could you show your settings.json?

  12. d3milord commented on Oct 28, 2022

    @d3milord
    {
        "java.jdt.ls.vmargs": "-XX:+UseParallelGC -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -Dsun.zip.disableMemoryMapping=true -Xmx1G -Xms100m -javaagent:\"c:\\Users\\davidepecorari\\.vscode\\extensions\\gabrielbb.vscode-lombok-1.0.1\\server\\lombok.jar\"",
        "files.exclude": {
            "**/.classpath": true,
            "**/.project": true,
            "**/.settings": true,
            "**/.factorypath": true
        },
        "redhat.telemetry.enabled": false,
        "editor.suggestSelection": "first",
        "vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
        "git.confirmSync": false,
        "git.enableSmartCommit": true,
        "java.configuration.runtimes": [
            {
              "name": "JavaSE-1.8",
              "path": "C:\\Program Files\\Java\\jdk1.8.0_202",
            },
            {
              "name": "JavaSE-11",
              "path": "C:\\Program Files\\Java\\jdk-11.0.13",
              "default": true
            }
        ],
        "java.referencesCodeLens.enabled": true,
        "java.debug.settings.showHex": true,
        "json.schemas": [],
        "workbench.startupEditor": "none",
        "workbench.colorCustomizations": {},
        "java.inlayHints.parameterNames.enabled": "none",
        "workbench.editor.enablePreviewFromQuickOpen": true,
        "workbench.editor.enablePreview": false,
        "java.debug.settings.enableRunDebugCodeLens": false,
        "java.help.showReleaseNotes": false,
        "java.autobuild.enabled": false,
        "maven.dependency.enableConflictDiagnostics": false,
        "javascript.suggestionActions.enabled": false,
        "typescript.suggestionActions.enabled": false
    }
    
  13. snjeza commented on Oct 28, 2022

    @snjeza
    Collaborator

    @d3milord could you remove the gabrielbb.vscode-lombok extension and update java.jdt.ls.vmargs to

     "java.jdt.ls.vmargs": "-XX:+UseParallelGC -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -Dsun.zip.disableMemoryMapping=true -Xmx4G -Xms100m ",
       
    

    See Lombok Support

  14. francescodedomenico commented on Jan 27, 2023

    @francescodedomenico

    I can confirm this is happening to me on a large enterprise Java Project with hundreds of classes (sometimes large ones too, 6000+ lines of code).
    It's a Spring Boot Gradle Project, and I got the message that the language server got out of memory.

    When I do get an Intellisense suggestion it comes with a 20 seconds delay (when lucky), often it shows no popup at all, making it hardly usable.

    The curious thing here is how fast is Language Server for Java by Netbeans instead, while it doesn't have the features I need the code suggestion are almost instantly provided.

    I did my tests on a brand new vscode installation with vscode-java only enabled as extension.

  15. 82 remaining items

  16. nickzhums commented on Mar 13, 2023

    @nickzhums
    Contributor

    @nikitades it could be caused by this issue and the problem is fixed the latest pre-release of the Spring Boot extension: #2941 (comment)

  17. martinlippert commented on Mar 13, 2023

    @martinlippert
    Contributor

    As @nickzhums mentioned, please try and switch to the pre-release of the Spring Boot Tools extension, which fixes an important issue that we had that broke java auto-completion. The regular release of the extension - including the fix - will also ship probably sometime this week. But please give the pre-release a try to see if this helps.

  18. nikitades commented on Mar 13, 2023

    @nikitades

    @nickzhums @martinlippert I've installed the pre-release version of Spring Boot Tools. I can confirm that I had no issues with autocompletion at the time of the usage. However, the test span was rather short, ~10 minutes. But normally it was enough to just change a symbol once to encounter the bug. So, a green light from me.

    However, after installing the said extension I also did launch the test suite run with the other extension that is called Test Runner for Java (vscjava.vscode-java-test). And the difference was, that the test suite that used to be green before Spring Boot Tools installation now became partially red. "SpringBootTest"-based tests went red, with the following error:
    javax.management.InstanceAlreadyExistsException

    I've removed the extension, and the suite went green again. I guess, this issue is well described here:
    microsoft/vscode-java-test#1420

    Thanks

  19. nickzhums commented on Mar 13, 2023

    @nickzhums
    Contributor

    Glad the pre-release solved the previous issue. For Java Test Runner, @jdneo will have more knowledge

  20. renanfranca commented on Mar 13, 2023

    @renanfranca

    @renanfranca I had this issue when you ctrl + . once and then it stops working until you restart the whole VSCode. This was solved by removing "Spring Boot Tools" (vmware.vscode-spring-boot) and "Spring Boot Dashboard" (vscjava.vscode-spring-boot-dashboard). However, "Spring Boot Tests Runner" is installed and even though it provides some integration with Spring, it does not harm the performance. So please stop using those two extensions and things might start being fine then.

    Thank you @nikitades for our feedback! In my case I solved the problem by doing this:

    1. I create a new vscode profile and configure everything again, step by step, and testing after each step without bringing all my configurations from the old settings.xml
    2. My configuration for java at the settings.json:
    	// java
    	"java.configuration.updateBuildConfiguration": "interactive",
    	"java.saveActions.organizeImports": true,
    	"java.compile.nullAnalysis.mode": "disabled",
    	"java.autobuild.enabled": true, 
    	"java.server.launchMode": "Standard",
    	"java.trace.server": "off",
    	"java.completion.favoriteStaticMembers": [
    		"org.junit.Assume.*",
    		"org.junit.jupiter.api.Assertions.*",
    		"org.junit.jupiter.api.Assumptions.*",
    		"org.junit.jupiter.api.DynamicContainer.*",
    		"org.junit.jupiter.api.DynamicTest.*",
    		"org.mockito.Mockito.*",
    		"org.mockito.ArgumentMatchers.*",
    		"org.mockito.Answers.*",
    		"org.assertj.core.api.Assertions.*",
    		"org.hamcrest.CoreMatchers.*",
    		"org.apache.commons.collections.*",
    		"org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.*",
    		"tech.jhipster.lite.module.domain.JHipsterModule.*",
    		"tech.jhipster.lite.module.domain.JHipsterModulesFixture.*",
    		"tech.jhipster.lite.module.domain.replacement.ReplacementCondition.*",
    	],
    	"boot-java.rewrite.reconcile": false,
    	"vscode-spring-boot.rewrite.reconcile-prompt": false,
    	"spring-boot.ls.java.home": "/home/renanfranca/.sdkman/candidates/java/17.0.5-tem",
  21. jdneo commented on Mar 14, 2023

    @jdneo
    Collaborator

    @nikitades Let's discuss the problem in microsoft/vscode-java-test#1546

  22. iamfreeman commented on Mar 30, 2023

    @iamfreeman

    I am not sure what you have done to the latest version 1.16. The problem is, intellisense get even wrose than 1.15. I have to wait for ages to get the intellisense popup come out. The perf is good only for the first 10min, and slow down and down

  23. iamfreeman commented on Apr 6, 2023

    @iamfreeman

    @snjeza , convincing performance

  24. bucketsize commented on Sep 25, 2023

    @bucketsize

    It's come a long way since taking a few minutes to just a few seconds for each keystroke triggered build, but it's still annoying and causes noticable lag.

    Version: 1.78.2
    Commit: b3e4e68a0bc097f0ae7907b217c1119af9e03435
    Date: 2023-05-10T14:47:05.613Z
    Electron: 22.5.2
    Chromium: 108.0.5359.215
    Node.js: 16.17.1
    V8: 10.8.168.25-electron.0
    OS: Linux x64 5.15.0-84-generic
    Sandboxed: No

  25. ahizap commented on Jul 18, 2024

    @ahizap

    Any updates on this?

  26. rishitank commented on Jul 9, 2025

    @rishitank

    It is now 2025. The issue still persists with the latest version at the time of this comment (1.43.1). I have tried everything suggested in this discussion but I am unable to resolve the issue. Why is it painfully slow for every character you type in a Java file to take so long? 💀 From what I can tell, every keystroke triggers a Validate documents and Publish Diagnostics task.

    fa365b1f Synchronizing projects [Done]
    47c25a2e Validate documents [Done]
    6d708224 Searching... [Done]
    114af78a Publish Diagnostics [Done]
    4de27d2e Publish Diagnostics [Done]
    a39cb7ab Validate documents [Done]
    c6634177 Publish Diagnostics [Done]
    3045fc33 Validate documents [Done]
    cd3dc9f6 Validate documents [Done]
    a0551181 Publish Diagnostics [Done]
    

    When will Java be usable on VSCode? I tried the pre-release but the issue still persists.

    EDIT: I believe I solved this by adding

    "java.jdt.ls.vmargs": "-XX:+UseParallelGC -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -Dsun.zip.disableMemoryMapping=true -Xmx4G -Xms100m "
    

    To my workspace settings. This should probably be set as a default since it is not clear that this is required to make Java projects usable.

  27. rgrunber commented on Jul 9, 2025

    @rgrunber
    Member

    @rishitank , every keystroke should trigger validation/publishing. The original issue was for rebuild being triggered, which is no longer happening here. Was setting XmX to 4G enough to fix the issue ? About how many lines of code is the file you had opened ?

  28. rishitank commented on Jul 9, 2025

    @rishitank

    @rishitank , every keystroke should trigger validation/publishing. The original issue was for rebuild being triggered, which is no longer happening here. Was setting XmX to 4G enough to fix the issue ? About how many lines of code is the file you had opened ?

    The file I had open was only 60 lines. Yes I believe setting XmX to 4G solved the issue.

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions