Closed alexr00 closed 7 months ago
It might not have many lines, but the number of lines doesn't really effect the performance all that much.
Sadly It's the length of a single line that significantly impacts performance. I wouldn't really call a +1,000 character line a "quite short" piece of code.
Parsing that line is an inherently hard task, I don't think it can be done both efficiently and correctly with a TextMate parser. The better tree sitter parser derives it's name from exactly this kind of situation; it "trims/caches branches" while the TextMate parser does not. TextMate ends up having to do permutations enumerating/checking all possible branches to try to figure out whether it's the start of a variable declaration or a function declaration. Even if some advanced regex optimizations are made in the syntax, the time complexity of the algorithm is still going to be terrible. It would just be a band-aid that pushed the freeze limit from 1000 characters to, I suppose, 1200 characters.
The default highlighting character limit is below 1000 characters, and if there are issues with it being slow I would recommend reducing the maximum character length down to 250. That should prevent the freezing. I think the only practical change I can make is having a built-in C++ specific version character cap. Although it wouldn't be doing anything special, and I'm certain people would report it as a bug.
Seems nested ()
and <>
inisde word<( ... )>
is causing the problem
s<(()<>()<>()<>()<>()<>()<>()<>()<>()<>()<>()<>()<>()<>())>
s<(<(<(<(<(<(<(<(<(<(>)>)>)>)>)>)>)>)>)>)
I am no longer getting any lag? @jeff-hykin can you confirm?
Wow, yeah absolutely 0 delay now. Glad to see that was fixed
Originally from @JacquesLucke in https://github.com/microsoft/vscode/issues/137106
Issue Type: Bug
Since the text is quite short, I would not expect a noticeable freeze.
I have been sent here from the c++ extension repo: https://github.com/microsoft/vscode-cpptools/issues/8392.
VS Code version: Code 1.61.2 (6cba118ac49a1b88332f312a8f67186f7f3c1643, 2021-10-19T14:58:13.605Z) OS version: Linux x64 5.14.15-arch1-1 Restricted Mode: Yes
System Info
|Item|Value| |---|---| |CPUs|AMD Ryzen 9 3900X 12-Core Processor (24 x 3800)| |GPU Status|2d_canvas: enabledgpu_compositing: enabled
multiple_raster_threads: enabled_on
oop_rasterization: disabled_off
opengl: enabled_on
rasterization: disabled_software
skia_renderer: enabled_on
video_decode: disabled_software
vulkan: disabled_off
webgl: enabled
webgl2: enabled| |Load (avg)|1, 1, 1| |Memory (System)|31.26GB (25.58GB free)| |Process Argv|--crash-reporter-id 5f76c6ba-dfb0-40a8-a382-b82424e84719| |Screen Reader|no| |VM|0%| |DESKTOP_SESSION|plasma| |XDG_CURRENT_DESKTOP|KDE| |XDG_SESSION_DESKTOP|KDE| |XDG_SESSION_TYPE|x11|
Extensions (2)
Extension|Author (truncated)|Version ---|---|--- jupyter|ms-|2021.9.1101343141 jupyter-keymap|ms-|1.0.0A/B Experiments
``` vsliv368:30146709 vsreu685:30147344 python383:30185418 vspor879:30202332 vspor708:30202333 vspor363:30204092 pythontb:30283811 pythonvspyt551:30345470 pythonptprofiler:30281270 vshan820:30294714 vstes263cf:30335440 vscorecescf:30384386 pythondataviewer:30285071 vscod805:30301674 pythonvspyt200:30340761 binariesv615:30325510 vsccppwt:30382697 bridge0708:30335490 dockerwalkthru:30377721 bridge0723:30353136 pythonrunftest32:30373476 pythonf5test824:30373475 javagetstartedt:30391933 pythonvspyt187:30373474 vsqsis200cf:30386380 vsaa593cf:30376535 vssld246cf:30386378 ```