perf: is_executable calls fs_access for every file on every reload

Open Beginner friendly
#3,383 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
lua, neovim

Research direction

Start by locating utils.is_executable and the two call sites described: new FileNode creation and Explorer:reload, where lstat is already available. Check how the stat exposes file type and execute bits, then compare behavior with the existing fs_access checks. Done when regular files without execute bits skip that syscall while directories, links, and executable files retain their current behavior.

Written by the indexing model from the issue text.

Description

Problem

utils.is_executable calls vim.uv.fs_access(path, "X") for:

  • every new FileNode, and
  • every existing node on every Explorer:reload.

The node's lstat result is already available at both call sites.

Impact

fs_access costs 7.7µs per call vs 1.9µs for lstat. is_executable is about 11% of reload_explorer on a fully expanded 16.8k-node tree.

Proposed fix

Pass the existing stat into is_executable. A regular file with none of the user, group or other execute bits set can never pass access(X), even as root, so return false without the syscall. Files with execute bits, directories and links still use fs_access, happy to follow up with a PR soon.

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

Dominant language
Lua
Stars
8.7k
Forks
642
Avg merge
1d 4m
Merged PRs (30d)
11

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from nvim-tree/nvim-tree.lua

All issues in nvim-tree/nvim-tree.lua

Similar issues

More Lua issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.