Skip to content

current_line_blame is too CPU intensive #877

@WhyNotHugo

Description

@WhyNotHugo

Description

From what I'm understanding, current_line_blame runs an instance of git each time that the cursor moves to another line in order to extract blame information for the new line.

This is a problem for large repositories, where a single execution can spike CPU to 100% for a few seconds.

This becomes a terrible problem when scrolling; if I press j five times, then 5 git processes are spawned each one taking 100% of a CPU core. If I just hold j for a short while, this is what top looks like:

image

These can take around 20-30s to complete, given that they're all competing for CPU usage.

Neovim version

NVIM v0.9.1

Operating system and version

Linux 6.5.1-0-edge x86_64 Linux

Expected behavior

CPU usage should not spike due to blame calculation

Actual behavior

CPU usage spikes to 100% for each line change on large repositories.

Minimal config

for name, url in pairs{
  gitsigns = 'https://github.com/lewis6991/gitsigns.nvim',
  -- ADD OTHER PLUGINS _NECESSARY_ TO REPRODUCE THE ISSUE
} do
  local install_path = vim.fn.fnamemodify('gitsigns_issue/'..name, ':p')
  if vim.fn.isdirectory(install_path) == 0 then
    vim.fn.system { 'git', 'clone', '--depth=1', url, install_path }
  end
  vim.opt.runtimepath:append(install_path)
end

require("gitsigns").setup({
  current_line_blame = true,
  current_line_blame_opts = {
    delay = 0,
  },
})

Steps to reproduce

  1. git clone https://gitlab.alpinelinux.org/alpine/aports.git (or any other large repository)
  2. Open any file in the repository (e.g.: community/xdg-desktop-portal/APKBUILD)
  3. CPU will now spike once.
  4. Open top in another terminal
  5. Press j or k in neovim. Note how each keypress spawns a git process that takes a few seconds to exit.

Gitsigns debug messages

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions