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

editor: Improve performance of lsp_ext validation #22299

Merged
merged 2 commits into from
Dec 20, 2024

Conversation

osiewicz
Copy link
Contributor

We've received a complaint on Discord about bad multicursor performance. I too run 15k cursor simultaneously. The gist of the issue was in the lsp_ext; whenever we gather up actions to be registered on a buffer, we need to know whether a buffer has any of the languages for which we have LSP extensions. The problem stemed from the fact that we did a two-phase filtering. For each selection we'd first check whether this selection lies in a part of a file that is part of a language for which we have LSP extensions. Then, we'd check whether we're running a language server of interest for this buffer.

This is not optimal, because it would often do the redundant work:

  1. We resolve selections for buffer that are known to not contain a given language server.
  2. We look up language server in the LspStore once per each matching selection.

In case where the file is not related at all, we end up resolving all of the selections which is pretty bad. This PR makes us skip buffers which are known to not match the criteria. It also caches the result of language server lookup for the buffers.

Closes #ISSUE

Release Notes:

  • Improved performance with large quantity of cursors

We've received a complaint on Discord about bad multicursor performance. I too run 15k cursor simultaneously.
The gist of the issue was in the lsp_ext; whenever we gather up actions to be registered on a buffer, we need to know whether a buffer has any of the languages for which we have LSP extensions.
The problem stemed from the fact that we did a two-phase filtering.
For each selection we'd first check whether this selection lies in a part of a file that is part of a language for which we have LSP extensions.
Then, we'd check whether we're running a language server of interest for this buffer.

This is not optimal, because it would often do the redundant work:
1. We resolve selections for buffer that are known to not contain a given language server.
2. We look up language server in the LspStore once per each matching selection.

In case where the file is not related at all, we end up resolving all of the selections which is pretty bad.
This PR makes us skip buffers which are known to not match the criteria. It also caches the result of language server lookup for the buffers.
@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Dec 20, 2024
@osiewicz osiewicz enabled auto-merge December 20, 2024 18:28
@osiewicz osiewicz added this pull request to the merge queue Dec 20, 2024
Merged via the queue into main with commit 62f5ca5 Dec 20, 2024
13 checks passed
@osiewicz osiewicz deleted the improve-perf-of-filtering-languages-in-buffer branch December 20, 2024 18:42
helgemahrt pushed a commit to helgemahrt/zed that referenced this pull request Jan 1, 2025
We've received a complaint on Discord about bad multicursor performance.
I too run 15k cursor simultaneously. The gist of the issue was in the
lsp_ext; whenever we gather up actions to be registered on a buffer, we
need to know whether a buffer has any of the languages for which we have
LSP extensions. The problem stemed from the fact that we did a two-phase
filtering. For each selection we'd first check whether this selection
lies in a part of a file that is part of a language for which we have
LSP extensions. Then, we'd check whether we're running a language server
of interest for this buffer.

This is not optimal, because it would often do the redundant work:
1. We resolve selections for buffer that are known to not contain a
given language server.
2. We look up language server in the LspStore once per each matching
selection.

In case where the file is not related at all, we end up resolving all of
the selections which is pretty bad. This PR makes us skip buffers which
are known to not match the criteria. It also caches the result of
language server lookup for the buffers.

Closes #ISSUE

Release Notes:

- Improved performance with large quantity of cursors
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed The user has signed the Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant