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

Please improve the performance. #1357

Open
kgfly opened this issue Apr 30, 2023 · 6 comments
Open

Please improve the performance. #1357

kgfly opened this issue Apr 30, 2023 · 6 comments

Comments

@kgfly
Copy link

kgfly commented Apr 30, 2023

Description

My folder has about 2k-3k files. When refreshing, it's very flow, taking about 4-5 seconds (on Windows OS). The refreshing appears to be a sync func. Etc during the refresh, whole vim get freezed, which makes auto fresh unusable, https://superuser.com/questions/1141994/autorefresh-nerdtree.

Also when expanding for the 1st time, it's very slow too.

Other plugin, such https://github.com/lambdalisue/fern.vim, is much faster (on Windows OS)

  1. Is it possible to improve the perf?
  2. Is it possible to change the sync mode to async? At least, the vim will not be freezed during the refresh.

Thanks.

@jinleileiking
Copy link

image

@rzvxa
Copy link
Member

rzvxa commented Nov 24, 2023

@jinleileiking interesting results, May I ask what other plugins are there in your config other than NERDTree? For example vim-devicons or the nerdtree-git-plugin? and may I have your profiling options?
This call takes a bunch of time because of being in a loop and getting called for every child node, I suspect that the actual bulk of the work happens in this line in the lib/nerdtree/path.vim line 664:

" FUNCTION: Path.refreshFlags(nerdtree) {{{1
function! s:Path.refreshFlags(nerdtree)
    call g:NERDTreePathNotifier.NotifyListeners('refreshFlags', self, a:nerdtree, {})
    call self.cacheDisplayString()
endfunction

Call to the refreshFlags listeners is for third-party plugins, for example, vim-devicons and nerdtree-git-plugin which update their internal state via this event. So the cost of each extra plugin is O(n).

@rzvxa
Copy link
Member

rzvxa commented Nov 24, 2023

You can also try using #1362, Setting g:NerdTreeLazyDirRefresh to 1 enables the lazy refresh functionality. In this mode, we don't refresh closed directories, We just mark them as dirty and refresh them once it is necessary.

@jinleileiking
Copy link

Plug 'PhilRunninger/nerdtree-buffer-ops'

@jinleileiking
Copy link

It seems this plugin cost a lot of CPU. I disable this plugin, works well

@rzvxa
Copy link
Member

rzvxa commented Nov 29, 2023

@jinleileiking I'm happy to hear that you've found the issue, Since it probably wasn't the original author's problem I'll leave this open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants