Repository navigation
perf: avoid redoing pointer, scan, and lookup work - #3
Merged
Merged
Conversation
Pointer movement was re-rendering the page, scans repeated canonicalize and stat calls, and colors and file types were recomputed per item.
Per-entry canonicalize and stat calls dominated scanning. Bulk attributes and a flat arena remove that repeated work.
2 of 6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
這個 PR 做了什麼
指標移動、統計數字和目錄掃描都在重複做同一份工作。這個 PR 把那些重複拿掉,目錄掃描改成一次讀完整個目錄的 metadata。
指標光暈與工具提示不再讓整頁 reconcile,統計數字只改文字節點(
src/components/CursorGlow.tsx、src/components/StatsDisplay.tsx)。深度顏色是預先算好的表,檔案類型是啟動時建好的Map(src/lib/fileTypeUtils.ts)。拿掉沒用到的recharts、d3-shape、i18next-resources-to-backend、walkdir、lazy_static、filesize。serde_json留著,因為 Tauri 需要它。這次 commit(
e627a8d)的正式程式碼:src-tauri/src/scan/:根目錄只 canonicalize 一次。macOS 用getattrlistbulk,Linux 用getdents64加statx,Windows 用FindFirstFileExW(壓縮或稀疏檔再問壓縮後大小)。macOS 與 Linux 的子目錄用父目錄的 fdopenat。只有 symlink 會再查一次,用來判斷目標在不在掃描根裡面。scan/tree.rs):一個 nodeVec、一段名字、一張子節點索引表。送給 webview 的是平行陣列n、s、m、k、r,不再是一檔一個 JSON 物件。src/app/analyze/page.tsx的unpackForest把那些陣列組回原本的樹。src-tauri/src/main.rs的掃描命令改為呼叫這個模組。刪除前的大小計算走同一套掃描。測試在
scan/mod.rs,不進正式程式碼:硬連結只算一次、symlink、目錄循環、寬目錄,以及 macOS 上 bulk 讀取與lstat/fstatat一致。量測用的暫時測試沒有留在這個 commit。速度是在這台 Mac(Apple M4 Max)上,release 對 release 量的。目前 release 是
origin/main(1015673),新的是上面這個 commit。兩邊都用cargo test --release編譯。先暖機一次,再記多次,取中位數。計時的是scan_directory_streaming背景執行緒做的那一段:走完整棵樹,並把批次送到一個空的 channel。空的 callback 仍會讓 Tauri 把批次 serde 成 JSON,沒有真的送進 webview。node_modules(三批、暖機後共 17 次):src(各 11 次):node_modules的總數不一樣:find node_modules的 19964 筆相同node_modules/.bin的 7 個 symlink(next、jiti、tsserver、nanoid、tauri、tsc、semver)。舊版用fs::metadata,會跟著連結走;目標 inode 已經計過,這個名字就不再計。新版用 lstat,連結自己的 inode 另外計這次沒有做、留給審查的:
src-tauri/src/scan/mod.rs的plan_entries)filesize,配置大小改在scan/platform/windows.rs裡算相關 issue
沒有對應的 issue。
怎麼驗
cargo test --release --bin storviz:11 項通過檢查清單
tool/check/commits.sh origin/main..HEAD通過 —— 不適用。StorViz 沒有這支腳本,也沒有 DPIP 的 commit gate。這個 repo 的訊息是type: summary,後面加一兩句原因e627a8d;指標光暈、顏色表、檔案類型是已在分支上的45cebcbmise exec -- flutter analyze與mise exec -- flutter test通過 —— 不適用,這是 Tauri + Next,沒有 Flutter。代替的是上面的cargo test --release,11 項通過AppLocalizations,沒有寫死 —— 不適用。沒有新增使用者可見字串;這個專案用 i18nextgh pr checks:每一項都是 pass 或 skipped)—— 這次 commit 剛推上去,檢查還沒有結果,現在不勾AppSpacing/AppRadius/AppMotion,深色模式看過,文字對比度可接受 —— 不適用。這次 commit 只改掃描結果的解析,沒有改間距或配色,也沒有開視窗看