Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance issue when formatting a large file #932

Closed
ghentschke opened this issue Feb 28, 2024 · 0 comments · Fixed by #933
Closed

Performance issue when formatting a large file #932

ghentschke opened this issue Feb 28, 2024 · 0 comments · Fixed by #933
Assignees

Comments

@ghentschke
Copy link
Contributor

ghentschke commented Feb 28, 2024

Given is a large file (~5000 lines). When performing a formatting with many formatted lines (e.g. by changing the indent with) via LSP, the folding and semantic highlighting reconciler are triggered for every queued change event in the document. Since both reconcilers perform on the whole document they should be performed only once, when the document has been modfied and not for each quewed document change.

A formatting with many formatted lines result in many queued change events:

I[09:48:20.585] <-- textDocument/didChange
I[09:48:20.585] <-- textDocument/didChange
I[09:48:20.585] <-- textDocument/didChange
I[09:48:20.585] <-- textDocument/didChange
I[09:48:20.586] <-- textDocument/didChange
I[09:48:20.586] <-- textDocument/didChange
...

which results in many (thousands!) consecutive formatting and semantic highlighting reconciler runs:

I[09:48:21.774] <-- textDocument/semanticTokens/full("483")
I[09:48:21.779] --> reply:textDocument/semanticTokens/full("483") 4 ms
I[09:48:21.835] <-- textDocument/foldingRange("484")
I[09:48:21.917] --> reply:textDocument/foldingRange("484") 81 ms
I[09:48:22.340] <-- textDocument/semanticTokens/full("485")
...

When logging to lsp4e console an out of memory occurs.

Step to reproduce:

  1. Open a large file in LSP backed editor
  2. Modify the formatting settings in way that many lines will be changed (e.g. change the IndentWidth in .clang-format file when using clangd as LS)
  3. Select all (Ctrl+a)
  4. Select in editor context menu -> Source -> Format
  5. Wait for the reconciler to be triggered (its not triggered immediately, it can take up to a few seconds, or scrolling around in the source document my trigger it as well)
@ghentschke ghentschke self-assigned this Feb 28, 2024
ghentschke added a commit to ghentschke/lsp4e-bachmann-fixes that referenced this issue Feb 28, 2024
This change prevents reconcile run on every dirty region which can be
many thousands in a large source file (> 5000 lines) Since the
reconciler operate on the whole document it needed to be executed only
when the file document changes.

fixes eclipse#932
ghentschke added a commit that referenced this issue Mar 1, 2024
This change prevents reconcile run on every dirty region which can be
many thousands in a large source file (> 5000 lines) Since the
reconciler operate on the whole document it needed to be executed only
when the file document changes.

fixes #932
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant