perf: Filters:custom calls getcwd for every file, even with no custom filters
维护者通常 1 天内回复
评估
- 难度
- 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 天 4 分钟
- 30 天内合并 PR
- 11
环境准备
- 没有 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
-
bug
难度 2/5 1-3 小时 新手友好度 67/100
维护者通常 1 天内回复
-
bug confirmed discord guide:tyrs-watch locale:enUS navigation v0.3.2
难度 2/5 1-3 小时 新手友好度 67/100
fitzforge/polestar#855 · 1 条评论 ·
维护者通常 1 天内回复
-
translation
难度 2/5 1-3 小时 新手友好度 64/100
KristanLaimon/PanelsPlus#16 ·
-
Bug
难度 1/5 1 小时以内 新手友好度 91/100
DennisRas/WeeklyKnowledge#164 ·
-
bug
难度 2/5 1-3 小时 新手友好度 65/100
维护者通常 1 天内回复