dense-analysis / dense-analysis/ale

Linting with tsserver causes unbalanced ALELintPre / ALELintPost events.

Open
#3,881 6 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Vim Script
Stars
14k
Forks
1.5k
Avg merge
17h 49m
Merged PRs (30d)
1

Description

## Information

**VIM version**
VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Jul 27 2021 11:46:24)
Included patches: 1-3140

Operating System: Ubuntu 20.04

## What went wrong

I am having significant delays while editing a javascript source file, with ALE configured to use 'tsserver' lsp for error checking.

Simply opening a javascript source file (~1500 lines) causes ale to trigger and keep vim busy (an unresponsive) for 15-17 seconds (timed with a stopwatch over a few runs).

Vim profiling produced the following output:

```
FUNCTIONS SORTED ON TOTAL TIME
count total (s) self (s) function
8 10.936195 0.001552 294_VimOutputCallback()
8 10.934487 0.011693 8()
8 10.922794 0.004513 ale#lsp#HandleMessage()
16 10.875960 0.001762 ale#lsp_linter#HandleLSPResponse()
4 10.874198 0.010286 289_HandleTSServerDiagnostics()
4 10.537103 0.435463 ale#engine#HandleLoclist()
353293 7.472895 5.675680 ale#util#LocItemCompare()
4 4.565259 0.000063 248_ApplyPartialTimer()
4 4.565196 0.010737 306_SetListsImpl()
4 4.348568 0.313646 306_Deduplicate()
4 4.333663 0.006698 ale#engine#SetResults()
129977 4.034922 0.877602 ale#util#LocItemCompareWithText()
4 3.000369 0.033530 ale#highlight#SetHighlights()
4 2.966757 0.450309 ale#highlight#UpdateHighlights()
24738 2.408182 0.159522 307_highlight_range()
24744 2.168205 307_matchaddpos()
216902 2.027183 ale#util#GetItemPriority()
4 1.452017 1.451110 ale#engine#FixLocList()
4 0.886674 0.002318 ale#sign#SetSigns()
4 0.451513 0.054491 305_BuildSignMap()

FUNCTIONS SORTED ON SELF TIME
count total (s) self (s) function
353293 7.472895 5.675680 ale#util#LocItemCompare()
24744 2.168205 307_matchaddpos()
216902 2.027183 ale#util#GetItemPriority()
4 1.452017 1.451110 ale#engine#FixLocList()
129977 4.034922 0.877602 ale#util#LocItemCompareWithText()
4 2.966757 0.450309 ale#highlight#UpdateHighlights()
4 10.537103 0.435463 ale#engine#HandleLoclist()
4 0.433394 0.433366 ale#statusline#Update()
4 0.326593 ale#lsp#response#ReadTSServerDiagnostics()
4 4.348568 0.313646 306_Deduplicate()
4 0.171859 305_GroupLoclistItems()
4 0.168041 305_UpdateLineNumbers()
1970 0.396968 0.167000 ale#sign#GetSignName()
24738 2.408182 0.159522 307_highlight_range()
3853 0.154838 ale#GetLocItemMessage()
4 0.108266 ale#highlight#RemoveHighlights()
4 0.083399 0.081316 ale#sign#GetSignCommands()
24738 0.080455 ale#highlight#CreatePositions()
4 0.451513 0.054491 305_BuildSignMap()
4 0.205537 0.051091 306_FixList()
```

In trying to diagnose this, Ive disabled the following;
```
let g:ale_set_loclist = 0
let g:ale_set_quickfix = 0
let g:ale_open_list = 0
let g:ale_keep_list_window_open = 1
let g:ale_list_window_size = 4
let g:ale_set_signs = 0
"let g:ale_max_signs = 50
let g:ale_set_highlights = 0
let g:ale_echo_cursor = 1
" Uses preview window to show details about the error under the cursor
"let g:ale_cursor_detail = 1
let g:ale_set_balloon = 1
```

With this set, ALE shows almost no visible clues that there are errors, but the delay is still there.

Watching both `vim` and `tsserver` in `htop` shows that `tsserver` becomes busy for around three seconds, then vim sits at 100% for about 14 seconds.

Do you have any ideas on how I can resolve this?

Is there a way I can tell ALE to process only the first 10 or 20 errors? I suspect a simple error
is causing a cascade of errors numering in the thousands.

Thanks.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.