sum_tree: Replace rayon with futures (#41586)

Release Notes:

- N/A *or* Added/Fixed/Improved ...

Co-authored by: Kate <kate@zed.dev>
This commit is contained in:
Lukas Wirth
2025-10-31 10:39:01 +00:00
committed by GitHub
parent 7c29c6d7a6
commit f2ce06c7b0
67 changed files with 1271 additions and 640 deletions
+22 -12
View File
@@ -20,6 +20,7 @@ use std::{
path::{Path, PathBuf},
sync::Arc,
};
use text::Rope;
use util::{
ResultExt, path,
rel_path::{RelPath, rel_path},
@@ -646,9 +647,13 @@ async fn test_dirs_no_longer_ignored(cx: &mut TestAppContext) {
// Update the gitignore so that node_modules is no longer ignored,
// but a subdirectory is ignored
fs.save("/root/.gitignore".as_ref(), &"e".into(), Default::default())
.await
.unwrap();
fs.save(
"/root/.gitignore".as_ref(),
&Rope::from_str("e", cx.background_executor()),
Default::default(),
)
.await
.unwrap();
cx.executor().run_until_parked();
// All of the directories that are no longer ignored are now loaded.
@@ -716,7 +721,7 @@ async fn test_write_file(cx: &mut TestAppContext) {
.update(cx, |tree, cx| {
tree.write_file(
rel_path("tracked-dir/file.txt").into(),
"hello".into(),
Rope::from_str("hello", cx.background_executor()),
Default::default(),
cx,
)
@@ -727,7 +732,7 @@ async fn test_write_file(cx: &mut TestAppContext) {
.update(cx, |tree, cx| {
tree.write_file(
rel_path("ignored-dir/file.txt").into(),
"world".into(),
Rope::from_str("world", cx.background_executor()),
Default::default(),
cx,
)
@@ -1465,7 +1470,7 @@ async fn test_random_worktree_operations_during_initial_scan(
let fs = FakeFs::new(cx.background_executor.clone()) as Arc<dyn Fs>;
fs.as_fake().insert_tree(root_dir, json!({})).await;
for _ in 0..initial_entries {
randomly_mutate_fs(&fs, root_dir, 1.0, &mut rng).await;
randomly_mutate_fs(&fs, root_dir, 1.0, &mut rng, cx.background_executor()).await;
}
log::info!("generated initial tree");
@@ -1555,7 +1560,7 @@ async fn test_random_worktree_changes(cx: &mut TestAppContext, mut rng: StdRng)
let fs = FakeFs::new(cx.background_executor.clone()) as Arc<dyn Fs>;
fs.as_fake().insert_tree(root_dir, json!({})).await;
for _ in 0..initial_entries {
randomly_mutate_fs(&fs, root_dir, 1.0, &mut rng).await;
randomly_mutate_fs(&fs, root_dir, 1.0, &mut rng, cx.background_executor()).await;
}
log::info!("generated initial tree");
@@ -1598,7 +1603,7 @@ async fn test_random_worktree_changes(cx: &mut TestAppContext, mut rng: StdRng)
.await
.log_err();
} else {
randomly_mutate_fs(&fs, root_dir, 1.0, &mut rng).await;
randomly_mutate_fs(&fs, root_dir, 1.0, &mut rng, cx.background_executor()).await;
}
let buffered_event_count = fs.as_fake().buffered_event_count();
@@ -1607,7 +1612,7 @@ async fn test_random_worktree_changes(cx: &mut TestAppContext, mut rng: StdRng)
log::info!("flushing {} events", len);
fs.as_fake().flush_events(len);
} else {
randomly_mutate_fs(&fs, root_dir, 0.6, &mut rng).await;
randomly_mutate_fs(&fs, root_dir, 0.6, &mut rng, cx.background_executor()).await;
mutations_len -= 1;
}
@@ -1759,8 +1764,12 @@ fn randomly_mutate_worktree(
})
} else {
log::info!("overwriting file {:?} ({})", &entry.path, entry.id.0);
let task =
worktree.write_file(entry.path.clone(), "".into(), Default::default(), cx);
let task = worktree.write_file(
entry.path.clone(),
Rope::default(),
Default::default(),
cx,
);
cx.background_spawn(async move {
task.await?;
Ok(())
@@ -1775,6 +1784,7 @@ async fn randomly_mutate_fs(
root_path: &Path,
insertion_probability: f64,
rng: &mut impl Rng,
executor: &BackgroundExecutor,
) {
log::info!("mutating fs");
let mut files = Vec::new();
@@ -1849,7 +1859,7 @@ async fn randomly_mutate_fs(
);
fs.save(
&ignore_path,
&ignore_contents.as_str().into(),
&Rope::from_str(ignore_contents.as_str(), executor),
Default::default(),
)
.await