perf: Filters:custom calls getcwd for every file, even with no custom filters

Đang mở
#3,386 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@hood đang làm issue này rồi.

Từ ngày 5/11/2026.

  • #3387 của @hood — đang mở

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
25/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
lua, neovim
Lĩnh vực
performance

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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:custom when 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).

Ngôn ngữ chính
Lua
Star
8.7k
Fork
642
Merge trung bình
1 ngày 4 phút
Pull request đã merge (30 ngày)
11

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của nvim-tree/nvim-tree.lua

Tất cả issue của nvim-tree/nvim-tree.lua

Issue tương tự

Thêm issue về Lua

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.