Skip to content

perf: renderer highlights via vim.hl.range are slow on large trees #3381

Open

Description

@hood

Problem

Renderer:render_hl applies every highlight of every line with vim.hl.range. That function is generic: on each call it switches buffer context with vim._with, calls col('$') twice and calls getregionpos. nvim-tree's ranges are always single-line byte ranges, so none of that work is needed.

Impact

µs per highlight
vim.hl.range 6.1
nvim_buf_set_extmark 0.74

At 16.8k visible lines, render_hl is about 50% of Renderer:draw() (620ms) and about 15% of reload_explorer.

Proposed fix

Call nvim_buf_set_extmark directly with the same ranges and the same priority (vim.hl.priorities.user). The highlights produced are identical. Happy to provide a PR for this ofc.

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

Activity

  1. changed the title [-]perf: git rev-parse is spawned for every directory loaded[/-] [+]perf: renderer highlights via vim.hl.range are slow on large trees[/+] on Nov 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions