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

Abierto
#3,386 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@hood ya está trabajando en esto.

Desde el 5/11/2026.

  • #3387 de @hood — abierto

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
25/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Estancado
Stack tecnológico
lua, neovim
Área
performance

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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).

Lenguaje dominante
Lua
Estrellas
8.7k
Forks
642
Merge medio
1 d 4 min
PR fusionados (30 d)
11

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de nvim-tree/nvim-tree.lua

Todos los issues de nvim-tree/nvim-tree.lua

Issues similares

Más issues de Lua

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.