Skip to content

Slow auto-complete / semantic highlighting with async function and lots of expressions. #23217

Description

@cynecx

I've been trying to reproduce and minimize an auto-complete and semantic highlighting slowdown in our closed-source codebase. It's a rather large async method spanning over 500 lines of code. I've figured that the number of expressions (including the 20x tracing::debug!() lines) and it being async might be the reason why.

This Python script produces the repro code:

python3 - <<'EOF'
n = 1600
body = "".join(f"    let s{i} = String::new();\n    let l{i} = s{i}.len();\n"
               for i in range(n))
open("repro.rs", "w").write(
    f"pub fn sync_body() {{\n{body}}}\n"
    f"pub async fn async_body() {{\n{body}}}\n")
EOF

This produces a file that looks like:

pub fn sync_body() {
    let s0 = String::new();
    let l0 = s0.len();
    let s1 = String::new();
    let l1 = s1.len();
    // ...
    // s0.<|>
    // s0<|>
} 
pub async fn async_body() {
    let s0 = String::new();
    let l0 = s0.len();
    let s1 = String::new();
    let l1 = s1.len();
    // ...
    // s0.<|>
    // s0<|>
} 

Auto-complete in sync_body completes in roughly 1–2s. The async variant completes in roughly 5–6s.

Using rust-analyzer: d2e55da

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions