perf: Filters:custom calls getcwd for every file, even with no custom filters
維護者通常 1 天內回覆
已經有一個關聯 PR 被合併了。
- #3387 來自 @hood —— 已合併
評估
- 難度
- 2/5
- 預估耗時
- 1-3 小時
- 新手友好度
- 25/100
- Issue 類型
- 缺陷
- 描述清晰度
- 描述清楚
- 活躍度
- 停滯
- 技術堆疊
- lua, neovim
- 領域
- performance
研究方向
Start with lua/nvim-tree/explorer/filters.lua, especially Filters:custom and Filters:prepare; the issue identifies the repeated vim.uv.cwd() call and proposes resolving it once per directory only when custom patterns exist. Check the existing filtering tests and add coverage for empty and nonempty custom patterns. Done when filtering behavior stays the same and the unnecessary cwd calls are avoided; pull request #3387 is already open for this issue.
由索引模型根據 Issue 內容生成。
描述
Problem
Filters:custom calls vim.uv.cwd() for every file that gets scanned, via utils.path_relative(path, vim.uv.cwd()) (lua/nvim-tree/explorer/filters.lua:180). This happens even when filters.custom is empty, the default, so the result is never used.
getcwd is slow on some platforms: about 61µs per call on macOS.
Impact (profile on master)
| Operation | Share of time on this line |
|---|---|
api.tree.expand_all() |
33% |
Explorer:reload_explorer() |
42% |
Proposed fix
- Return early from
Filters:customwhen there are no custom patterns. - Resolve the cwd once per directory in
Filters:prepare, and only when there are custom patterns.
Filtering behaviour stays the same.
Happy to follow up with a PR as soon as I get some time.
Environment: macOS, Nvim v0.13.0-dev, LuaJIT 2.1. Test repo: 16.8k files and folders, 3.1k git status entries (modified, untracked, ignored). Measured headless with vim.uv.hrtime() and the LuaJIT profiler (jit.p).
- 主要語言
- Lua
- 星號
- 8.7k
- 分支
- 642
- 平均合併
- 1 天 58 分鐘
- 30 天內合併 PR
- 12
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 沒有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
nvim-tree/nvim-tree.lua 的其他 Issue
-
難度 2/5 1-3 小時 新手友好度 72/100
nvim-tree/nvim-tree.lua#3383 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 77/100
nvim-tree/nvim-tree.lua#3382 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 78/100
nvim-tree/nvim-tree.lua#3381 ·
維護者通常 1 天內回覆
-
Use vim.Option getters and setters instead of directly setting可能已有人在做 關聯的 PR 仍在進行中或已合併。 未關閉
難度 2/5 1-3 小時 新手友好度 75/100
nvim-tree/nvim-tree.lua#3357 · 1 則留言 ·
維護者通常 1 天內回覆
-
documentation PR please
難度 1/5 1 小時以內 新手友好度 65/100
nvim-tree/nvim-tree.lua#3179 · 6 則留言 ·
維護者通常 1 天內回覆
查看 nvim-tree/nvim-tree.lua 的全部 Issue
相似的 Issue
-
Good First Issue
難度 2/5 1-3 小時 新手友好度 88/100
維護者通常 1 天內回覆
-
bug triage
難度 2/5 1-3 小時 新手友好度 68/100
Cidan/BetterBags#1265 ·
維護者通常 1 天內回覆
-
bug discord guide:06-ashenvale locale:enUS triage v0.3.4
難度 2/5 1-3 小時 新手友好度 61/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 67/100
reacher-z/Awesome-REA#3601 ·
維護者通常 1 天內回覆
-
addon bug night-shift
難度 2/5 1-3 小時 新手友好度 78/100