Shougo / denite.nvim

:dragon: Dark powered asynchronous unite all interfaces for Neovim/Vim8
Other
2.06k stars 215 forks source link

`cache_threshold` doesn't work #548

Closed mMontu closed 5 years ago

mMontu commented 5 years ago

Problems summary

I'm probably missing some obvious detail, but setting the cache_threshold mentioned in :help denite-source-file_rec causes an error and make :Denite file/rec fail.

[denite]     return self._async_gather_candidates(context, 0.5)
[denite]   File "/home/mmontu/.vim/bundle/denite.nvim/rplugin/python3/denite/source/file/rec.py", line 115, in _async_g
ather_candidates
[denite]     if threshold > 0:
[denite] TypeError: unorderable types: str() > int()
[denite] Please execute :messages command.     

Changing this to threshold = int(self.vars['cache_threshold']) avoid the error message. But I don't notice any speed up when using the command on directories with a small number of files (with ag as the file/rec command, as the first lines in :help denite-examples).

Environment Information (Required!)

Provide a minimal init.vim with less than 50 lines (Required!)

Reproducible without init file.

How to reproduce problems from neovim startup (Required!)

$ gvim -u NONE -U NONE -N -i NONE
set nocompatible
let &rtp.=','.$HOME.'/.vim/bundle/denite.nvim'
source ~/.vim/bundle/denite.nvim/plugin/denite.vim
call denite#custom#var('file/rec', 'cache_threshold', 50)
Denite file/rec
Shougo commented 5 years ago

But I don't notice any speed up when using the command on directories with a small number of files

If the files are small, it does not any speed up. You should know it...

Shougo commented 5 years ago

cache threshold feature is not magic.

mMontu commented 5 years ago

cache threshold feature is not magic.

That much I guessed. What surprised me is that is seems irrelevant. No noticeable change in both large and small directories.

Shougo commented 5 years ago

The disk cache is available and the improvement is n nt so big. I don't implement the feature until recently. Because the advantage is not so big like you have shocked.

Shougo commented 5 years ago

The cache is useful for only 100k level files.

mMontu commented 5 years ago

I see. I expected it to be far quicker, close to instant response, by just reading the variable contents into the buffer. Maybe the extra delay is due to the transfer between python and VimL. But I guess there is something else wrong, unrelated to cache: just profiled DeniteProjectDir -root-markers='*.sln,*.avrsln,*.atsln,index.wiki' file/rec, which returned 112 files:

FUNCTIONS SORTED ON TOTAL TIME
count  total (s)   self (s)  function
    1   3.869510   0.000259  denite#helper#call_denite()
    1   3.823575   0.000163  denite#start()
    1   3.823412   0.000297  <SNR>211_start()
    1   3.822127   1.033573  denite#vim#_start()

Unfortunately it doesn't give enough information about the slowest part:

FUNCTION  denite#vim#_start()
    Defined: ~/.vim/bundle/denite.nvim/autoload/denite/vim.vim line 33
Called 1 time
Total time:   3.822127
 Self time:   1.033573
count  total (s)   self (s)
    1              0.000006   python3 << EOF
                            def _temporary_scope():
                                nvim = denite.rplugin.Neovim(vim)
                                try:
                                    buffer_name = nvim.eval('a:context')['buffer_name']
                                    if nvim.eval('a:context')['buffer_name'] not in denite__uis:
                                        denite__uis[buffer_name] = denite.ui.default.Default(nvim)
                                    denite__uis[buffer_name].start(
                                        denite.rplugin.reform_bytes(nvim.eval('a:sources')),
                                        denite.rplugin.reform_bytes(nvim.eval('a:context')),
                                    )
                                except Exception as e:
                                    import traceback
                                    for line in traceback.format_exc().splitlines():
                                        denite.util.error(nvim, line)
                                    denite.util.error(nvim, 'Please execute :messages command.')
                            _temporary_scope()
                            if _temporary_scope in dir():
                                del _temporary_scope
                            EOF
    1              0.000013   return []

Is there any verbose options on the plugin to help on this? I found :help denite-map-print_messages in the docs, but it didn't seems applicable.

mMontu commented 5 years ago

Smaller when using Denite file/rec alone:

FUNCTIONS SORTED ON TOTAL TIME
count  total (s)   self (s)  function
    1   2.024810   0.000300  denite#helper#call_denite()
    1   1.999972   0.000221  denite#start()
    1   1.999751   0.000234  <SNR>231_start()
    1   1.998348   1.202788  denite#vim#_start()
Shougo commented 5 years ago

I don't reproduce the problem. So, I cannot help you.

Is there any verbose options on the plugin to help on this? I found :help denite-map-print_messages in the docs, but it didn't seems applicable.

Nothing.

Shougo commented 5 years ago

DeniteProjectDir searches the root marker from parent directory. So, I think your directory is not so small.

Shougo commented 5 years ago

You should see the issue template. Your report is not reproduce-able for other people. Unfortunately, I will ignore non reproduce-able report.

mMontu commented 5 years ago

I don't reproduce the problem.

OK, makes perfect sense. I'll try to find a minimal setup to reproduce it and create a new issue. Thanks for your help!