dense-analysis / ale

Check syntax in Vim/Neovim asynchronously and fix files, with Language Server Protocol (LSP) support
BSD 2-Clause "Simplified" License
13.58k stars 1.44k forks source link

FindNearestFile makes vim lag on large file tree #2613

Closed kovasap closed 5 years ago

kovasap commented 5 years ago

Information

VIM version NVIM v0.3.3 Build type: Release LuaJIT 2.1.0-beta3

Operating System: Linux

What went wrong

Noticeable lag when typing or doing other actions in vim. Here is a profile.log summary captured when typing a few random words:

FUNCTIONS SORTED ON TOTAL TIME
count  total (s)   self (s)  function
    3   3.384851   0.000768  <SNR>233_Lint()
    3   3.381752   0.001105  ale#engine#RunLinters()
   21   3.379934   0.000896  <SNR>247_RunLinter()
   21   2.294387   0.000450  ale#linter#GetExecutable()
    9   2.293543   0.001043  ale#node#FindExecutable()
   15   2.291972             ale#path#FindNearestFile()
   21   1.084651   1.083396  ale#engine#IsExecutable()
    3   0.943655   0.000039  ale#handlers#textlint#GetExecutable()
    3   0.892920   0.000044  ale#handlers#writegood#GetExecutable()
    3   0.457110   0.000059  <lambda>1()
    8   0.066112   0.012619  airline#highlighter#highlight()
   29   0.061725   0.004581  airline#check_mode()
   29   0.053786   0.000613  airline#extensions#branch#get_head()
   29   0.053172   0.000854  airline#extensions#branch#head()
   29   0.046341   0.001467  <SNR>213_update_branch()
   29   0.044474   0.007013  <SNR>213_update_hg_branch()
  259   0.043004   0.010788  airline#highlighter#exec()
  483   0.038089   0.017356  airline#highlighter#get_highlight()
   29   0.031509   0.028511  lawrencium#statusline()
   96   0.028558   0.002205  <SNR>224_exec_separator()

FUNCTIONS SORTED ON SELF TIME
count  total (s)   self (s)  function
   15              2.291972  ale#path#FindNearestFile()
   21   1.084651   1.083396  ale#engine#IsExecutable()
   29   0.031509   0.028511  lawrencium#statusline()
  966              0.017756  <SNR>224_get_syn()
  483   0.038089   0.017356  airline#highlighter#get_highlight()
    8   0.066112   0.012619  airline#highlighter#highlight()
   14              0.011560  <SNR>278__redir()
  259   0.043004   0.010788  airline#highlighter#exec()
   12   0.010861   0.007417  <SNR>278__build_module()
   29   0.044474   0.007013  <SNR>213_update_hg_branch()
   12   0.027511   0.006507  <SNR>278__import()
  259              0.006038  <SNR>224_CheckDefined()
    2   0.005856   0.005808  airline#async#nvim_get_mq_async()
   29   0.005949   0.005547  <SNR>213_update_untracked()
    7   0.005117   0.004963  airline#extensions#tabline#formatters#default#format()
   29   0.061725   0.004581  airline#check_mode()
    1   0.003968   0.003616  sy#repo#get_diff_start()
   16   0.013337   0.003572  <SNR>278__get_sid_by_script()
   58   0.005690   0.003457  airline#extensions#ale#get()
   29   0.003395   0.003012  airline#extensions#whitespace#check()

Reproducing the bug

Try editing in very large file tree, where vim instance was started at root and you are editing a file ~5-10 directories deep.

:ALEInfo

 Current Filetype: markdown
Available Linters: ['alex', 'markdownlint', 'mdl', 'proselint', 'redpen', 'remark_lint', 'textlint', 'vale', 'writegood']
   Linter Aliases:
'remark_lint' -> ['remark-lint']
'writegood' -> ['write-good']
  Enabled Linters: ['alex', 'markdownlint', 'mdl', 'proselint', 'redpen', 'remark_lint', 'textlint', 'vale', 'writegood']
 Suggested Fixers:
  'prettier' - Apply prettier to a file.
  'remove_trailing_lines' - Remove all blank lines at the end of a file.
  'textlint' - Fix text files with textlint --fix
  'trim_whitespace' - Remove all trailing whitespace characters at the end of every line.
 Linter Variables:

let g:ale_markdown_mdl_executable = 'mdl'
let g:ale_markdown_mdl_options = ''
 Global Variables:

let g:ale_cache_executable_check_failures = v:null
let g:ale_change_sign_column_color = 0
let g:ale_command_wrapper = v:null
let g:ale_completion_delay = v:null
let g:ale_completion_enabled = 0
let g:ale_completion_max_suggestions = v:null
let g:ale_echo_cursor = 1
let g:ale_echo_msg_error_str = 'Error'
let g:ale_echo_msg_format = '%code: %%s'
let g:ale_echo_msg_info_str = 'Info'
let g:ale_echo_msg_warning_str = 'Warning'
let g:ale_enabled = 1
let g:ale_fix_on_save = 0
let g:ale_fixers = {}
let g:ale_history_enabled = 1
let g:ale_history_log_output = 1
let g:ale_keep_list_window_open = 0
let g:ale_lint_delay = 200
let g:ale_lint_on_enter = 1
let g:ale_lint_on_filetype_changed = 1
let g:ale_lint_on_insert_leave = 0
let g:ale_lint_on_save = 1
let g:ale_lint_on_text_changed = 'always'
let g:ale_linter_aliases = {}
let g:ale_linters = {'java': [], 'python': ['gpylint']}
let g:ale_linters_explicit = 0
let g:ale_list_vertical = 0
let g:ale_list_window_size = 10
let g:ale_loclist_msg_format = '%code: %%s'
let g:ale_max_buffer_history_size = 20
let g:ale_max_signs = -1
let g:ale_maximum_file_size = v:null
let g:ale_open_list = 0
let g:ale_pattern_options = v:null
let g:ale_pattern_options_enabled = v:null
let g:ale_set_balloons = 0
let g:ale_set_highlights = 1
let g:ale_set_loclist = 1
let g:ale_set_quickfix = 0
let g:ale_set_signs = 1
let g:ale_sign_column_always = 0
let g:ale_sign_error = '>>'
let g:ale_sign_info = '--'
let g:ale_sign_offset = 1000000
let g:ale_sign_style_error = '>>'
let g:ale_sign_style_warning = '--'
let g:ale_sign_style_warning = '--'
let g:ale_sign_warning = '--'
let g:ale_statusline_format = v:null
let g:ale_type_map = {}
let g:ale_use_global_executables = v:null
let g:ale_virtualtext_cursor = 0
let g:ale_warn_about_trailing_blank_lines = 1
let g:ale_warn_about_trailing_whitespace = 1
  Command History:
(executable check - failure) alex
(executable check - failure) markdownlint
(executable check - failure) mdl
(executable check - failure) proselint
(executable check - failure) redpen
(executable check - failure) remark
(executable check - failure) textlint
(executable check - failure) vale
(executable check - failure) write-good

Any ideas for working around this?

kovasap commented 5 years ago

Also, I think the directory tree I'm working on is a network mounted file system. I think it takes so long to do this checking because of the network latency. Is there any way to just disable it all?

kovasap commented 5 years ago

I've tried specifying the executable of my linters with g:alepython_executable = "path" and have set g:ale_use_global_executables = 1.

w0rp commented 5 years ago

You're going to have a lot of trouble with network mounted file systems. My advice is to search through all of the options for the linters you use and disable as many options that cause files to be searched, and try to avoid network mounts if you can. At the moment, there's nothing else that can be done about this.

In the future, ale#command#Run could be used to perform searches for files in another process, which would mean there would be no more input lag in Vim. This is easier said than done.

kovasap commented 5 years ago

Ok. I have a workable state now with specifically chosen linters and let g:ale_cache_executable_check_failures = 1!