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

オープン
#3,386 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@hood がすでに取り組んでいます。

2026年11月5日 から。

  • #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: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).

主要言語
Lua
スター
8.7k
フォーク
642
平均マージ
1日 4分
マージ済み PR(30日)
11

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

nvim-tree/nvim-tree.lua のほかの issue

nvim-tree/nvim-tree.lua の issue をすべて見る

似ている issue

Lua の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。