Skip to content

Slow in a repo with large working tree #147

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

Closed
rockyzhang24 opened this issue Feb 15, 2022 · 31 comments
Closed

Slow in a repo with large working tree #147

rockyzhang24 opened this issue Feb 15, 2022 · 31 comments
Labels
bug Something isn't working

Comments

@rockyzhang24
Copy link

Hi, this plugin is awesome. Great ideas on filtering and sources, easy to customize and extend, and very active development. Thank you first.

To reproduce this issue:

  1. Create a bare repo git init --bare $HOME/bare.git
  2. In zshenv, set git env
    export GIT_DIR="$HOME/bare.git"
    export GIT_WORK_TREE="$HOME"
  3. In a new shell, under $HOME, let's create a file, and commit it
    touch file1
    git add file1
    git commit -m "first commit"
  4. Next, we open this file using Neovim. Then open neo-tree via :NeoTreeRevealToggle. Now it freezes there. After around 2~3 seconds, the neo-tree window opens.
  5. Then with neo-tree window open, we modify this file. Finally we save it via :w. After pressing <ENTER>, Neovim freezes again.

It seems that neo-tree fetches the git info synchronously, so Neovim will block in a bare repo with a large working directory. Is it possible to deal with this situation?

Looking forward to your response, and thank you so much.

@cseickel cseickel added the bug Something isn't working label Feb 15, 2022
@cseickel
Copy link
Contributor

I ran through the test and I don't have an issue if I follow the instructions exactly, but ti will freeze up if I open the bare.git directory.

This is a known issue with adding file watches to a git directory, because it throws off change events constantly. I have a check for .git directories where I skip adding watchers to those, but I hadn't come across the bare.git pattern before this.

Does this sound like it may be the issue?

If not, can you please include your neo-tree config and try capturing a log file with the instructions here: https://github.com/nvim-neo-tree/neo-tree.nvim/wiki/Troubleshooting#logs

@cseickel
Copy link
Contributor

Oh, and thanks for the kind words!

@rockyzhang24
Copy link
Author

rockyzhang24 commented Feb 15, 2022

Thank you.

Does this sound like it may be the issue

Maybe not. Let me make my example above clearer. :)

Throughout the process, I stay under $HOME directory. On step 4, I open this file by nvim file1. Then I run :NeoTreeShow. Neovim is stuck there for around 3 seconds until neo-tree window shows up. Next, I type something in this file, then I run :w, Neovim will be stuck again for a little while until [M] symbol shows next to the filename.

I will put a short video below for demo.

https://asciinema.org/a/elRuwAgal79z09hL5bWGIM9sC

can you please include your neo-tree config

I didn't config it. What I did is install neo-tree and nui and that's it.

I will attach the log info below

[DEBUG Tue Feb 15 06:59:28 2022] ...ig/nvim/pack/minpac/start/neo-tree.nvim/lua/neo-tree.lua:529: setup
[TRACE Tue Feb 15 06:59:28 2022] .../minpac/start/neo-tree.nvim/lua/neo-tree/events/init.lua:44: Teardown autocmds for  vim_buffer_added
[TRACE Tue Feb 15 06:59:28 2022] .../minpac/start/neo-tree.nvim/lua/neo-tree/events/init.lua:44: Teardown autocmds for  vim_buffer_changed
[TRACE Tue Feb 15 06:59:28 2022] .../minpac/start/neo-tree.nvim/lua/neo-tree/events/init.lua:44: Teardown autocmds for  vim_buffer_deleted
[TRACE Tue Feb 15 06:59:28 2022] .../minpac/start/neo-tree.nvim/lua/neo-tree/events/init.lua:44: Teardown autocmds for  vim_buffer_enter
[TRACE Tue Feb 15 06:59:28 2022] .../minpac/start/neo-tree.nvim/lua/neo-tree/events/init.lua:44: Teardown autocmds for  vim_diagnostic_changed
[TRACE Tue Feb 15 06:59:28 2022] .../minpac/start/neo-tree.nvim/lua/neo-tree/events/init.lua:44: Teardown autocmds for  vim_dir_changed
[TRACE Tue Feb 15 06:59:28 2022] .../minpac/start/neo-tree.nvim/lua/neo-tree/events/init.lua:44: Teardown autocmds for  vim_tab_closed
[TRACE Tue Feb 15 06:59:28 2022] .../minpac/start/neo-tree.nvim/lua/neo-tree/events/init.lua:44: Teardown autocmds for  vim_win_enter
[DEBUG Tue Feb 15 06:59:28 2022] ...minpac/start/neo-tree.nvim/lua/neo-tree/events/queue.lua:170: Creating queue for event: vim_buffer_enter
[TRACE Tue Feb 15 06:59:28 2022] .../minpac/start/neo-tree.nvim/lua/neo-tree/events/init.lua:39: Registering autocmds: %s augroup NeoTreeEvent_vim_buffer_enter
autocmd BufEnter,BufWinEnter * :lua require('neo-tree.events').fire_event('vim_buffer_enter', { afile = vim.fn.expand('<afile>') })
augroup END
[DEBUG Tue Feb 15 06:59:28 2022] ...minpac/start/neo-tree.nvim/lua/neo-tree/events/queue.lua:177: Setup for event vim_buffer_enter was run
[DEBUG Tue Feb 15 06:59:28 2022] ...minpac/start/neo-tree.nvim/lua/neo-tree/events/queue.lua:184: Adding event handler [ nil ] for event:  vim_buffer_enter
[DEBUG Tue Feb 15 06:59:28 2022] ...pac/start/neo-tree.nvim/lua/neo-tree/sources/manager.lua:445: filesystem  setup  {
  bind_to_cwd = true,
  commands = {
    add = <function 1>,
    clear_filter = <function 2>,
    close_all_nodes = <function 3>,
    close_node = <function 4>,
    close_window = <function 5>,
    ...
[TRACE Tue Feb 15 06:59:28 2022] ...pac/start/neo-tree.nvim/lua/neo-tree/sources/manager.lua:136: subscribing to event: filesystem.before_render
[DEBUG Tue Feb 15 06:59:28 2022] ...minpac/start/neo-tree.nvim/lua/neo-tree/events/queue.lua:170: Creating queue for event: before_render
[DEBUG Tue Feb 15 06:59:28 2022] ...minpac/start/neo-tree.nvim/lua/neo-tree/events/queue.lua:184: Adding event handler [ filesystem.before_render ] for event:  before_render
[TRACE Tue Feb 15 06:59:28 2022] ...pac/start/neo-tree.nvim/lua/neo-tree/sources/manager.lua:136: subscribing to event: filesystem.vim_buffer_changed
[DEBUG Tue Feb 15 06:59:28 2022] ...minpac/start/neo-tree.nvim/lua/neo-tree/events/queue.lua:170: Creating queue for event: vim_buffer_changed
[TRACE Tue Feb 15 06:59:28 2022] .../minpac/start/neo-tree.nvim/lua/neo-tree/events/init.lua:39: Registering autocmds: %s augroup NeoTreeEvent_vim_buffer_changed
autocmd BufWritePost,BufFilePost * :lua require('neo-tree.events').fire_event('vim_buffer_changed', { afile = vim.fn.expand('<afile>') })
augroup END
[DEBUG Tue Feb 15 06:59:28 2022] ...minpac/start/neo-tree.nvim/lua/neo-tree/events/queue.lua:177: Setup for event vim_buffer_changed was run
[DEBUG Tue Feb 15 06:59:28 2022] ...minpac/start/neo-tree.nvim/lua/neo-tree/events/queue.lua:184: Adding event handler [ filesystem.vim_buffer_changed ] for event:  vim_buffer_changed
[TRACE Tue Feb 15 06:59:28 2022] ...pac/start/neo-tree.nvim/lua/neo-tree/sources/manager.lua:136: subscribing to event: filesystem.vim_dir_changed
[DEBUG Tue Feb 15 06:59:28 2022] ...minpac/start/neo-tree.nvim/lua/neo-tree/events/queue.lua:170: Creating queue for event: vim_dir_changed
[TRACE Tue Feb 15 06:59:28 2022] .../minpac/start/neo-tree.nvim/lua/neo-tree/events/init.lua:39: Registering autocmds: %s augroup NeoTreeEvent_vim_dir_changed
autocmd DirChanged * :lua require('neo-tree.events').fire_event('vim_dir_changed', { afile = vim.fn.expand('<afile>') })
augroup END
[DEBUG Tue Feb 15 06:59:28 2022] ...minpac/start/neo-tree.nvim/lua/neo-tree/events/queue.lua:177: Setup for event vim_dir_changed was run
[DEBUG Tue Feb 15 06:59:28 2022] ...minpac/start/neo-tree.nvim/lua/neo-tree/events/queue.lua:184: Adding event handler [ filesystem.vim_dir_changed ] for event:  vim_dir_changed
[TRACE Tue Feb 15 06:59:28 2022] ...pac/start/neo-tree.nvim/lua/neo-tree/sources/manager.lua:136: subscribing to event: filesystem.vim_diagnostic_changed
[DEBUG Tue Feb 15 06:59:28 2022] ...minpac/start/neo-tree.nvim/lua/neo-tree/events/queue.lua:170: Creating queue for event: vim_diagnostic_changed
[TRACE Tue Feb 15 06:59:28 2022] .../minpac/start/neo-tree.nvim/lua/neo-tree/events/init.lua:39: Registering autocmds: %s augroup NeoTreeEvent_vim_diagnostic_changed
autocmd DiagnosticChanged * :lua require('neo-tree.events').fire_event('vim_diagnostic_changed', { afile = vim.fn.expand('<afile>') })
augroup END
[DEBUG Tue Feb 15 06:59:28 2022] ...minpac/start/neo-tree.nvim/lua/neo-tree/events/queue.lua:177: Setup for event vim_diagnostic_changed was run
[DEBUG Tue Feb 15 06:59:28 2022] ...minpac/start/neo-tree.nvim/lua/neo-tree/events/queue.lua:184: Adding event handler [ filesystem.vim_diagnostic_changed ] for event:  vim_diagnostic_changed
[TRACE Tue Feb 15 06:59:28 2022] ...pac/start/neo-tree.nvim/lua/neo-tree/sources/manager.lua:136: subscribing to event: filesystem.vim_tab_closed
[DEBUG Tue Feb 15 06:59:28 2022] ...minpac/start/neo-tree.nvim/lua/neo-tree/events/queue.lua:170: Creating queue for event: vim_tab_closed
[TRACE Tue Feb 15 06:59:28 2022] .../minpac/start/neo-tree.nvim/lua/neo-tree/events/init.lua:39: Registering autocmds: %s augroup NeoTreeEvent_vim_tab_closed
autocmd TabClosed * :lua require('neo-tree.events').fire_event('vim_tab_closed', { afile = vim.fn.expand('<afile>') })
augroup END
[DEBUG Tue Feb 15 06:59:28 2022] ...minpac/start/neo-tree.nvim/lua/neo-tree/events/queue.lua:177: Setup for event vim_tab_closed was run
[DEBUG Tue Feb 15 06:59:28 2022] ...minpac/start/neo-tree.nvim/lua/neo-tree/events/queue.lua:184: Adding event handler [ filesystem.vim_tab_closed ] for event:  vim_tab_closed
[DEBUG Tue Feb 15 06:59:28 2022] ...pac/start/neo-tree.nvim/lua/neo-tree/sources/manager.lua:445: buffers  setup  {
  bind_to_cwd = true,
  commands = {
    add = <function 1>,
    buffer_delete = <function 2>,
    close_node = <function 3>,
    close_window = <function 4>,
    copy_to_clipboard = <function 5>,
 ...
[TRACE Tue Feb 15 06:59:28 2022] ...pac/start/neo-tree.nvim/lua/neo-tree/sources/manager.lua:136: subscribing to event: buffers.before_render
[DEBUG Tue Feb 15 06:59:28 2022] ...minpac/start/neo-tree.nvim/lua/neo-tree/events/queue.lua:184: Adding event handler [ buffers.before_render ] for event:  before_render
[TRACE Tue Feb 15 06:59:28 2022] ...pac/start/neo-tree.nvim/lua/neo-tree/sources/manager.lua:136: subscribing to event: buffers.vim_buffer_changed
[DEBUG Tue Feb 15 06:59:28 2022] ...minpac/start/neo-tree.nvim/lua/neo-tree/events/queue.lua:184: Adding event handler [ buffers.vim_buffer_changed ] for event:  vim_buffer_changed
[TRACE Tue Feb 15 06:59:28 2022] ...pac/start/neo-tree.nvim/lua/neo-tree/sources/manager.lua:136: subscribing to event: buffers.vim_buffer_added
[DEBUG Tue Feb 15 06:59:28 2022] ...minpac/start/neo-tree.nvim/lua/neo-tree/events/queue.lua:170: Creating queue for event: vim_buffer_added
[TRACE Tue Feb 15 06:59:28 2022] .../minpac/start/neo-tree.nvim/lua/neo-tree/events/init.lua:39: Registering autocmds: %s augroup NeoTreeEvent_vim_buffer_added
autocmd BufAdd * :lua require('neo-tree.events').fire_event('vim_buffer_added', { afile = vim.fn.expand('<afile>') })
augroup END
[DEBUG Tue Feb 15 06:59:28 2022] ...minpac/start/neo-tree.nvim/lua/neo-tree/events/queue.lua:177: Setup for event vim_buffer_added was run
[DEBUG Tue Feb 15 06:59:28 2022] ...minpac/start/neo-tree.nvim/lua/neo-tree/events/queue.lua:184: Adding event handler [ buffers.vim_buffer_added ] for event:  vim_buffer_added
[TRACE Tue Feb 15 06:59:28 2022] ...pac/start/neo-tree.nvim/lua/neo-tree/sources/manager.lua:136: subscribing to event: buffers.vim_buffer_deleted
[DEBUG Tue Feb 15 06:59:28 2022] ...minpac/start/neo-tree.nvim/lua/neo-tree/events/queue.lua:170: Creating queue for event: vim_buffer_deleted
[TRACE Tue Feb 15 06:59:28 2022] .../minpac/start/neo-tree.nvim/lua/neo-tree/events/init.lua:39: Registering autocmds: %s augroup NeoTreeEvent_vim_buffer_deleted
autocmd BufDelete * :lua require('neo-tree.events').fire_event('vim_buffer_deleted', { afile = vim.fn.expand('<afile>') })
augroup END
[DEBUG Tue Feb 15 06:59:28 2022] ...minpac/start/neo-tree.nvim/lua/neo-tree/events/queue.lua:177: Setup for event vim_buffer_deleted was run
[DEBUG Tue Feb 15 06:59:28 2022] ...minpac/start/neo-tree.nvim/lua/neo-tree/events/queue.lua:184: Adding event handler [ buffers.vim_buffer_deleted ] for event:  vim_buffer_deleted
[TRACE Tue Feb 15 06:59:28 2022] ...pac/start/neo-tree.nvim/lua/neo-tree/sources/manager.lua:136: subscribing to event: buffers.vim_dir_changed
[DEBUG Tue Feb 15 06:59:28 2022] ...minpac/start/neo-tree.nvim/lua/neo-tree/events/queue.lua:184: Adding event handler [ buffers.vim_dir_changed ] for event:  vim_dir_changed
[TRACE Tue Feb 15 06:59:28 2022] ...pac/start/neo-tree.nvim/lua/neo-tree/sources/manager.lua:136: subscribing to event: buffers.vim_diagnostic_changed
[DEBUG Tue Feb 15 06:59:28 2022] ...minpac/start/neo-tree.nvim/lua/neo-tree/events/queue.lua:184: Adding event handler [ buffers.vim_diagnostic_changed ] for event:  vim_diagnostic_changed
[TRACE Tue Feb 15 06:59:28 2022] ...pac/start/neo-tree.nvim/lua/neo-tree/sources/manager.lua:136: subscribing to event: buffers.vim_tab_closed
[DEBUG Tue Feb 15 06:59:28 2022] ...minpac/start/neo-tree.nvim/lua/neo-tree/events/queue.lua:184: Adding event handler [ buffers.vim_tab_closed ] for event:  vim_tab_closed
[DEBUG Tue Feb 15 06:59:28 2022] ...pac/start/neo-tree.nvim/lua/neo-tree/sources/manager.lua:445: git_status  setup  {
  commands = {
    add = <function 1>,
    close_node = <function 2>,
    close_window = <function 3>,
    copy_to_clipboard = <function 4>,
    cut_to_clipboard = <function 5>,
    delete = <functi...
[TRACE Tue Feb 15 06:59:28 2022] ...pac/start/neo-tree.nvim/lua/neo-tree/sources/manager.lua:136: subscribing to event: git_status.vim_buffer_changed
[DEBUG Tue Feb 15 06:59:28 2022] ...minpac/start/neo-tree.nvim/lua/neo-tree/events/queue.lua:184: Adding event handler [ git_status.vim_buffer_changed ] for event:  vim_buffer_changed
[TRACE Tue Feb 15 06:59:28 2022] ...pac/start/neo-tree.nvim/lua/neo-tree/sources/manager.lua:136: subscribing to event: git_status.vim_diagnostic_changed
[DEBUG Tue Feb 15 06:59:28 2022] ...minpac/start/neo-tree.nvim/lua/neo-tree/events/queue.lua:184: Adding event handler [ git_status.vim_diagnostic_changed ] for event:  vim_diagnostic_changed
[TRACE Tue Feb 15 06:59:28 2022] ...pac/start/neo-tree.nvim/lua/neo-tree/sources/manager.lua:136: subscribing to event: git_status.vim_tab_closed
[DEBUG Tue Feb 15 06:59:28 2022] ...minpac/start/neo-tree.nvim/lua/neo-tree/events/queue.lua:184: Adding event handler [ git_status.vim_tab_closed ] for event:  vim_tab_closed
[DEBUG Tue Feb 15 06:59:28 2022] ...minpac/start/neo-tree.nvim/lua/neo-tree/events/queue.lua:170: Creating queue for event: vim_win_enter
[TRACE Tue Feb 15 06:59:28 2022] .../minpac/start/neo-tree.nvim/lua/neo-tree/events/init.lua:39: Registering autocmds: %s augroup NeoTreeEvent_vim_win_enter
autocmd WinEnter * :lua require('neo-tree.events').fire_event('vim_win_enter', { afile = vim.fn.expand('<afile>') })
augroup END
[DEBUG Tue Feb 15 06:59:28 2022] ...minpac/start/neo-tree.nvim/lua/neo-tree/events/queue.lua:177: Setup for event vim_win_enter was run
[DEBUG Tue Feb 15 06:59:28 2022] ...minpac/start/neo-tree.nvim/lua/neo-tree/events/queue.lua:184: Adding event handler [ neo-tree-win-enter ] for event:  vim_win_enter
[TRACE Tue Feb 15 06:59:28 2022] ...minpac/start/neo-tree.nvim/lua/neo-tree/events/queue.lua:130: Handler  {
  event = "vim_buffer_enter",
  handler = <function 1>
}  for vim_buffer_enter called successfully.
[TRACE Tue Feb 15 06:59:28 2022] ...minpac/start/neo-tree.nvim/lua/neo-tree/events/queue.lua:130: Handler  {
  event = "vim_buffer_enter",
  handler = <function 1>
}  for vim_buffer_enter called successfully.
[TRACE Tue Feb 15 06:59:29 2022] ...minpac/start/neo-tree.nvim/lua/neo-tree/events/queue.lua:130: Handler  {
  event = "vim_buffer_enter",
  handler = <function 1>
}  for vim_buffer_enter called successfully.
[TRACE Tue Feb 15 06:59:29 2022] ...minpac/start/neo-tree.nvim/lua/neo-tree/events/queue.lua:130: Handler  {
  event = "vim_buffer_enter",
  handler = <function 1>
}  for vim_buffer_enter called successfully.
[TRACE Tue Feb 15 06:59:30 2022] ...t/neo-tree.nvim/lua/neo-tree/sources/filesystem/init.lua:287: refreshing due to vim_buffer_changed event:  [Wilder Float 1]
[TRACE Tue Feb 15 06:59:30 2022] ...minpac/start/neo-tree.nvim/lua/neo-tree/events/queue.lua:130: Handler  filesystem.vim_buffer_changed  for vim_buffer_changed called successfully.
[TRACE Tue Feb 15 06:59:30 2022] ...minpac/start/neo-tree.nvim/lua/neo-tree/events/queue.lua:130: Handler  buffers.vim_buffer_changed  for vim_buffer_changed called successfully.
[TRACE Tue Feb 15 06:59:30 2022] ...minpac/start/neo-tree.nvim/lua/neo-tree/events/queue.lua:130: Handler  git_status.vim_buffer_changed  for vim_buffer_changed called successfully.
[TRACE Tue Feb 15 06:59:33 2022] ...pac/start/neo-tree.nvim/lua/neo-tree/sources/manager.lua:307: navigate filesystem nil nil
[TRACE Tue Feb 15 06:59:33 2022] ...t/neo-tree.nvim/lua/neo-tree/sources/filesystem/init.lua:166: navigate nil nil
[TRACE Tue Feb 15 06:59:33 2022] ...t/neo-tree.nvim/lua/neo-tree/sources/filesystem/init.lua:112: navigate_internal nil nil nil
[DEBUG Tue Feb 15 06:59:33 2022] ...t/neo-tree.nvim/lua/neo-tree/sources/filesystem/init.lua:116: navigate_internal: path is nil, using cwd
[DEBUG Tue Feb 15 06:59:33 2022] ...t/neo-tree.nvim/lua/neo-tree/sources/filesystem/init.lua:120: navigate_internal: path changed from  nil  to  /Users/rockyzhang
[TRACE Tue Feb 15 06:59:33 2022] ...t/neo-tree.nvim/lua/neo-tree/sources/filesystem/init.lua:148: navigate_internal: position saved
[DEBUG Tue Feb 15 06:59:33 2022] ...ree.nvim/lua/neo-tree/sources/filesystem/lib/fs_scan.lua:173: Not unwatching folders... use_libuv_file_watcher is  false  and state.tree is  false
[TRACE Tue Feb 15 06:59:36 2022] ...minpac/start/neo-tree.nvim/lua/neo-tree/events/queue.lua:130: Handler  filesystem.before_render  for before_render called successfully.
[TRACE Tue Feb 15 06:59:36 2022] ...minpac/start/neo-tree.nvim/lua/neo-tree/events/queue.lua:130: Handler  buffers.before_render  for before_render called successfully.
[TRACE Tue Feb 15 06:59:36 2022] ...minpac/start/neo-tree.nvim/lua/neo-tree/events/queue.lua:130: Handler  neo-tree-win-enter  for vim_win_enter called successfully.
[TRACE Tue Feb 15 06:59:36 2022] ...minpac/start/neo-tree.nvim/lua/neo-tree/events/queue.lua:130: Handler  {
  event = "vim_buffer_enter",
  handler = <function 1>
}  for vim_buffer_enter called successfully.
[TRACE Tue Feb 15 06:59:36 2022] ...minpac/start/neo-tree.nvim/lua/neo-tree/events/queue.lua:130: Handler  {
  event = "vim_buffer_enter",
  handler = <function 1>
}  for vim_buffer_enter called successfully.
[DEBUG Tue Feb 15 06:59:36 2022] .../minpac/start/neo-tree.nvim/lua/neo-tree/ui/renderer.lua:395: Setting expanded nodes
[DEBUG Tue Feb 15 06:59:36 2022] .../minpac/start/neo-tree.nvim/lua/neo-tree/ui/renderer.lua:351: No node_id to restore to
[TRACE Tue Feb 15 06:59:36 2022] ...minpac/start/neo-tree.nvim/lua/neo-tree/events/queue.lua:130: Handler  neo-tree-win-enter  for vim_win_enter called successfully.
[TRACE Tue Feb 15 06:59:36 2022] ...minpac/start/neo-tree.nvim/lua/neo-tree/events/queue.lua:130: Handler  {
  event = "vim_buffer_enter",
  handler = <function 1>
}  for vim_buffer_enter called successfully.
[TRACE Tue Feb 15 06:59:36 2022] ...t/neo-tree.nvim/lua/neo-tree/sources/filesystem/init.lua:284: Ignoring vim_buffer_changed event from filesystem
[TRACE Tue Feb 15 06:59:36 2022] ...minpac/start/neo-tree.nvim/lua/neo-tree/events/queue.lua:130: Handler  filesystem.vim_buffer_changed  for vim_buffer_changed called successfully.
[TRACE Tue Feb 15 06:59:36 2022] ...minpac/start/neo-tree.nvim/lua/neo-tree/events/queue.lua:130: Handler  buffers.vim_buffer_changed  for vim_buffer_changed called successfully.
[TRACE Tue Feb 15 06:59:36 2022] ...minpac/start/neo-tree.nvim/lua/neo-tree/events/queue.lua:130: Handler  git_status.vim_buffer_changed  for vim_buffer_changed called successfully.
[TRACE Tue Feb 15 06:59:39 2022] ...minpac/start/neo-tree.nvim/lua/neo-tree/events/queue.lua:130: Handler  {
  event = "vim_buffer_enter",
  handler = <function 1>
}  for vim_buffer_enter called successfully.
[TRACE Tue Feb 15 06:59:39 2022] ...minpac/start/neo-tree.nvim/lua/neo-tree/events/queue.lua:130: Handler  {
  event = "vim_buffer_enter",
  handler = <function 1>
}  for vim_buffer_enter called successfully.
[TRACE Tue Feb 15 06:59:39 2022] ...t/neo-tree.nvim/lua/neo-tree/sources/filesystem/init.lua:287: refreshing due to vim_buffer_changed event:  file1
[TRACE Tue Feb 15 06:59:39 2022] ...pac/start/neo-tree.nvim/lua/neo-tree/sources/manager.lua:327: filesystem  refresh
[TRACE Tue Feb 15 06:59:39 2022] ...pac/start/neo-tree.nvim/lua/neo-tree/sources/manager.lua:307: navigate filesystem /Users/rockyzhang nil
[TRACE Tue Feb 15 06:59:39 2022] ...t/neo-tree.nvim/lua/neo-tree/sources/filesystem/init.lua:166: navigate /Users/rockyzhang nil
[TRACE Tue Feb 15 06:59:39 2022] ...t/neo-tree.nvim/lua/neo-tree/sources/filesystem/init.lua:112: navigate_internal left /Users/rockyzhang nil
[TRACE Tue Feb 15 06:59:39 2022] ...t/neo-tree.nvim/lua/neo-tree/sources/filesystem/init.lua:148: navigate_internal: position saved
[DEBUG Tue Feb 15 06:59:39 2022] ...ree.nvim/lua/neo-tree/sources/filesystem/lib/fs_scan.lua:173: Not unwatching folders... use_libuv_file_watcher is  false  and state.tree is  false
[TRACE Tue Feb 15 06:59:41 2022] ...minpac/start/neo-tree.nvim/lua/neo-tree/events/queue.lua:130: Handler  filesystem.vim_buffer_changed  for vim_buffer_changed called successfully.
[TRACE Tue Feb 15 06:59:41 2022] ...minpac/start/neo-tree.nvim/lua/neo-tree/events/queue.lua:130: Handler  buffers.vim_buffer_changed  for vim_buffer_changed called successfully.
[TRACE Tue Feb 15 06:59:41 2022] ...minpac/start/neo-tree.nvim/lua/neo-tree/events/queue.lua:130: Handler  git_status.vim_buffer_changed  for vim_buffer_changed called successfully.
[TRACE Tue Feb 15 06:59:41 2022] ...minpac/start/neo-tree.nvim/lua/neo-tree/events/queue.lua:130: Handler  filesystem.before_render  for before_render called successfully.
[TRACE Tue Feb 15 06:59:41 2022] ...minpac/start/neo-tree.nvim/lua/neo-tree/events/queue.lua:130: Handler  buffers.before_render  for before_render called successfully.
[TRACE Tue Feb 15 06:59:41 2022] .../minpac/start/neo-tree.nvim/lua/neo-tree/ui/renderer.lua:611: Preserving expanded nodes
[DEBUG Tue Feb 15 06:59:41 2022] .../minpac/start/neo-tree.nvim/lua/neo-tree/ui/renderer.lua:395: Setting expanded nodes
[DEBUG Tue Feb 15 06:59:41 2022] .../minpac/start/neo-tree.nvim/lua/neo-tree/ui/renderer.lua:355: Restoring position to node_id: /Users/rockyzhang
[TRACE Tue Feb 15 06:59:42 2022] ...minpac/start/neo-tree.nvim/lua/neo-tree/events/queue.lua:130: Handler  {
  event = "vim_buffer_enter",
  handler = <function 1>
}  for vim_buffer_enter called successfully.
[TRACE Tue Feb 15 06:59:42 2022] ...minpac/start/neo-tree.nvim/lua/neo-tree/events/queue.lua:130: Handler  {
  event = "vim_buffer_enter",
  handler = <function 1>
}  for vim_buffer_enter called successfully.
[TRACE Tue Feb 15 06:59:44 2022] ...minpac/start/neo-tree.nvim/lua/neo-tree/events/queue.lua:130: Handler  neo-tree-win-enter  for vim_win_enter called successfully.

Thanks a lot.

Update:
Even if I disabled enable_git_status, this issue still remained. It seems that this issue exists as long as the working tree is very large, e.g., $HOME.

Another experiment:
In the shell rc file, only set GIT_WORK_TREE like export GIT_WORK_TREE="$HOME". Then cd into any normal git repo, and open any file in the repo via Neovim. Then run :NeoTreeShow. It can be observed that the issue appears again. So probably I can conclude that this issue is caused by setting the git work tree to a very large directory.

Thank you very much.

@cseickel
Copy link
Contributor

I think the problem is with the respect_gitignore setting. Can you try disabling that with:

      require("neo-tree").setup({
        filesystem = {
          filters = {
            respect_gitignore = false,
          }
        }
      })

and letting me know if that fixes the problem?

if it does we may be able to throttle or cache that check.

@cseickel
Copy link
Contributor

Here is the command that is actually run to get the ignored files:

git --no-optional-locks status --porcelain=v1 --ignored=matching --untracked-files=normal

@rockyzhang24
Copy link
Author

Thanks.

letting me know if that fixes the problem?

I can confirm that after setting respect_gitignore = false, the issue is totally solved and neo-tree is so smooth and responsive with a large git working tree. Awesome.
However, sometimes respect_gitignore = true is still useful for a repo with a large working tree. Is it possible to fix this to make neo-tree has good performance even if respect_gitignore set to true?

Thanks a lot.

@cseickel
Copy link
Contributor

Is it possible to fix this to make neo-tree has good performance even if respect_gitignore set to true?

Maybe, I will try out different strategies and see if there is a better way. We may have to add options that trade accuracy for performance. The built-in plenary filter that we used to use is likely better performing in this situation, but not always accurate.

The hard part was figuring out exactly where the issue was. The rest should be downhill from here.

@rockyzhang24
Copy link
Author

It makes sense. Thank you very much for developing and maintaining this plugin. I will use it with respect_gitignore = false and looking forward to your new strategies to see whether this can be solved.

@rockyzhang24 rockyzhang24 changed the title Slow in a large bare repo Slow in a repo with large working tree Feb 16, 2022
@rockyzhang24
Copy link
Author

Or is it possible to make the process of checking gitignore asynchronous?
neo-tree could open a window containing all files and check the gitignore in the background. After finishing, update the tree to filter out the entries in gitignore.

@cseickel
Copy link
Contributor

You know, I checked out the linux repo, which is insanely huge, and I had no performance issues. I think the problem with the bare repo as you have configured it is that there is a large amount of untracked but eligible files. I bet if you just add an appropriate .gitignore file that would solve the issue. In this case, you might want to .gitignore everything and then only track what you explicitly add, or add an exclusion just for certain folders which you do actually want to track.

If you are using the bare repo for dotfile management, I would highlly recommend using dotbot instead.

I'll still add an alternative respect_ignore option, but I also wanted to throw this out there.

@cseickel
Copy link
Contributor

cseickel commented Feb 16, 2022

... but if you do keep your bare repo as-is, update to the latest in main and add this option to enable the alternative gitignore logic:

      require("neo-tree").setup({
        filesystem = {
          filters = {
            respect_gitignore = true,
            gitignore_source = "plenary"
          }
        }
      })

@rockyzhang24
Copy link
Author

rockyzhang24 commented Feb 16, 2022

Thank you so much for you help and suggestions.

You know, I checked out the linux repo, which is insanely huge, and I had no performance issues.

Lol, yesterday I tested it with linux repo (more than 5GB) as well. I opened the Makefile file under the root directory in linux and then run :NeoTreeReveal with respect_gitignore = true, the neo-tree window didn't show immediately after I pressed <ENTER>, and still had a hundreds of milliseconds latency time. I can feel it, even though it is not that noticeable. If I set respect_gitignore = false, I felt a little improvement, but it still had a very slight latency. If I run :NeoTreeReveal in a very small repo, the neo-tree window shows instantly. I thought linux repo is not large enough, because its actually files are just 1.1GB, .git is 4G. So the working tree of linux repo is not large actually. Then I did a further test.

In order to make the working tree large enough, in the shell rc file, I only set export GIT_WORK_TREE="$HOME". Then I opened a new shell and went back to the linux folder. This time linux repo has a very large working tree, the whole $HOME. Then, stay in linux folder, I tried to open a file like Makefile, and run :NeoTreeReveal. The performance issue appeared again, the latency time is very long, near 8s. Then I tried to set respect_gitignore = false, however, the latency was not gone, but relieved some, near 4s, and I don't know why the latency is not completely resolved. Could you please test this on your end?

In my original experiment, I set both GIT_DIR and GIT_WORK_TREE env. After setting respect_gitignore = false, the latency was resolved completely, and the neo-tree window shown instantly. I think the reason is that linux has lots of traced file, but my bare repo only has one tracked file, file1, right?

you might want to .gitignore everything and then only track what you explicitly add, or add an exclusion just for certain folders which you do actually want to track

But I need to see the whole structure of $HOME. I set showUntrackedFiles = no for the bare repo to hide all the untracked files for command like git status.

If you are using the bare repo for dotfile management

Yes, I am using bare repo to mange my dotfiles. And actually I set GIT_DIR=$HOME/dotfiles and GIT_WORK_TREE=$HOME", along with showUntrackedFiles = no`.

update to the latest in main and add this option to enable the alternative gitignore logic

I tried this option and the performance is great with respect_gitignore = true. Awesome. But this option has a low accuracy, right?

Sorry for this verbose reply, and really appreciate your patience for helping me debug this. :)

@cseickel
Copy link
Contributor

I tried this option and the performance is great with respect_gitignore = true. Awesome. But this option has a low accuracy, right?

The major issue with this is that it only works when your cwd is the root of the repo, otherwise it doesn't find the .gitignore file. It also is not aware of any cascading .gitignore that may be in effect. See this for more info: #78

...actually, now that I read that I realize it's worse than I remember. It only works for the root level objects... I'll need to revisit this.

@rockyzhang24
Copy link
Author

rockyzhang24 commented Feb 16, 2022

Okay. Thanks ❤️

For my verbose relay above, I want to extract and summarize the problems so far below to make it clear for your reference.

For all situations below, use 1.x branch, i.e., not set gitignore_source.

  1. For bare repo
    In zshrc, set

    export GIT_DIR="$HOME/bare.git"
    export GIT_WORK_TREE="$HOME"

    Then open a file under $HOME, and run :NeoTreeReveal.

    If set respect_gitignore = true, it has a long latency.
    If set respect_gitignore = false, no latency.

  2. For linux repo
    open ./Makefile and run :NeoTreeReveal

    If set respect_gitignore = true, milliseconds latency
    If set respect_gitignore = false, improved but still a slight latency

  3. For linux repo, but set export GIT_WORK_TREE=$HOME in zshrc.
    open ./Makefile and run :NeoTreeReveal

    If set respect_gitignore = true, very long, 8~10s latency
    If set respect_gitignore = false, improved but still 4s latency

Thank you very much.

@rockyzhang24
Copy link
Author

rockyzhang24 commented Feb 16, 2022

One more idea (let me know if it is better to open a new issue):
For the gitignored files, how about adding an option to show them with a symbol like [I], or hide them directly?
E.g.,

require("neo-tree").setup({
	filesystem = {
		filters = {
			respect_gitignore = true,
			gitignore_treatmente = 'symbol'	-- can be 'hidden' or 'symbol'
		}
	}
})

For the symbols, nvim-tree uses symbols for different status and they are configurable.
image

I think this is a good addition to neo-tree

@cseickel
Copy link
Contributor

3. For linux repo, but set export GIT_WORK_TREE=$HOME in zshrc.
open ./Makefile and run :NeoTreeReveal
If set respect_gitignore = true, very long, 8~10s latency

That definitely resulted in a delay but but I only had a long delay the first time, and after that it was about 1 second. I think the cache is more effective on my computer, maybe because it is clean or I just have a lot less files in my HOME directory. Whatever the case it is still enough to make an obvious delay but not to the degree that you are seeing.

If set `respect_gitignore = false`, improved but still 4s latency

I don't have that, but it could be that you are still getting a significant delay from the git status step.

I just committed a new option in main that runs git check-ignore on each directory that is scanned instead of running a single git status on the whole repo. It is faster on my computer in this situation. here is how you enable it:

      require("neo-tree").setup({
        filesystem = {
          filters = {
            respect_gitignore = true,
            --gitignore_source = "git status", -- <-- this is the default
            gitignore_source = "git check-ignore",
          }
        }
      })

Can you try it out and let me know if it is improved?

@rockyzhang24
Copy link
Author

rockyzhang24 commented Feb 17, 2022

Can you try it out and let me know if it is improved?

No, still very long latency. What I did is bit by bit is:

  1. Put export GIT_WORK_TREE=$HOME in .zshrc.
  2. Open a new shell window
  3. cd into linux folder, then run :nvim Makefile. In Neovim, run :NeoTreeReveal.

After pressing <ENTER>, around 7~8s latency there. I put a short demo below.

asciicast

@cseickel
Copy link
Contributor

As a test, can you run git check-ignore ./* in the linux folder and tell me how long the delay is?

@rockyzhang24
Copy link
Author

rockyzhang24 commented Feb 17, 2022

No delay, it exits immediately with exit 1 and nothing output. I think probably its working tree is changed to $HOME so it makes this command failed?
image

@cseickel
Copy link
Contributor

exit 1 in this case is not a failure, which caused me some confusion at first. It means "nothing is ignored in this path". exit 128 indicates a failure, and it would output some message explaining what the failure is.

This means I am either on the wrong path, or I fixed one slowdown but another one remains. The next question is, how long does this take:

git status --porcelain=v1

@rockyzhang24
Copy link
Author

Thanks for the explanation and apologize my wrong understanding for exit code.

git status --porcelain=v1

It outputs contents under my $HOME, totally 75073 entries.
image

And then I run time git status --porcelain=v1 to get the time
image

@cseickel
Copy link
Contributor

There's the problem! This is used to mark the status of each item shown in the tree. I guess the problem here is that there are so many untracked files. Maybe I can come up with an alternate solution that only checks the files that are currently visible. I'll look into it.

@cseickel
Copy link
Contributor

I just merged a new git_status_async option to main that I think works really well. If there are no issues, I'll make this the new default. To enable it now along with the other improvements, set these options:

      require("neo-tree").setup({
        enable_git_status = true,
        git_status_async = true, -- <-- this is the new setting
        filesystem = {
          filters = {
            respect_gitignore = true,
            gitignore_source = "git check-ignore",
          }
        }
      })

Please try it out and let me know how it works.

@rockyzhang24
Copy link
Author

Thanks. Now, the latency issue is totally resolved. After I press <ENTER>, the neo-tree window appears immediately. That's cool!

However, if I change gitignore_source to git status, the latency is still very significant. Btw, I also tried nvim-tree and I found there is no latency for the bare repo and very large working tree.

Thank you.

@cseickel
Copy link
Contributor

cseickel commented Feb 20, 2022

However, if I change gitignore_source to git status, the latency is still very significant.

Yes, this is a two part solution for a large repo. Checking ignore and status can each add their own delay. I think I will make both of these settings the new default soon, but I want to use it for a week to make sure there are no issue.

Btw, I also tried nvim-tree and I found there is no latency for the bare repo and very large working tree.

I'm pretty sure nvim-tree has already made the switch to an async git status. I just put it off until someone expressed a need because it always worked fine for me as it was. 🤷‍♂️

@nyngwang
Copy link

I'm happy to see that this discussion continues. I have also experienced the same recently but I was too busy to report it. Thanks for the OP btw :)

@rockyzhang24
Copy link
Author

rockyzhang24 commented Feb 21, 2022

@cseickel Thank you.
So right now gitignore_source has two values, check-ignore and git status, right? Is the value plenary removed? I remember you mentioned that plenary has a low accuracy, how about check-ignore and git status?

Thank you very much.

@cseickel
Copy link
Contributor

The plenary option technically still exists but it is too flawed to be useful so it won't be documented and can be removed at any time.

gitignore_source currently has two recommended values, git check-ignore and git status, both of which are 100% accurate. On a very large repo, git check-ignore will be faster. On a small repo where all ignored files can be listed in milliseconds, git status is likely faster but it might not be a meaningful difference.

@rockyzhang24
Copy link
Author

Thank you so much for the explanation. Now neo-tree works like a charm. I really appreciate what you have done and all the efforts you put into the issue exploring and fixing 👍

@nyngwang
Copy link

Thanks for you guys making this plugin better! @cseickel @yanzhang0219

@rockyzhang24
Copy link
Author

rockyzhang24 commented Apr 28, 2022

Hi @cseickel

Update this issue:

  1. Open any file in this bare repo with a very large working treee
  2. Open neotree window
  3. Type something in the file buffer. The diagnostics information will not be shown (seems that the git running in background asynchronously to fetch status blocks the diagnostics). Then we run :qa! to quit, but vim will be stuck there for a while. In shell, an error appears (screenshot below)
    image

I am using the latest nightly neovim and latest neotree with default config. I also found nvim-tree is very fast when fetching git status and diagnostics no matter how large the repo is. Probably you could investigate it and find a workaround.

Thank you.

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

3 participants