perf: is_executable calls fs_access for every file on every reload

未关闭 适合新手
#3,383 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
72/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
lua, neovim

调研方向

首先定位 utils.is_executable 以及所述的两个调用点:新建 FileNode 时,以及 lstat 已经可用的 Explorer:reload 中。检查 stat 如何提供文件类型和执行位,然后将其行为与现有的 fs_access 检查进行比较。完成标准是:没有执行位的普通文件跳过该系统调用,而目录、链接和可执行文件保持当前行为。

由索引模型根据 Issue 内容生成。

描述

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

主要语言
Lua
星标
8.7k
派生
642
平均合并
1 天 4 分钟
30 天内合并 PR
11

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

nvim-tree/nvim-tree.lua 的其他 Issue

查看 nvim-tree/nvim-tree.lua 的全部 Issue

相似的 Issue

更多 Lua Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。