fs: Replace a bunch of uses of smol::fs with manual impls (#40172)

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>
This commit is contained in:
Piotr Osiewicz
2025-10-16 14:49:34 +02:00
committed by GitHub
co-authored by Smit Barmase
parent 9c70ba7dcc
commit c37a2f885a
13 changed files with 432 additions and 188 deletions
Generated
+39 -9
View File
@@ -1166,7 +1166,7 @@ version = "2.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09f7e37c0ed80b2a977691c47dae8625cfb21e205827106c64f7c588766b2e50"
dependencies = [
"async-lock",
"async-lock 3.4.1",
"blocking",
"futures-lite 2.6.0",
]
@@ -1180,7 +1180,7 @@ dependencies = [
"async-channel 2.3.1",
"async-executor",
"async-io",
"async-lock",
"async-lock 3.4.1",
"blocking",
"futures-lite 2.6.0",
"once_cell",
@@ -1192,7 +1192,7 @@ version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "19634d6336019ef220f09fd31168ce5c184b295cbf80345437cc36094ef223ca"
dependencies = [
"async-lock",
"async-lock 3.4.1",
"cfg-if",
"concurrent-queue",
"futures-io",
@@ -1204,6 +1204,15 @@ dependencies = [
"windows-sys 0.60.2",
]
[[package]]
name = "async-lock"
version = "2.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "287272293e9d8c41773cec55e365490fe034813a2f172f502d6ddcf75b2f582b"
dependencies = [
"event-listener 2.5.3",
]
[[package]]
name = "async-lock"
version = "3.4.1"
@@ -1243,7 +1252,7 @@ checksum = "63255f1dc2381611000436537bbedfe83183faa303a5a0edaf191edef06526bb"
dependencies = [
"async-channel 2.3.1",
"async-io",
"async-lock",
"async-lock 3.4.1",
"async-signal",
"async-task",
"blocking",
@@ -1272,7 +1281,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "637e00349800c0bdf8bfc21ebbc0b6524abea702b0da4168ac00d070d0c0b9f3"
dependencies = [
"async-io",
"async-lock",
"async-lock 3.4.1",
"atomic-waker",
"cfg-if",
"futures-core",
@@ -1293,7 +1302,7 @@ dependencies = [
"async-channel 1.9.0",
"async-global-executor",
"async-io",
"async-lock",
"async-lock 3.4.1",
"async-process",
"crossbeam-utils",
"futures-channel",
@@ -6528,6 +6537,15 @@ dependencies = [
"windows-sys 0.59.0",
]
[[package]]
name = "fs_benchmarks"
version = "0.1.0"
dependencies = [
"fs",
"gpui",
"workspace-hack",
]
[[package]]
name = "fs_extra"
version = "1.3.0"
@@ -11034,7 +11052,7 @@ dependencies = [
"ashpd 0.12.0",
"async-fs",
"async-io",
"async-lock",
"async-lock 3.4.1",
"blocking",
"cbc",
"cipher",
@@ -15735,7 +15753,7 @@ dependencies = [
"async-executor",
"async-fs",
"async-io",
"async-lock",
"async-lock 3.4.1",
"async-net",
"async-process",
"blocking",
@@ -20849,6 +20867,7 @@ name = "worktree"
version = "0.1.0"
dependencies = [
"anyhow",
"async-lock 2.8.0",
"clock",
"collections",
"fs",
@@ -20879,6 +20898,17 @@ dependencies = [
"zlog",
]
[[package]]
name = "worktree_benchmarks"
version = "0.1.0"
dependencies = [
"fs",
"gpui",
"settings",
"workspace-hack",
"worktree",
]
[[package]]
name = "write16"
version = "1.0.0"
@@ -21150,7 +21180,7 @@ dependencies = [
"async-broadcast",
"async-executor",
"async-io",
"async-lock",
"async-lock 3.4.1",
"async-process",
"async-recursion",
"async-task",