Compare commits

...

3 Commits

Author SHA1 Message Date
Piotr Osiewicz
778179b5f4 Merge branch 'main' into lsp-parsing-perf 2024-06-14 14:13:51 +02:00
Piotr Osiewicz
7b2ceba9c2 Deserialize as response first, require the response to be a valid utf-8 (per spec). 2024-06-11 18:40:04 +02:00
Piotr Osiewicz
de76eb015d Baseline: measure overhead of various parts of the pipeline
+- 430ms
2024-06-11 18:31:42 +02:00
4 changed files with 46 additions and 12 deletions

View File

@@ -117,6 +117,9 @@ use serde::{Deserialize, Serialize};
use settings::{update_settings_file, Settings, SettingsStore};
use smallvec::SmallVec;
use snippet::Snippet;
use std::ops::Not as _;
use std::time::SystemTime;
use std::{
any::TypeId,
borrow::Cow,
@@ -4020,6 +4023,10 @@ impl Editor {
if this.focus_handle.is_focused(cx) && menu.is_some() {
let menu = menu.unwrap();
*context_menu = Some(ContextMenu::Completions(menu));
dbg!(std::time::SystemTime::now()
.duration_since(SystemTime::UNIX_EPOCH)
.unwrap()
.as_millis());
drop(context_menu);
this.discard_inline_completion(false, cx);
cx.notify();

View File

@@ -161,6 +161,12 @@ impl LspAdapter for VtslsLspAdapter {
"format": {
"enable": true
},
"tsserver":{
"enableTracing": true,
"log": "verbose"
},
"inlayHints":{
"parameterNames":
{

View File

@@ -1,5 +1,5 @@
use std::str;
use std::sync::Arc;
use std::{str, time::SystemTime};
use anyhow::{anyhow, Result};
use collections::HashMap;
@@ -11,6 +11,7 @@ use gpui::{BackgroundExecutor, Task};
use log::warn;
use parking_lot::Mutex;
use smol::io::BufReader;
use util::ResultExt;
use crate::{
AnyNotification, AnyResponse, IoHandler, IoKind, RequestId, ResponseHandler, CONTENT_LEN_HEADER,
@@ -91,20 +92,35 @@ impl LspStdoutHandler {
buffer.resize(message_len, 0);
stdout.read_exact(&mut buffer).await?;
let t = SystemTime::now()
.duration_since(SystemTime::UNIX_EPOCH)
.unwrap()
.as_millis();
if let Ok(message) = str::from_utf8(&buffer) {
let Some(message) = str::from_utf8(&buffer).log_err() else {
continue;
};
{
log::trace!("incoming message: {message}");
for handler in io_handlers.lock().values_mut() {
handler(IoKind::StdOut, message);
}
}
if let Ok(msg) = serde_json::from_slice::<AnyNotification>(&buffer) {
notifications_sender.unbounded_send(msg)?;
} else if let Ok(AnyResponse {
if let Ok(AnyResponse {
id, error, result, ..
}) = serde_json::from_slice(&buffer)
}) = serde_json::from_str(&message)
{
let any_parse = SystemTime::now()
.duration_since(SystemTime::UNIX_EPOCH)
.unwrap()
.as_millis();
log::info!(
"message {:?} arrived at {:?}, io stuff took {:?}",
id,
t,
any_parse
);
let mut response_handlers = response_handlers.lock();
if let Some(handler) = response_handlers
.as_mut()
@@ -119,11 +135,10 @@ impl LspStdoutHandler {
handler(Ok("null".into()));
}
}
} else if let Ok(msg) = serde_json::from_str::<AnyNotification>(&message) {
notifications_sender.unbounded_send(msg)?;
} else {
warn!(
"failed to deserialize LSP message:\n{}",
std::str::from_utf8(&buffer)?
);
warn!("failed to deserialize LSP message:\n{}", message);
}
}
}

View File

@@ -35,7 +35,7 @@ use std::{
Arc, Weak,
},
task::Poll,
time::{Duration, Instant},
time::{Duration, Instant, SystemTime},
};
use std::{path::Path, process::Stdio};
use util::{ResultExt, TryFutureExt};
@@ -1061,7 +1061,13 @@ impl LanguageServer {
select! {
response = rx.fuse() => {
let elapsed = started.elapsed();
log::info!("Took {elapsed:?} to receive response to {method:?} id {id}");
log::info!(
"message {id} ended at {:?}",
SystemTime::now()
.duration_since(SystemTime::UNIX_EPOCH)
.unwrap()
.as_millis(),
);
cancel_on_drop.abort();
response?
}