Skip to content

Every request re-analyses the document, so latency grows with its size even without edits #95

Open

Description

@Kinflou

Driving comline-lsp over stdio with one struct of N fields, the same hover twice in a row, with no edit in between, takes:

Fields First hover after the text changes The same hover again, no change After a 1-character edit
1,000 0.32 s 0.20 s 0.32 s
5,000 2.09 s 1.10 s 1.58 s
20,000 8.22 s 5.17 s 7.39 s

An unchanged document still costs seconds per request, growing linearly with its size, so the analysis appears to run per request rather than once per change. A single file that large is unusual, but analysis covers the whole package, so many files add up the same way, and every hover, completion and highlighting request pays it.

Fix: keep each document's analysis until it changes (and the package's until a file in it changes), and serve requests from it. Then a request costs the lookup, and only an edit costs analysis.

Measured on a debug build of main (bef0854).

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

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions