Skip to content

Bevy should become less of a rust-analyzer stress test #19951

Open
@workingjubilee

Description

@workingjubilee

Bevy version

I first observed this working from 1a410ef but I believe it remains relevant today, 3 days later.

What you did

I tried to edit a file in Bevy. Specifically, crates/bevy_reflect/src/lib.rs. I was trying to remove some of the glob imports, so I used rust-analyzer's expand-glob-imports assist.

What went wrong

Honestly I was expecting things to be slow. But I encountered outright pathological behavior from rust-analyzer, as it hung after every "unglob". See rust-lang/rust-analyzer#20173 for more on why, but the details here are that while the glob assist worked fine, it happened to perturb the state of the file enough that rust-analyzer recomputed the diagnostics for the entire file, including every glob import.

This happens to be pretty slow, and I believe it scales with the number of globs, possibly nonlinearly? I don't know what else can trigger it except this assist, but I believe it is not unique to that assist, i.e. other things can cause diagnostics to be recomputed. It probably just depends on how much the file changes.

Additional information

My understanding of the rust-analyzer architectural issues is that, while we can expect this to speed up ~soon, rust-analyzer still handles globs extremely poorly and will have other correctness and performance issues.

I believe rust-analyzer's team will be able to extract a number of very useful benchmarks and tests from the historical information available in Bevy's repo. Meanwhile, Bevy should, on future commits, reduce the amount of patterns it uses that are outright problematic for performance in That Other Rust Compiler People Use.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-BugAn unexpected or incorrect behaviorS-Needs-TriageThis issue needs to be labelled

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions