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

[Bug]: Out of memory #171

Closed
sandangel opened this issue Nov 12, 2023 · 11 comments
Closed

[Bug]: Out of memory #171

sandangel opened this issue Nov 12, 2023 · 11 comments
Labels
bug Something isn't working

Comments

@sandangel
Copy link

sandangel commented Nov 12, 2023

What happened?

After installing the plugin, try opening github-preview with GithubPreviewToggle.
I got the notification saying github-preview: init.

After 10s, the terminal crash saying it's using too much memory.

I guess the plugin load all the files into memory to display on browser.

What browsers are you seeing the problem on?

Firefox

:checkhealth

github-preview: require("github-preview.health").check()

github-preview.nvim ~
- platform: linux
- git-commit: a4c7dd98eb274834bfe15629b540fe13ead83b06
- OK bun: 1.0.7

@sandangel sandangel added the bug Something isn't working label Nov 12, 2023
@wallpants
Copy link
Owner

does that happen every time you try opening the plugin? or does it only happen when starting the plugin in a repo with many files? If so, do you know around how many files/levels there are in the repo?

@wallpants
Copy link
Owner

or is there anything different in the repo where this is happening compared to others where this doesn't happen

@wallpants
Copy link
Owner

The plugin doesn't load all the files into memory, but it does traverse the entire repo to get the names of the files. The contents of the files are not accessed until you navigate to that file either via the browser or neovim. I would be surprised if there was a memory problem from getting the names of the files.

@wallpants
Copy link
Owner

Also, did the browser ever open and did anything load?

@sandangel
Copy link
Author

The browser never open. nothing load. It only shows github-preview: init in notification history. Is there a way to enable more logs?

@sandangel
Copy link
Author

sandangel commented Nov 12, 2023

Actually, I tried on small repo as well but it does not work. Could be because I'm using nix with devenv, direnv? devenv will create a .devenv directory with symlinks to all packages within /nix/store. I'm not sure how github-preview traverse the dir tree.

@wallpants
Copy link
Owner

We also run bun install every time before the bun app starts, that could also be the step taking up all the memory.

try adding a log_level to your plugin config:

require("github-preview").setup({
	-- ...other settings
	log_level = "verbose"
})

this should print out stuff to your neovim :messages and you should now also be able to run the following command in a new terminal to get detailed logs live from the bun app:

bunx bunvim logs github-preview

@sandangel
Copy link
Author

Hi, I managed to make the browser open. After adding log_level, it started to work. I notice that the kitty terminal/neovim was freezed for like 10s. When I expect it crashes, the browser open! YAY!!!!. And the next time I open with GithubPreviewToggle command, it opens browser without issue.

Things I changed: I upgraded bun from 1.0.7 to 1.0.11, which might fix some issues with memory loading.

The performance is still not great. There are some lags like 5~10 seconds when you open a new folder in the sidebar. Also it takes around ~10sec to open a file to view. All of these happens only the first time you open the file or closing github preview and reopen it.

I guess the file loading is not very fast. You might want to take a look at how nvim-tree or neo-tree implement it.

Some suggestions:

  • We can preload file system in the background so it will be ready when user open it.
  • Use background jobs / async jobs so it won't freeze the UI.

@wallpants
Copy link
Owner

wallpants commented Nov 13, 2023

There must be something else.

I'm testing the plugin on a base macbbook pro 2.6 GHz 6-Core Intel Core i7, 16 GB ram and everything is pretty much instant.

When opening a folder, we use globby to get a list of files/dirs. Globby is based on fast-glob which claims to be the fastest in nodejs.

When reading the contents of a file we're doing it the way bun says is "heavily optimized and represent the recommended way to perform file-system tasks using Bun."

what are the specs of your machine?

@sandangel
Copy link
Author

My spec:

  • Linux, Fedora.
  • 32GB ram, 6-core

@sandangel
Copy link
Author

sandangel commented Nov 14, 2023

Since I get it working, I think we can close the issue now. Will reopen if I experience this issue again. Thanks a lot for your hard work. This plugin is great

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants