VIM version
VIM - Vi IMproved 8.1 (2018 May 18, compiled Oct 26 2018 12:36:32)
Included patches: 1-497
Operating System: Ubuntu 18.04.1 LTS
Vim is slowed down in following cases:
:profile ~/vim_profile.log
:profile file *
:profile func *
FUNCTIONS SORTED ON TOTAL TIME
count total (s) self (s) function
30 9.368570 0.002536 ale#CallWithCooldown()
5 9.348243 0.000459 ale#Lint()
5 9.347211 0.000537 <SNR>15_ALELintImpl()
5 9.341646 0.001122 ale#engine#RunLinters()
5 9.339271 0.000471 <SNR>44_RunLinter()
10 9.319802 0.000230 ale_linters#python#pyflakes#GetExecutable()
10 9.319572 0.000880 ale#python#FindExecutable()
10 9.317714 9.300010 ale#python#FindVirtualenv()
5 5.011503 0.000321 <SNR>44_InvokeChain()
5 4.994441 0.000740 ale#engine#ProcessChain()
5 4.993701 0.000222 ale#linter#GetCommand()
5 4.993406 0.000259 ale_linters#python#pyflakes#GetCommand()
5 4.327129 0.000226 ale#linter#GetExecutable()
5 0.016741 0.002560 <SNR>44_RunJob()
5 0.016297 0.000936 <SNR>49_VimCloseCallback()
5 0.015099 0.000683 <SNR>49_VimExitCallback()
10 0.014274 0.000846 <SNR>44_HandleExit()
10 0.012996 0.000600 ale#Queue()
730 0.012694 ale#path#Simplify()
3 0.011843 0.000387 ale#engine#HandleLoclist()
FUNCTIONS SORTED ON SELF TIME
count total (s) self (s) function
10 9.317714 9.300010 ale#python#FindVirtualenv()
730 0.012694 ale#path#Simplify()
176 0.008408 ale#Var()
15 0.011010 0.007305 ale#linter#Get()
5 0.005921 ale#util#Writefile()
26 0.004477 <SNR>21_Highlight_Matching_Pair()
5 0.004629 0.004302 ale#job#Start()
30 0.008141 0.003983 ale#ShouldDoNothing()
3 0.006079 0.002900 ale#sign#SetSigns()
5 0.016741 0.002560 <SNR>44_RunJob()
30 9.368570 0.002536 ale#CallWithCooldown()
10 0.002446 0.002157 ale#path#Upwards()
5 0.007417 0.001431 <SNR>44_CreateTemporaryFileForJob()
10 0.011469 0.001346 <SNR>15_ALEQueueImpl()
15 0.006979 0.001340 <SNR>50_EchoImpl()
11 0.002096 0.001298 ale#cursor#EchoCursorWarningWithDelay()
15 0.001271 <SNR>35_GetAliasedFiletype()
15 0.001186 ale#linter#GetAll()
5 9.341646 0.001122 ale#engine#RunLinters()
3 0.001098 0.001040 ale#engine#RemoveManagedFiles()
FUNCTION ale#python#FindVirtualenv()
Defined: ~/.vim/bundle/ale/autoload/ale/python.vim line 57
Called 10 times
Total time: 9.317714
Self time: 9.300010
count total (s) self (s)
70 0.004882 0.002436 for l:path in ale#path#Upwards(expand('#' . a:buffer . ':p:
h'))
" Skip empty path components returned in MSYS.
60 0.000219 if empty(l:path)
continue
60 0.000075 endif
420 0.004772 0.001919 for l:dirname in ale#Var(a:buffer, 'virtualenv_dir_name
s')
360 0.015215 0.008383 let l:venv_dir = ale#path#Simplify( join([l:path,
l:dirname], s:sep))
360 0.012649 0.007076 let l:script_filename = ale#path#Simplify( join([
l:venv_dir, s:bin_dir, 'activate'], s:sep))
360 9.275185 if filereadable(l:script_filename)
return l:venv_dir
360 0.000497 endif
420 0.000597 endfor
70 0.000098 endfor
10 0.000086 return $VIRTUAL_ENV
I'm not sure, but maybe it's similar to https://github.com/w0rp/ale/issues/563#issue-229379398
I still don't know why filereadable is so time consuming, but currently I just updated if filereadable(l:script_filename) to if !empty(l:script_filename), and it works well for me, for now.
You can disable this behavior with let g:ale_virtualenv_dir_names = [], if accessing your filesystem is slow. Then you will have to set VIRTUAL_ENV yourself if you want to use a virtualenv directory.
Do you think can we improve on this by using async features?
Eventually yes, with this: #2132
Most helpful comment
You can disable this behavior with
let g:ale_virtualenv_dir_names = [], if accessing your filesystem is slow. Then you will have to setVIRTUAL_ENVyourself if you want to use a virtualenv directory.