rust-lang / rust-analyzer

A Rust compiler front-end for IDEs
https://rust-analyzer.github.io/
Apache License 2.0
13.84k stars 1.53k forks source link

Check-on-save only starts with huge delay when cache priming is disabled #13770

Open RalfJung opened 1 year ago

RalfJung commented 1 year ago

Since some time recently, there is a huge delay of 10-60s between hitting Ctrl-S and RA starting to do the next check-build. Needless to say that slows down the usual development process quite a bit.

This seems to happen in Miri, but not in smaller repos, and not when I disable proc macro support. It also only happens when cache priming is disabled.

rust-analyzer version: rust-analyzer version: 0.3.1317-standalone

rustc version: rustc 1.68.0-nightly (e1c91213f 2022-12-11)

relevant settings:

    "rust-analyzer.cachePriming.enable": false,
    "rust-analyzer.cargo.buildScripts.useRustcWrapper": false,

    "rust-analyzer.rustc.source": "discover",
    "rust-analyzer.linkedProjects": [
        "./Cargo.toml",
        "./cargo-miri/Cargo.toml"
    ],
    "rust-analyzer.checkOnSave.overrideCommand": [
        "./miri",
        "cargo",
        "clippy",
        "--all-targets",
        "--message-format=json"
    ],
    // Contrary to what the name suggests, this also affects proc macros.
    "rust-analyzer.cargo.buildScripts.overrideCommand": [
        "./miri",
        "cargo",
        "check",
        "--message-format=json",
    ],
Veykril commented 1 year ago

Most likely caused by https://github.com/rust-lang/rust-analyzer/pull/13447. This is a bit annoying, that PR made it so that check on save is not as eager anymore, which at that time used to block all other requests while it was evaluating things to kick off flycheck. Now that it is no longer eager it can of course be blocked by other requests ... cache priming fxiing it makes sense that populates the necessary things for flycheck. Though it taking up to a minute now sounds very odd since it clearly didn't do that before either ...

the-a-man-006 commented 3 months ago

Any workaround? The minutes-long-delay completely kills all productivity and I can't tolerate it anymore... Any hope?

the-a-man-006 commented 3 months ago
"rust-analyzer.check.overrideCommand": [
    "cargo",
    "clippy",
    "--workspace",
    "--message-format=json",
    "--all-targets
],
"rust-analyzer.procMacro.enable": false,
"rust-analyzer.diagnostics.enable": false,
"rust-analyzer.checkOnSave.enable": true

https://github.com/rust-lang/rust-analyzer/issues/5984#issuecomment-748946015

I do need proc-macro support and build-scripts, but guess would just have to resort to rebuild-proc-macros and build scripts manually or reenable when I frequently need those. Cargo check seems to be slow for me and hangs for a minute halfway through (on my Windows machine), so resorting to Clippy.

RalfJung commented 3 months ago

I haven't seen this issue in a long while, even though cache priming is disabled.