Bug 423680 - Very high CPU load when entering a number in C++ syntax
Summary: Very high CPU load when entering a number in C++ syntax
Status: RESOLVED FIXED
Alias: None
Product: frameworks-syntax-highlighting
Classification: Frameworks and Libraries
Component: syntax (other bugs)
Version First Reported In: 5.71.0
Platform: Neon Linux
: NOR normal
Target Milestone: ---
Assignee: Nibaldo G.
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-06-29 22:42 UTC by Andrey Kozlovskiy
Modified: 2020-07-29 16:19 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed/Implemented In: 5.73.0
Sentry Crash Report:


Attachments
Kwrite: hold '1' key CPU load - Normal vs C++ (522.75 KB, video/mp4)
2020-06-29 22:42 UTC, Andrey Kozlovskiy
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Andrey Kozlovskiy 2020-06-29 22:42:57 UTC
Created attachment 129778 [details]
Kwrite: hold '1' key CPU load - Normal vs C++

When I hold a number key to enter some long number in C++, kwrite/kate starts to lag and one of the CPU cores immediately loads up to 100%.

Problem is specific to C++/ISO C++ syntax. C, Rust, Java, JavaScript, for example, are not affected.

See attached video for example.
Comment 1 Nibaldo G. 2020-07-03 03:13:50 UTC
In the ISO C++ highlighter (isocpp.xml), to detect a number, many context switches occur (there are 4-5 context switches) and there are many RegExpr rules; since suffixes, number types and invalid characters are highlighted. This may explain the high CPU usage.
Comment 2 Nibaldo G. 2020-07-03 07:32:43 UTC
I did tests on "isocpp.xml": in the "Number" context there is a RegExpr rule with a very large regular expression to detect float numbers. This is responsible for slowing down aand using high CPU by writing numbers in C++/ISO C++
Comment 3 Bug Janitor Service 2020-07-05 09:16:30 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/syntax-highlighting/-/merge_requests/10