rust-lang / rust-lang/rust-analyzer

feat/bug: slow check times -> perhaps add dependency aware version of check.workspace=false

Open
#17,255 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-diagnostics A-perf C-feature
Dominant language
Rust
Stars
16.9k
Forks
2.2k
Avg merge
1d 12h
Merged PRs (30d)
72

Description

Today, in our company workspace, when I save a file in a binary leaf crate - e.g. an alteration to main.rs, it takes:

  • 40 seconds for rust-analyzer to run clippy on all the members
  • or 40 seconds for it to run check on all the members
  • or 2 seconds to run clippy on the member
  • or 2 seconds to run check on the member

Depending on what check-on-save command I am using and the value of check.workspace.

With just cargo at the command line,

  • 1 second to run clippy --workspace
  • or 1 second to run check --workspace

Changing a mid-layer crate, and clippy --workspace takes ~ 4 seconds or so.

Which is fine, but the times from RA itself are not.

With check.workspace = True, every crate in a workspace - we're at 90 - has the check command run when a file is saved.
This takes some time but when a public interface is changed and causes another crate to fail, that is picked up immediately.

With check.workspace = False, only the package the file belongs to is rechecked, but changes that alter public interfaces go unnoticed until those other crates are saved.

What I would love is a version that runs check on the closure of the reverse dependencies of the package the saved file was in.

For example, imagine that we have a proc macro crate, a library that works in concert with that proc macro crate - including re-exporting it, and a binary:

binary

  • library
    • proc-macro

saving a file in binary would check binary
saving a file in library would check binary and library
saving a file in proc-macro would check binary and library and proc-macro

Alternatively, if RA would literally run 'clippy --workspace' or 'check --workspace' that would also solve things.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing how rust-analyzer handles the check.workspace setting and invokes cargo check or clippy on save. Compare workspace checking with package checking, then define and test the reverse-dependency closure behavior described in the examples; done means affected dependent crates are checked without checking the entire workspace.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
devtools
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.