summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2023-11-29 22:18:23 +0100
committerGitHub <noreply@github.com>2023-11-29 21:18:23 +0000
commit6718be87c8468b8ed27548e350c62ad86287a900 (patch)
tree2a02fd9f7c055c91969532d6bf040ef20601879c
parentae327d0a83be3ad56d42cad7db0b15ae8e853f06 (diff)
perf(lsp): add performance marks for TSC requests (#21383)
This should help us get a better picture where most of the time is spent (the TSC or the surrounding Rust code).
-rw-r--r--cli/lsp/tsc.rs14
-rw-r--r--cli/tests/integration/lsp_tests.rs4
2 files changed, 15 insertions, 3 deletions
diff --git a/cli/lsp/tsc.rs b/cli/lsp/tsc.rs
index e664c1b0e..b67b634e1 100644
--- a/cli/lsp/tsc.rs
+++ b/cli/lsp/tsc.rs
@@ -208,6 +208,7 @@ fn normalize_diagnostic(
#[derive(Clone, Debug)]
pub struct TsServer {
+ performance: Arc<Performance>,
sender: mpsc::UnboundedSender<Request>,
specifier_map: Arc<TscSpecifierMap>,
}
@@ -217,8 +218,9 @@ impl TsServer {
let specifier_map = Arc::new(TscSpecifierMap::new());
let specifier_map_ = specifier_map.clone();
let (tx, mut rx) = mpsc::unbounded_channel::<Request>();
+ let perf = performance.clone();
let _join_handle = thread::spawn(move || {
- let mut ts_runtime = js_runtime(performance, cache, specifier_map_);
+ let mut ts_runtime = js_runtime(perf, cache, specifier_map_);
let runtime = create_basic_runtime();
runtime.block_on(async {
@@ -238,6 +240,7 @@ impl TsServer {
});
Self {
+ performance,
sender: tx,
specifier_map,
}
@@ -946,9 +949,14 @@ impl TsServer {
where
R: de::DeserializeOwned,
{
- self
+ let mark = self
+ .performance
+ .mark(format!("tsc {}", req.method), None::<()>);
+ let r = self
.request_with_cancellation(snapshot, req, Default::default())
- .await
+ .await;
+ self.performance.measure(mark);
+ r
}
async fn request_with_cancellation<R>(
diff --git a/cli/tests/integration/lsp_tests.rs b/cli/tests/integration/lsp_tests.rs
index be3c3c0ad..49b8bb495 100644
--- a/cli/tests/integration/lsp_tests.rs
+++ b/cli/tests/integration/lsp_tests.rs
@@ -8309,6 +8309,10 @@ fn lsp_performance() {
"op_load",
"request",
"testing_update",
+ "tsc $configure",
+ "tsc $getAssets",
+ "tsc $getSupportedCodeFixes",
+ "tsc getQuickInfoAtPosition",
"update_cache",
"update_diagnostics_deps",
"update_diagnostics_lint",