Batch diagnostics updates (#35794)
Diagnostics updates were programmed in Zed based off the r-a LSP push diagnostics, with all related updates happening per file. https://github.com/zed-industries/zed/pull/19230 and especially https://github.com/zed-industries/zed/pull/32269 brought in pull diagnostics that could produce results for thousands files simultaneously. It was noted and addressed on the local side in https://github.com/zed-industries/zed/pull/34022 but the remote side was still not adjusted properly. This PR * removes redundant diagnostics pull updates on remote clients, as buffer diagnostics are updated via buffer sync operations separately * batches all diagnostics-related updates and proto messages, so multiple diagnostic summaries (per file) could be sent at once, specifically, 1 (potentially large) diagnostics summary update instead of N*10^3 small ones. Buffer updates are still sent per buffer and not updated, as happening separately and not offending the collab traffic that much. Release Notes: - Improved diagnostics performance in the collaborative mode
This commit is contained in:
parent
a5c25e0366
commit
740686b883
7 changed files with 500 additions and 350 deletions
|
@ -74,9 +74,9 @@ use gpui::{
|
|||
Task, WeakEntity, Window,
|
||||
};
|
||||
use language::{
|
||||
Buffer, BufferEvent, Capability, CodeLabel, CursorShape, DiagnosticSourceKind, Language,
|
||||
LanguageName, LanguageRegistry, PointUtf16, ToOffset, ToPointUtf16, Toolchain, ToolchainList,
|
||||
Transaction, Unclipped, language_settings::InlayHintKind, proto::split_operations,
|
||||
Buffer, BufferEvent, Capability, CodeLabel, CursorShape, Language, LanguageName,
|
||||
LanguageRegistry, PointUtf16, ToOffset, ToPointUtf16, Toolchain, ToolchainList, Transaction,
|
||||
Unclipped, language_settings::InlayHintKind, proto::split_operations,
|
||||
};
|
||||
use lsp::{
|
||||
CodeActionKind, CompletionContext, CompletionItemKind, DocumentHighlightKind, InsertTextMode,
|
||||
|
@ -305,7 +305,7 @@ pub enum Event {
|
|||
language_server_id: LanguageServerId,
|
||||
},
|
||||
DiagnosticsUpdated {
|
||||
path: ProjectPath,
|
||||
paths: Vec<ProjectPath>,
|
||||
language_server_id: LanguageServerId,
|
||||
},
|
||||
RemoteIdChanged(Option<u64>),
|
||||
|
@ -2895,18 +2895,17 @@ impl Project {
|
|||
cx: &mut Context<Self>,
|
||||
) {
|
||||
match event {
|
||||
LspStoreEvent::DiagnosticsUpdated {
|
||||
language_server_id,
|
||||
path,
|
||||
} => cx.emit(Event::DiagnosticsUpdated {
|
||||
path: path.clone(),
|
||||
language_server_id: *language_server_id,
|
||||
}),
|
||||
LspStoreEvent::LanguageServerAdded(language_server_id, name, worktree_id) => cx.emit(
|
||||
Event::LanguageServerAdded(*language_server_id, name.clone(), *worktree_id),
|
||||
LspStoreEvent::DiagnosticsUpdated { server_id, paths } => {
|
||||
cx.emit(Event::DiagnosticsUpdated {
|
||||
paths: paths.clone(),
|
||||
language_server_id: *server_id,
|
||||
})
|
||||
}
|
||||
LspStoreEvent::LanguageServerAdded(server_id, name, worktree_id) => cx.emit(
|
||||
Event::LanguageServerAdded(*server_id, name.clone(), *worktree_id),
|
||||
),
|
||||
LspStoreEvent::LanguageServerRemoved(language_server_id) => {
|
||||
cx.emit(Event::LanguageServerRemoved(*language_server_id))
|
||||
LspStoreEvent::LanguageServerRemoved(server_id) => {
|
||||
cx.emit(Event::LanguageServerRemoved(*server_id))
|
||||
}
|
||||
LspStoreEvent::LanguageServerLog(server_id, log_type, string) => cx.emit(
|
||||
Event::LanguageServerLog(*server_id, log_type.clone(), string.clone()),
|
||||
|
@ -3829,27 +3828,6 @@ impl Project {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn update_diagnostics(
|
||||
&mut self,
|
||||
language_server_id: LanguageServerId,
|
||||
source_kind: DiagnosticSourceKind,
|
||||
result_id: Option<String>,
|
||||
params: lsp::PublishDiagnosticsParams,
|
||||
disk_based_sources: &[String],
|
||||
cx: &mut Context<Self>,
|
||||
) -> Result<(), anyhow::Error> {
|
||||
self.lsp_store.update(cx, |lsp_store, cx| {
|
||||
lsp_store.update_diagnostics(
|
||||
language_server_id,
|
||||
params,
|
||||
result_id,
|
||||
source_kind,
|
||||
disk_based_sources,
|
||||
cx,
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
pub fn search(&mut self, query: SearchQuery, cx: &mut Context<Self>) -> Receiver<SearchResult> {
|
||||
let (result_tx, result_rx) = smol::channel::unbounded();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue