Follow-up after #40417, which should've fixed hangs. smol::fs uses a separate threadpool, which is a bit yuck. This PR also added a benchmark you can use to run a full worktree scan (initial one, that is) for arbitrary worktree.. and refactored worktree scanner to use async locks, as otherwise tests were deadlocking. :) I've benchmarked it against Zed, Linux and Chromium and saw a ~60% drop in initial worktree scan times across the board. Release Notes: - Significantly (3.3x speedup over the old implementation) improved speed of Zed's worktree scanner, that's responsible for synchronizing the state of your project with the state of files on hard drive. --------- Co-authored-by: Smit Barmase <heysmitbarmase@gmail.com>
33 lines
1.2 KiB
Rust
33 lines
1.2 KiB
Rust
use fs::Fs;
|
|
use gpui::{AppContext, Application};
|
|
fn main() {
|
|
let Some(path_to_read) = std::env::args().nth(1) else {
|
|
println!("Expected path to read as 1st argument.");
|
|
return;
|
|
};
|
|
|
|
let _ = Application::headless().run(|cx| {
|
|
let fs = fs::RealFs::new(None, cx.background_executor().clone());
|
|
cx.background_spawn(async move {
|
|
let timer = std::time::Instant::now();
|
|
let result = fs.load_bytes(path_to_read.as_ref()).await;
|
|
let elapsed = timer.elapsed();
|
|
if let Err(e) = result {
|
|
println!("Failed `load_bytes` after {elapsed:?} with error `{e}`");
|
|
} else {
|
|
println!("Took {elapsed:?} to read {} bytes", result.unwrap().len());
|
|
};
|
|
let timer = std::time::Instant::now();
|
|
let result = fs.metadata(path_to_read.as_ref()).await;
|
|
let elapsed = timer.elapsed();
|
|
if let Err(e) = result {
|
|
println!("Failed `metadata` after {elapsed:?} with error `{e}`");
|
|
} else {
|
|
println!("Took {elapsed:?} to query metadata");
|
|
};
|
|
std::process::exit(0);
|
|
})
|
|
.detach();
|
|
});
|
|
}
|