Open qsantos opened 1 month ago
Sorry for the late response. I can repro the high cpu usage, but only for a few seconds, at least in C++.
Vim is known to struggle with really long lines. After running the snippet through a formatter I do not see a problem with performance. That's not to say things can not be improved, but that would require deeper analysis.
To be clear, I am using a formatter as well, and I encounter the issue without long lines. It was easier to reproduce it with that example, however.
Issue Prelude
Please complete these steps and check these boxes (by putting an
x
inside the brackets) before filing your issue:vim --version
.:YcmDebugInfo
.:YcmToggleLogs
command.vim -Nu /path/to/YCM/vimrc_ycm_minimal
, including what I expected to happen and what actually happened.install.py
(orcmake
/make
/ninja
) including its invocationThank you for adhering to this process! It ensures your issue is resolved quickly and that neither your nor our time is needlessly wasted.
Issue Details
While doing Rust or TypeScript, when editing a file, it can temporarily becomes syntactically invalid. In some cases, this causes many syntax errors in lines below. For non-trivial files, this causes Vim to hang with 100 % CPU usage for up to 1 minute.
cargo init bla
cd bla
src/main.rs
cargo fmt
vim -Nu /path/to/YCM/ycm_vimrc_minimal src/main.rs
r#
(jwir#<Esc>
)I can continue interacting with Vim normally.
Vim hangs for multiple seconds, with 100 % CPU usage.
That code does look ridiculous, and the hang is only a few seconds in that case. However, it is note quite clear what characteristic of the code slows down YouCompleteMe. In any case, I get minute-long hangs with reasonable code in files of a few hundred lines.
Diagnostic data
Profiling
I profiled Vim while triggering this behavior on real code. I observe that 98 % of the CPU time is spent in
<SNR>98_ReceiveMessages()
. More specifically:OnPeriodicTick
would be consistent with the fact that it happens a few moments after the edit. However, I do not know how to profile the Python code in the Vim context.Output of
vim --version
Output of
YcmDebugInfo
Output of
YcmDiags
Logs
They seem to contain nothing interesting.
Output of
git rev-parse HEAD
in YouCompleteMe installation directoryContents of YCM, ycmd and completion engine logfiles
OS version, distribution, etc.
Debian 13 / testing / trixie.
Output of build/install commands
I used
./install.sh --rust-completer --ts-completer
to install YouCompleteMe. Note that I also encountered the issue with TypeScript files, so it is not specific torust-analzyer
.