# lsp: Parse LSP messages on background thread \- again \(\#23122\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/1b3b825c7f646f2fb34e2bceb6be33f310dfeb59)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 1b3b825c7f646f2fb34e2bceb6be33f310dfeb59

Requested commit: 1b3b825c7f646f2fb34e2bceb6be33f310dfeb59

Commit: 1b3b825c7f646f2fb34e2bceb6be33f310dfeb59

Tree: 9c1cd668a6f67e1fde42110e4d0936739138f20b

Author: Piotr Osiewicz

Committer: GitHub

## Message

```
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.
```

## Parents

- [8e65ec10222d1e4a1f14f36a8d10adaed7bbd3f3](https://git.cafe/gitcafe/zed/commit/8e65ec10222d1e4a1f14f36a8d10adaed7bbd3f3?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/1b3b825c7f646f2fb34e2bceb6be33f310dfeb59?format=markdown)
