lsp: Parse LSP messages on background thread - again (#23122)

This is a follow-up to #12640.
While profiling latency of working with a project with 8192 diagnostics
I've noticed that while we're parsing the LSP messages into a generic
message struct on a background thread, we can still block the main
thread as the conversion between that generic message struct and the
actual LSP message (for use by callback) is still happening on the main
thread.
This PR significantly constrains what a message callback can use, so
that it can be executed on any thread; we also send off message
conversion to the background thread. In practice new callback
constraints were already satisfied by all call sites, so no code outside
of the lsp crate had to be adjusted.

This has improved throughput of my 8192-benchmark from 40s to send out
all diagnostics after saving to ~20s. Now main thread is spending most
of the time updating our diagnostics sets, which can probably be
improved too.

Closes #ISSUE

Release Notes:

- Improved app responsiveness with huge # of diagnostics.
This commit is contained in:
Piotr Osiewicz 2025-01-14 14:50:54 +01:00 committed by GitHub
parent 8e65ec1022
commit 1b3b825c7f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 83 additions and 62 deletions

View file

@ -4206,6 +4206,7 @@ async fn test_collaborating_with_lsp_progress_updates_and_diagnostics_ordering(
}],
},
);
executor.run_until_parked();
}
fake_language_server.notify::<lsp::notification::Progress>(&lsp::ProgressParams {
token: lsp::NumberOrString::String("the-disk-based-token".to_string()),