diff options
author | Nathan Whitaker <17734409+nathanwhit@users.noreply.github.com> | 2024-04-16 12:26:51 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-16 12:26:51 -0700 |
commit | 422cff1f247dc334d5eb9387be924f5937b0c6d9 (patch) | |
tree | a6abe5c97fb53163310687f6e0010eb774cdee2c /tests/util/server/src/lsp.rs | |
parent | c4d0fceec37e3842fad4aeb5afb0dfac4353390d (diff) |
chore(lsp): Add benchmark for performance on a large real-world repo (#23395)
This PR adds a benchmark intended to measure how the LSP handles larger
repos, as well as its performance on a more realistic workload.
The repo being benchmarked is
[deco-cx/apps](https://github.com/deco-cx/apps) which has been vendored
along with its dependencies. It's included as a git submodule as its
fairly large. The LSP requests used in the benchmark are the actual
requests sent by VSCode as I opened, modified, and navigated around a
file (to simulate an actual user interaction).
The main motivation is to have a more realistic benchmark that measures
how we do with a large number of files and dependencies. The
improvements made from 1.42 to 1.42.3 mostly improved performance with
larger repos, so none of our existing benchmarks showed an improvement.
Here are the results for the changes made from 1.42 to 1.42.3 (the new
benchmark is the last one listed):
**1.42.0**
```test
Starting Deno benchmark
-> Start benchmarking lsp
- Simple Startup/Shutdown
(10 runs, mean: 379ms)
- Big Document/Several Edits
(5 runs, mean: 1142ms)
- Find/Replace
(10 runs, mean: 51ms)
- Code Lens
(10 runs, mean: 443ms)
- deco-cx/apps Multiple Edits + Navigation
(5 runs, mean: 25121ms)
<- End benchmarking lsp
```
**1.42.3**
```text
Starting Deno benchmark
-> Start benchmarking lsp
- Simple Startup/Shutdown
(10 runs, mean: 383ms)
- Big Document/Several Edits
(5 runs, mean: 1135ms)
- Find/Replace
(10 runs, mean: 55ms)
- Code Lens
(10 runs, mean: 440ms)
- deco-cx/apps Multiple Edits + Navigation
(5 runs, mean: 11675ms)
<- End benchmarking lsp
```
Diffstat (limited to 'tests/util/server/src/lsp.rs')
-rw-r--r-- | tests/util/server/src/lsp.rs | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/util/server/src/lsp.rs b/tests/util/server/src/lsp.rs index 07b63c8a8..c4219b942 100644 --- a/tests/util/server/src/lsp.rs +++ b/tests/util/server/src/lsp.rs @@ -941,6 +941,21 @@ impl LspClient { }) } + pub fn write_jsonrpc( + &mut self, + method: impl AsRef<str>, + params: impl Serialize, + ) { + let value = json!({ + "jsonrpc": "2.0", + "id": self.request_id, + "method": method.as_ref(), + "params": params, + }); + self.write(value); + self.request_id += 1; + } + fn write(&mut self, value: Value) { let value_str = value.to_string(); let msg = format!( @@ -1030,6 +1045,17 @@ impl LspClient { }) } + pub fn read_latest_response( + &mut self, + ) -> (u64, Option<Value>, Option<LspResponseError>) { + self.reader.read_message(|msg| match msg { + LspMessage::Response(id, val, err) => { + Some((*id, val.clone(), err.clone())) + } + _ => None, + }) + } + pub fn write_response<V>(&mut self, id: u64, result: V) where V: Serialize, |