From 3583e129d197f6a1f4de541a420fbc0b420d31e3 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Wed, 29 Oct 2025 17:08:41 +0100 Subject: [PATCH] editor: Limit the amount of git processes spawned per multibuffer (#41472) Release Notes: - Reduced the number of concurrent git processes spawned for blaming --- crates/editor/src/git/blame.rs | 9 +++++++-- crates/git/src/repository.rs | 23 +++++++++++------------ 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/crates/editor/src/git/blame.rs b/crates/editor/src/git/blame.rs index 3d83e3a5cce937b92255810003a6ff951bb84d95..4f210cc9db8913eb7c46c6150d1ecd5d4f9020bb 100644 --- a/crates/editor/src/git/blame.rs +++ b/crates/editor/src/git/blame.rs @@ -1,6 +1,7 @@ use crate::Editor; use anyhow::Result; use collections::HashMap; +use futures::StreamExt; use git::{ GitHostingProviderRegistry, GitRemote, Oid, blame::{Blame, BlameEntry, ParsedCommitMessage}, @@ -507,7 +508,7 @@ impl GitBlame { let buffer_edits = buffer.update(cx, |buffer, _| buffer.subscribe()); let blame_buffer = project.blame_buffer(&buffer, None, cx); - Some((id, snapshot, buffer_edits, blame_buffer)) + Some(async move { (id, snapshot, buffer_edits, blame_buffer.await) }) }) .collect::>() }); @@ -517,10 +518,14 @@ impl GitBlame { let (result, errors) = cx .background_spawn({ async move { + let blame = futures::stream::iter(blame) + .buffered(4) + .collect::>() + .await; let mut res = vec![]; let mut errors = vec![]; for (id, snapshot, buffer_edits, blame) in blame { - match blame.await { + match blame { Ok(Some(Blame { entries, messages, diff --git a/crates/git/src/repository.rs b/crates/git/src/repository.rs index 06bc5ec4114af01ae4c90f12d676ad027d0c5cc0..eaefd4ba22c34ac2e3c30e822e6dbcd31468f9b8 100644 --- a/crates/git/src/repository.rs +++ b/crates/git/src/repository.rs @@ -1279,18 +1279,17 @@ impl GitRepository for RealGitRepository { .remote_url("upstream") .or_else(|| self.remote_url("origin")); - self.executor - .spawn(async move { - crate::blame::Blame::for_path( - &git_binary_path, - &working_directory?, - &path, - &content, - remote_url, - ) - .await - }) - .boxed() + async move { + crate::blame::Blame::for_path( + &git_binary_path, + &working_directory?, + &path, + &content, + remote_url, + ) + .await + } + .boxed() } fn diff(&self, diff: DiffType) -> BoxFuture<'_, Result> {