dense-analysis / ale

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

SetBufferContents gets slow during a session #4818

Closed amadeus closed 2 months ago

amadeus commented 2 months ago

Information

VIM version MacVim, version: VIM - Vi IMproved 9.1 (2024 Jan 02, compiled Jul 26 2024 15:42:32) macOS version - arm64 Included patches: 1-610

Operating System: macOS 14.6.1

What went wrong

It appears that over time in a vim editing session, ALEFix will slow to a crawl. Here's a profile of the ALEFix when it's slow:

https://gist.github.com/amadeus/633805729ebaad09c2280db48e9598d8

It appears the issue is in SetBufferContents, specifically the line call setbufline(a:buffer, 1, l:new_lines) util.vim#534

If I close vim and re-open MacVim, make some changes and then re-trigger ALEFix, it's fast again. Clearly something is causing issues over time, it may not even be ALE that's the issue, but was wondering if there are any additional ways I could debug this issue.

:ALEInfo

Expand Current Filetype: typescript.tsx Available Linters: ['biome', 'cspell', 'deno', 'eslint', 'standard', 'tslint', 'tsserver', 'typecheck', 'xo'] Enabled Linters: ['biome', 'eslint', 'tslint', 'tsserver', 'typecheck', 'xo'] Ignored Linters: [] Suggested Fixers: 'biome' - Fix JavaScript and TypeScript using biome. 'deno' - Fix TypeScript using deno fmt. 'dprint' - Pluggable and configurable code formatting platform 'eslint' - Apply eslint --fix to a file. 'prettier' - Apply prettier to a file. 'remove_trailing_lines' - Remove all blank lines at the end of a file. 'trim_whitespace' - Remove all trailing whitespace characters at the end of every line. 'tslint' - Fix typescript files with tslint --fix. 'xo' - Fix JavaScript/TypeScript files using xo --fix. Linter Variables: " Press Space to read :help for a setting let g:ale_typescript_tslint_config_path = '' let g:ale_typescript_tslint_executable = 'tslint' let g:ale_typescript_tslint_ignore_empty_files = 0 let g:ale_typescript_tslint_rules_dir = '' let g:ale_typescript_tslint_use_global = 0 let g:ale_typescript_tsserver_config_path = '' let g:ale_typescript_tsserver_executable = 'tsserver' let g:ale_typescript_tsserver_use_global = 0 let g:ale_typescript_xo_executable = 'xo' let g:ale_typescript_xo_options = '' let g:ale_typescript_xo_use_global = 0 Global Variables: " Press Space to read :help for a setting let g:ale_cache_executable_check_failures = v:null let g:ale_change_sign_column_color = 0 let g:ale_command_wrapper = '' let g:ale_completion_delay = 0 let g:ale_completion_enabled = 0 let g:ale_completion_max_suggestions = 200 let g:ale_disable_lsp = 'auto' let g:ale_echo_cursor = 0 let g:ale_echo_msg_error_str = 'Error' let g:ale_echo_msg_format = '[%linter%]% (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 = 1 let g:ale_fixers = {'stylus': ['prettier'], 'c': ['clang-format'], 'typescript': ['prettier'], 'json': ['prettier'], 'javascript': ['prettier'], 'css': ['prettier'], 'python': ['black', 'isort']} let g:ale_history_enabled = 1 let g:ale_info_default_mode = 'preview' 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 = 1 let g:ale_lint_on_save = 1 let g:ale_lint_on_text_changed = 'normal' let g:ale_linter_aliases = {} let g:ale_linters = {'typescript': ['biome', 'eslint', 'tslint', 'tsserver', 'typecheck', 'xo'], 'javascript': ['biome', 'eslint', 'fecs', 'jscs', 'jshint', 'standard', 'tsserver', 'xo']} let g:ale_linters_explicit = 0 let g:ale_linters_ignore = {} let g:ale_list_vertical = 0 let g:ale_list_window_size = 10 let g:ale_loclist_msg_format = '[%linter%]% (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_root = {} 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 = 1 let g:ale_sign_error = 'E' let g:ale_sign_info = 'I' let g:ale_sign_offset = 1000000 let g:ale_sign_style_error = 'E' let g:ale_sign_style_warning = 'W' let g:ale_sign_warning = 'W' let g:ale_sign_highlight_linenrs = 0 let g:ale_type_map = {} let g:ale_use_neovim_diagnostics_api = 0 let g:ale_use_global_executables = v:null let g:ale_virtualtext_cursor = 1 let g:ale_warn_about_trailing_blank_lines = 1 let g:ale_warn_about_trailing_whitespace = 0

The full ALEInfo was too big for this message, so gisted the contents: ALEInfo full output

w0rp commented 2 months ago

@amadeus Weird question: do you have code folding enabling? I've seen it before where updating a Vim buffer when folding was enabled caused Vim to run very slowly.

amadeus commented 2 months ago

@w0rp I do have code folding enabled, I can try with that off and see if I can still repro. FWIW I have foldmethod=indent

amadeus commented 2 months ago

I think you may be onto something with the foldmethod. indent on its own should be pretty harmless, but I did find in my config I had autoload for fugitive filetypes that was erroneously doing a set foldmethod=syntax, when it should've been setlocal foldmethod=syntax.

So far after correcting this, I have not seen these terrible lockups. But will continue to monitor for a few more days just in case. 🙏

amadeus commented 2 months ago

@w0rp Oki, I haven't been able to reproduce the sluggishness since fixing the indent bug above. Going to go ahead and close this issue. Thanks for the tips!