Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory panic with large number of commits #23

Open
rbong opened this issue Aug 29, 2024 · 1 comment
Open

Memory panic with large number of commits #23

rbong opened this issue Aug 29, 2024 · 1 comment
Assignees
Labels
bug Something isn't working performance related to unfavorable performance

Comments

@rbong
Copy link

rbong commented Aug 29, 2024

Slightly different from #18, not just running slow but running out of memory.

init.lua:

local function bootstrap_pckr()
  local pckr_path = vim.fn.stdpath("data") .. "/pckr/pckr.nvim"

  if not vim.loop.fs_stat(pckr_path) then
    vim.fn.system({
      'git',
      'clone',
      "--filter=blob:none",
      'https://github.com/lewis6991/pckr.nvim',
      pckr_path
    })
  end

  vim.opt.rtp:prepend(pckr_path)
end

bootstrap_pckr()

require("pckr").add({
  {
    'isakbm/gitgraph.nvim',
    opts = {
      symbols = {
        merge_commit = 'M',
        commit = '*',
      },
      format = {
        timestamp = '%H:%M:%S %d-%m-%Y',
        fields = { 'hash', 'timestamp', 'author', 'branch_name', 'tag' },
      },
    },
  },
})

Using the rust repo:

:lua require('gitgraph').draw({}, { all = true, max_count = 10000 })

Result is a crash with this error:

PANIC: unprotected error in call to Lua API (not enough memory)

Result of free (my memory usage):

               total        used        free      shared  buff/cache   available
Mem:        16100688     9912152     2272604      885492     5150172     6188536
Swap:        2097148     2096656         492

I suspect this is partially because of highlighting every branch on every line, both because of storing every highlight before populating the buffer and because nvim_buf_add_highlight() can use exponential amounts of memory.

However this is not the only cause. I commented out all of the code that adds highlights in core.gitgraph (and disabled padding while I was at it) and, while it works at max_count = 10000, it still runs out of memory at max_count = 15000. I just wanted to point out highlighting since I know it will grow out of hand.

@isakbm
Copy link
Owner

isakbm commented Aug 31, 2024

Thanks for pointing this out, am well aware that on systems with little RAM, this is an issue.

The solution is just for me to get this project out of the "POC" phase and into the, let's optimize and make this super fast phase.

I just need another weekend of focused effort to do so, unfortunately in the middle of some heavy sprints with work ... 😢

So will take another week or two before I get time to address these types of issues, but they are starting to become top priority.

Thanks again for reporting this ❤️

@isakbm isakbm self-assigned this Aug 31, 2024
@isakbm isakbm added bug Something isn't working performance related to unfavorable performance labels Aug 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working performance related to unfavorable performance
Projects
None yet
Development

No branches or pull requests

2 participants