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

Support limiting the number of outline symbols to avoid UI freezes #704

Merged
merged 1 commit into from
Mar 9, 2024

Conversation

sebthom
Copy link
Contributor

@sebthom sebthom commented Jun 21, 2023

This PR addresses #703 by limiting the maximum number of elements rendered in the UI to 5000 elements.

On my workstation Eclipse can add/render around 1.000 elements per second to the outline. Since adding elements is done in the UI thread, more elements mean longer freeze on initial population and each update.

Copy link
Contributor

@mickaelistria mickaelistria left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sebthom
Copy link
Contributor Author

sebthom commented Jun 27, 2023

@mickaelistria another issue I realized is that the Language Server also takes a considerable amount of time to provide the list of outline symbols for large files. this does not block the UI but delays the moment when the outline viewer starts drawing entries for quite a while.

Is there a way to tell the LS to limit the number of elements returned?

https://github.com/eclipse/lsp4e/blob/9ad25d4828c1041014993695fa5d1d2684510fed/org.eclipse.lsp4e/src/org/eclipse/lsp4e/outline/LSSymbolsContentProvider.java#L316-L317

I can see that DocumentSymbolParams extends WorkDoneProgressAndPartialResultParams but it is not clear if the decision to return partial results can only be made by the server or also requested by the client.

@mickaelistria
Copy link
Contributor

I don't see anything that fits immediately in https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/ . I suggest you lookup in the issues reported against LSP, IIRC there was some discussion about "paginated" responses which could fit here.

@angelozerr
Copy link
Contributor

angelozerr commented Jun 27, 2023

In LemMinx we have exactly this kind of problem (when we integrate LemMinx in vscode). It is the reason why we provide a custom limit for symbol and we throw a notfication to LSP client to notify that limit is reached to show this information in a popup information.

I don't see anything that fits immediately in https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/ .

Indeed but folding specifies rangeLimit, see
https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_foldingRange

So it can be a good idea to have too a rangeLimit kind for symbols.

Please note that symbol is used in breadcrumb in vscode, so I think symbols request should perhaps send too an information about the cursor location(just to give symbols hierachy for the cursor location).

@mickaelistria
Copy link
Contributor

Overall, LSP and more particularly JSON-RPC may be missing some capacity for sending responses in (ordered) chunks so that clients such as LSP4J could get the output as a stream or returning potentially long sequences in a BlockingQueue... But this problem is deeply rooted in JSon-RPC/LSP and should rather be addressed there.

@akurtakov
Copy link
Contributor

Is this still needed after platform.ui change?

@sebthom
Copy link
Contributor Author

sebthom commented Feb 29, 2024

A code change is still necessary because the platform.ui change is not enabled by default for all tables/tree viewers.

However this change does only address one part of the UI freeze. With newer lsp4j releases the following issue popped up eclipse-lsp4j/lsp4j#815

@sebthom sebthom changed the title Limit the maximum number of outline symbols to 5000 to avoid UI freezes Allow limiting the number of outline symbols to avoid UI freezes Feb 29, 2024
@sebthom sebthom changed the title Allow limiting the number of outline symbols to avoid UI freezes Support limiting the number of outline symbols to avoid UI freezes Feb 29, 2024
@sebthom sebthom added enhancement New feature or request performance and removed upstream-eclipse-platform labels Feb 29, 2024
@ghentschke
Copy link
Contributor

I ran into performance issues as well. I think this PR is a good starting point. Can this be merged @mickaelistria ?

@rubenporras
Copy link
Contributor

Hi @ghentschke, but would the problem not also greatly improved (also increasing performance in all cases) if we would fix #907 without using experimental APIs?

PD: If you agree to merge this PR, that is fine for me as well, regardless of what is the answer to my question.

@sebthom
Copy link
Contributor Author

sebthom commented Mar 8, 2024

without using experimental APIs?

While the javadoc says it is experimental, it is actively used in eclipse.platform.ui and eclipse.jdt.ui so I doubt it is so experimental.

@ghentschke
Copy link
Contributor

IMO a better solution would be lazy loading. Fetch the data in the background and update the treeview when the user scrolls. But this PR is a good starting to point to keep eclipse responsive.

@sebthom
Copy link
Contributor Author

sebthom commented Mar 8, 2024

IMO a better solution would be lazy loading. Fetch the data in the background and update the treeview when the user scrolls. But this PR is a good starting to point to keep eclipse responsive.

I also suggested that in the platform issue but they somehow found the current solution better.

@ghentschke
Copy link
Contributor

ghentschke commented Mar 8, 2024

The next step would be to refactor the org.eclipse.lsp4e.outline.LSSymbolsContentProvider to support partial results as described here

@sebthom sebthom merged commit 838b4c9 into eclipse-lsp4e:master Mar 9, 2024
2 checks passed
@sebthom sebthom deleted the limit-outline-elements branch March 9, 2024 11:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request performance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants