# Debounce code action and document highlight requests \(\#2905\) · gitcafe/zed

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

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

Visibility: public

Requested revision: 7ae5ee699f8ecd3808f3a55b1c6bd4f2f13ec75c

Requested commit: 7ae5ee699f8ecd3808f3a55b1c6bd4f2f13ec75c

Commit: 7ae5ee699f8ecd3808f3a55b1c6bd4f2f13ec75c

Tree: c664518fe33afb74ff01c352b9aae1a3e82b416e

Author: Max Brunsfeld

Committer: GitHub

## Message

```
Debounce code action and document highlight requests (#2905)

Lately, I've been finding Rust-analyzer unusably slow when editing large
files (like `editor_tests.rs`, or `integration_tests.rs`). When I
profile the Rust-analyzer process, I see that it sometimes saturates up
to 10 cores processing a queue of code actions requests.

Additionally, sometimes when collaborating on large files like these, we
see long delays in propagating buffer operations. I'm still not sure why
this is happening, but whenever I look at the server logs in Datadog, I
see that there are remote `CodeActions` and `DocumentHighlights`
messages being processed that take upwards of 30 seconds. I think what
may be happening is that many such requests are resolving at once, and
the responses are taking up too much of the host's bandwidth.

I think that both of these problems are caused by us sending way too
many code action and document highlight requests to rust-analyzer. This
PR adds a simple debounce between changing selections and making these
requests.

From my local testing, this debounce makes Rust-analyzer *much* more
responsive when moving the cursor around a large file like
`editor_tests.rs`.
```

## Parents

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

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

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