Bug 367882 - FileFilter implementation cause konsole cpu usage to go to 80-100%
Summary: FileFilter implementation cause konsole cpu usage to go to 80-100%
Status: RESOLVED WORKSFORME
Alias: None
Product: konsole
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: Konsole Developer
URL:
Keywords: regression
Depends on:
Blocks:
 
Reported: 2016-08-27 05:48 UTC by John Stanley
Modified: 2024-04-23 03:47 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Program, that illustrates regexp slowness on complex regexps (453 bytes, text/x-python)
2016-12-01 20:24 UTC, Alexander
Details

Note You need to log in before you can comment on or make changes to this bug.
Description John Stanley 2016-08-27 05:48:00 UTC
With commit 9d2fd9a3583c85d8c64cee1a46183befd5d5e5d6, "Implement a new file filter using POSIX Portable Filename Character Set", konsole consumes 80-100% cpu for 1-3 second periods when selecting/high-lighting text displayed after issuing, e.g., 'ls -R'  or 'find -name xx' on directories with many sub-directories/files. Also, afterward, konsole is erratically sluggish, using 11-40% cpu during routine activities.

Version konsole-16.04.3 (or commits prior to 9d2fd9a3583c85d8c64cee1a46183befd5d5e5d6 do not exhibit this behavior.

Reproducible: Always

Steps to Reproduce:
1. launch 'top' in a non-konsole terminal, say, QTerminal, to monitor CPU activity
2. launch konsole
3. in konsole, issue 'find ' or 'ls -R' in a directory with many sub-directories/files

Actual Results:  
After issuing the 'find' or 'ls -R' commands, konsole erratically uses 8-13% cpu.

Further, double-left clicking on any of the displayed filenames (for copy/paste purposes), takes up to 2-3 seconds for the string to be high-lighted, and cpu usage jumps to 80-100% for 1-3 seconds.

Further, scrolling has horrible delays and konsole is generally sluggish at this point onward, and, changing focus to/from konsole to another window is also sluggish. At this point, konsole erratically uses 11-39% cpu.

Expected Results:  
Repeating the above steps for konsole versions prior to this commit never show more than 1-3% cpu for copy/pasting. Konsole should not exhibit such high cpu and become sluggish under said conditions.
Comment 1 Kurt Hindenburg 2016-08-28 22:59:54 UTC
Martin, do you think we should have the profile setting to show these links disabled by default? Or do you have any other suggestions/opinions?
Comment 2 Kurt Hindenburg 2016-09-03 21:36:42 UTC
Git commit 07cbdbcd128781fe77d78533436ef2172dcc5993 by Kurt Hindenburg.
Committed on 03/09/2016 at 21:34.
Pushed by hindenburg into branch 'Applications/16.08'.

Change the default to not underline links

Set UnderlineLinksEnabled to false for now.  Users can alway enable in
profile settings.

M  +1    -1    src/Profile.cpp

http://commits.kde.org/konsole/07cbdbcd128781fe77d78533436ef2172dcc5993
Comment 3 Martin Sandsmark 2016-09-04 12:47:08 UTC
I created https://git.reviewboard.kde.org/r/128828/ to be able to disable the file filter, I can update it to make it off by default as well.

There must be another root cause here, though, the filter shouldn't be invoked during those activities. I'll try to figure out what happens here.
Comment 4 Martin Sandsmark 2016-09-04 13:08:09 UTC
I think the issue is that Konsole::ScreenWindow::outputChanged() is emitted every time a mouse button is clicked or the selection changes, which invalidates the current filter results, which leads to re-evaluating the filters when the mouse moves.

The file filter itself should also be optimized, maybe a more generic pre-filtering for valid filenames first, and maybe som pre-processing. And the generated regex could probably also be optimized a bit. And some caching wouldn't be a bad idea either.

I'm unable to reproduce the issue, though, even with Konsole filled with filenames. John; could you add a «qDebug() << regexp;» at line 543 in Filter.cpp, and upload the regex that is generated? It sounds like the generated regexp for you manages to trigger a really bad edge case.
Comment 5 Martin Sandsmark 2016-09-04 13:09:29 UTC
Sorry, I meant line 546, and «qDebug().noquote() << regex;» is probably better.
Comment 6 John Stanley 2016-09-09 00:29:27 UTC
(In reply to Martin Sandsmark from comment #5)
> Sorry, I meant line 546, and «qDebug().noquote() << regex;» is probably
> better.

Sorry for the delay; here's the regex:
FileFilter::FileFilter(session): (\b|/)+[A-Za-z0-9\._\-/]+(\.sv4crc|\.svgz|\.bak|\.old|\.sik|\.sldx|\.es|\.pak|\.nsv|\.p65|\.pm|\.pm6|\.pmd|\.lyx|\.sdd|\.sdp|\.css|\.t2t|\.fli|\.flc|\.csv|\.ods|\.afm|\.wql|\.abc|\.nef|\.karbon|\.tr1|\.tr1\.gz|\.rss|\.dmol|\.outmol|\.pk|\.kpat|\.mp2|\.xmi|\.xmi\.tgz|\.xmi\.tar\.bz2|\.m4a|\.f4a|\.sv|\.snf|\.snf\.Z|\.snf\.gz|\.js|\.jsm|\.mod|\.ult|\.uni|\.m15|\.mtm|\.669|\.med|\.skz|\.ttl|\.ksp|\.reg|\.ogm|\.pls|\.vala|\.vapi|\.lz|\.svg|\.602|\.avi|\.avf|\.divx|\.mhtml|\.mht|\.cur|\.ani|\.hpgl|\.it|\.xbm|\.xhtml|\.xht|\.sgf|\.cbin|\.scala|\.wmp|\.aup|\.nb|\.kug|\.ogg|\.fods|\.wmv|\.msi|\.mk|makefile|GNUmakefile|\.mak|Makefile\.|\.xlsx|cachegrind\.out|callgrind\.out|\.cer|\.vcs|\.ics|\.ace|\.texi|\.texinfo|\.opus|\.got|\.out|\.kut|\.wbmp|\.sxm|\.mcif|\.icc|\.icm|\.tnef|\.tnf|winmail\.dat|\.hdr|\.pic|\.ml|\.mli|\.bz2|\.bz|\.kpm|\.inchix|\.odf|\.gamin|\.inp|\.ins|\.res|\.xsl|\.xslt|\.kth|\.oga|\.ged|\.gedcom|\.sdc|\.dotx|\.ief|\.pgm|\.qt|\.mov|\.moov|\.qtvr|\.nfo|\.bin|\.pot|\.qml|\.qmltypes|\.qmlproject|\.sv4cpio|\.dtshd|\.as|\.smi|\.sami|\.jceks|README|\.7z|\.fb2|\.wv|\.wvp|\.fgeo|\.m4|\.ttf|\.ttc|\.oxps|\.xps|\.pdf\.bz2|\.xcf\.gz|\.xcf\.bz2|\.sgrd|\.pub|\.p7s|\.xdgapp|\.atom|\.ssa|\.ass|\.lzma|\.srt|\.scm|\.ss|\.Z|\.fxm|\.ttx|\.kexis|\.der|\.crt|\.cert|\.pem|gmon\.out|\.tgf|\.oxt|\.minipsf|\.mgp|\.m2t|\.m2ts|\.ts|\.mts|\.cpi|\.clpi|\.mpl|\.mpls|\.bdm|\.bdmv|\.kml|\.quanta|\.dsl|\.fodt|\.vcard|\.vcf|\.vct|\.gcrd|\.xml|\.xbl|\.xsd|\.rng|\.tar\.Z|\.taz|SConstruct|SConscript|SConscript\.|\.wwf|\.key|\.wad|\.ly|\.tar\.lrz|\.tlrz|\.wma|\.cdxml|\.dmg|\.por|\.plan|\.5vw|\.5vw\.gz|meson\.build|meson_options\.txt|\.siag|\.hwp|\.arc|\.car|\.eml|\.torrent|\.stw|\.hwt|\.jnlp|\.spx|\.php|\.php3|\.php4|\.php5|\.phps|\.htm|\.lzo|\.gb|\.gbc|\.cgb|\.sgb|\.pc|\.xmf|\.lnk|\.jpr|\.jpx|\.ora|\.ram|\.gnd|\.sub|\.qp|\.fo|\.xslfo|\.mab|\.it87|\.sxi|\.sh|\.sms|\.gg|\.sg|\.jng|\.mkv|\.egon|\.jrd|\.rdf|\.rdfs|\.owl|\.mxf|\.m4b|\.f4b|\.kgt|\.pcf|\.metalink|\.toc|\.kdc|\.webp|\.desktop|\.kdelnk|\.directory|\.dvi\.gz|\.cpp|\.cxx|\.cc|\.C|\.pcx|\.sisx|\.pptx|\.kolf|\.course|\.kourse|\.p|\.pas|\.gba|\.agb|\.wkdownload|\.crdownload|\.part|\.sfc|\.smc|\.asn|\.m|\.opml|\.xpm|\.xbel|\.shar|\.psf|\.ps\.bz2|\.pw|\.pdb|\.pdc|\.n64|\.z64|\.v64|\.movie|\.mka|\.fb2\.zip|\.smf|\.qtif|\.qif|\.ooc|\.cs|\.webm|\.kpatience|\.odc|\.fits|\.odb|\.iptables|\.sxd|\.pl|\.PL|\.al|\.perl|\.pod|\.t|\.kgeo|\.jp2|\.jpf|\.py|\.pyx|\.wsgi|\.dtd|\.rpm|\.class|ChangeLog|\.jar|\.siv|\.ufraw|\.wmf|\.wb1|\.wb2|\.wb3|\.tar\.lz|\.h|\.vhd|\.vhdl|\.kplatowork|\.gra|\.mdb|\.json-patch|\.kvtml|\.dc|\.pkipath|\.flv|\.potx|\.ogv|\.swf|\.spl|\.ras|\.msod|\.vrm|\.vrml|\.wrl|\.dbk|\.docbook|\.icb|\.tga|\.tpic|\.vda|\.vst|\.okular|\.tox|\.wpl|\.dts|\.mdl|\.mol|\.kplato|\.ai|\.dds|\.gif|\.raw-disk-image\.xz|\.img\.xz|\.kwl|\.cr2|\.pct|\.pict|\.pict1|\.pict2|\.pgp|\.gpg|\.asc|\.src\.rpm|\.spm|\.alz|\.svh|\.cpio\.gz|\.planwork|\.spec|\.url|\.woff|\.psd|\.src|\.lwo|\.lwob|\.o|\.pcd|\.idl|\.kmz|\.otf|\.lws|\.glade|\.raf|\.mdi|\.bib|\.dx|\.jdx|\.flac|\.sid|\.psid|\.dwg|\.vsd|\.vsw|\.vss|\.rw2|\.xwd|\.ppz|\.ppt|\.pps|\.tif|\.tiff|\.wcm|\.wdb|\.wks|\.wps|\.xlr|\.cdf|\.nc|\.m1u|\.m4u|\.mxu|\.pfa|\.pfb|\.gsf|\.dng|\.pce|\.voc|\.xul|\.ots|\.sgi|\.csh|\.fl|\.manifest|\.dxf|\.crw|\.jsonld|\.prc|\.pqa|\.oprc|\.au|\.snd|\.eps\.gz|\.epsi\.gz|\.epsf\.gz|\.moc|\.aac|\.raw-disk-image|\.img|\.mof|\.me|\.mif|\.vsdx|\.pdf|\.mm|\.flw|\.dvi|RMAIL|\.ac3|\.ms|\.el|\.aw|\.diff|\.patch|\.ui|\.pptm|\.pnm|\.txt|\.doc|\.ini|\.inf|\.sgml|\.sgm|\.c3d|\.xar|\.pkg|\.sldm|\.sun|\.qtl|\.man|\.epub|\.ra|\.rax|\.lha|\.lzh|\.qti|\.qti\.gz|\.csvs|\.cue|\.vssx|\.rgb|\.obj|\.themepack|\.tar\.lzo|\.tzo|\.nds|\.kexic|\.xi|\.seg|\.yaml|\.yml|\.xm|\.hex|\.dvi\.bz2|\.lhz|\.shp|\.shape|\.cascii|\.log|\.rd|\.sds|\.oda|\.mobi|\.nsc|\.psw|\.hin|AUTHORS|\.pcl|\.plasmoid|\.mp3|\.mpga|\.gnumeric|\.geojson|\.geo\.json|\.vstx|\.la|\.ica|\.sda|\.PAR2|\.par2|\.a|\.ar|\.arj|\.wvc|\.ott|\.xlsb|\.xz|\.kcsrc|\.uin|\.icq|\.emf|\.rb|\.shtml|\.pbm|\.kexi|\.docm|\.oleo|\.wri|\.gsm|\.blender|\.blend|\.BLEND|\.m3u|\.m3u8|\.vlc|\.wml|\.asp|\.amz|\.jks|\.ks|cacerts|\.iso|\.iso9660|\.zz|\.vssm|\.cdr|\.chm|\.kig|\.kigz|\.cgm|\.sav|\.zsav|\.tuberling|\.xpi|\.wmls|\.ppam|\.x3f|\.v|\.trc0|\.trc1|\.trc0\.gz|\.trc1\.gz|\.coffee|\.fkt|\.theme|\.xlam|\.potm|\.java|\.pcap|\.cap|\.dmp|\.pcap\.gz|\.snoop|\.snoop\.gz|\.rtx|\.hh|\.hp|\.hpp|\.hxx|\.ogx|\.tcl|\.tk|\.kfo|\.p7c|\.p7m|\.mdf|\.gv|\.dot|\.oth|\.abw|\.abw\.CRASHED|\.abw\.gz|\.zabw|\.etheme|\.wp|\.wp4|\.wp5|\.wp6|\.wpd|\.wpp|\.pack|\.rf5|\.rf5\.gz|\.mup|\.not|\.gz|COPYING|\.hdf|\.hdf4|\.h4|\.hdf5|\.h5|\.xltm|\.orf|\.ez|\.sql|\.gpt|\.g92|\.g94|\.g98|\.g03|\.gal|\.pyc|\.pyo|\.kopete-emoticons|\.gml|\.gau|\.gjc|\.gjf|\.eps|\.epsi|\.epsf|\.sr2|\.mpc|\.mpp|\.ps\.gz|\.smiles|\.cpio|\.kdenlivetitle|\.uue|\.AppImage|\.docx|\.erl|\.war|\.alc|\.eps\.bz2|\.epsi\.bz2|\.epsf\.bz2|\.tpc|\.apc|\.wpz|\.tpc\.gz|\.apc\.gz|\.wpz\.gz|\.ccmx|\.vmd|\.tex|\.ltx|\.sty|\.cls|\.dtx|\.latex|\.gpx|\.nes|\.nez|\.unf|\.unif|\.stc|\.sk|\.sk1|\.lua|\.awk|\.3ds|\.pgn|\.mpeg|\.mpg|\.mpe|\.vob|\.hessian|\.hessianx|\.xhessian|\.tar\.lz4|\.so|\.dll|\.dcl|\.sti|\.go|\.mp4|\.m4v|\.f4v|\.lrv|\.pdf\.xz|\.tta|\.xlf|\.xliff|\.ag|\.rle|\.srf|\.sxw|\.kra|\.3g2|\.3gp2|\.3gpp2|\.djvu|\.djv|\.dat|\.mop|\.mopcrt|\.zmt|\.k25|\.bcpio|\.odg|\.cdx|\.ppsm|\.otc|\.3gp|\.3gpp|\.3ga|\.kwd|\.kwt|\.dcr|\.p10|\.p12|\.pfx|\.uil|\.gmo|\.mo|\.gp|\.gplt|\.gnuplot|\.dia|\.lwp|\.axa|\.smil|\.sml|\.kino|\.html|\.rt|\.trig|\.tar|\.gtar|\.gem|\.chrt|\.kim|\.deb|\.udeb|\.adf|CREDITS|\.kns|\.etx|\.sit|\.bay|\.bmq|\.cs1|\.cs2|\.erf|\.fff|\.hrd|\.mdc|\.mos|\.pnx|\.rdc|\.crl|\.gen|\.tar\.lzma|\.tlz|\.gf|\.zoo|\.sxg|\.vtt|\.dv|\.spd|\.xls|\.xlc|\.xll|\.xlm|\.xlw|\.xla|\.xlt|\.xld|\.rxn|\.moo|\.kil|\.gam|\.gamout|\.rm|\.rmj|\.rmm|\.rms|\.rmx|\.rmvb|\.sig|\.fonts\.zip|\.sdw|\.vor|\.sgl|INSTALL|\.stm|\.rv|\.rvx|\.tar\.bz2|\.tar\.bz|\.tbz2|\.tbz|\.tb2|\.cac|\.cache|\.vstm|\.msx|\.psf\.gz|\.ppm|\.cbl|\.cob|\.rtf|\.ps|\.tr|\.roff|\.ml2|\.mol2|\.sy2|\.ldif|\.vsdm|\.awb|\.rs|\.g3|\.exe|\.com|\.hs|\.sam|\.sylk|\.slk|\.vbs|\.owx|\.ppsx|\.val|\.mbox|\.p7b|\.spc|\.po|\.axv|\.dar|\.ustar|\.s3m|\.rej|\.mrw|\.bmp|\.md|\.mkd|\.markdown|\.sis|\.bfr|\.bfr\.gz|\.icns|\.pln|\.sd|\.sdf|\.rp|\.dbf|\.adb|\.ads|\.katefl|\.cif|\.ctab|\.pntg|\.gs|\.aifc|\.aiffc|\.aiff|\.aif|\.jad|\.std|\.psflib|\.wim|\.swm|\.iff|\.ilbm|\.lbm|\.tsv|\.p8|\.cb7|\.raw|\.mrml|\.mrl|\.xltx|\.kdenlive|\.ape|\.rar|\.osm|\.osc|\.emp|\.tar\.gz|\.tgz|\.bdf|\.nzb|\.kpr|\.kpt|\.sxc|\.shx|\.d|\.di|\.smd|\.32x|\.mdx|\.fodg|\.fig|\.xspf|\.exr|\.asx|\.wax|\.wvx|\.wmx|\.cab|\.pcf\.Z|\.pcf\.gz|\.shn|\.meta4|\.fodp|\.png|\.ico|\.pdf\.gz|\.gvp|\.mng|\.odt|\.kmdr|\.otg|\.tar\.xz|\.txz|\.e|\.eif|\.mmd|\.mmod|\.xyz|\.imy|\.ime|\.rnc|\.cbr|\.kon|\.cbt|\.zip|\.otp|\.cbz|\.asf|\.westley|\.mlt|\.f|\.f90|\.f95|\.for|\.gnucash|\.gnc|\.xac|\.mmf|\.smaf|\.cmake|CMakeLists\.txt|\.inchi|\.arw|\.wav|\.ocl|\.k3b|\.odp|\.anx|\.jpeg|\.jpg|\.jpe|\.odi|\.skr|\.pkr|\.xcf|\.pef|\.123|\.wk1|\.wk3|\.wk4|\.mid|\.midi|\.kar|\.cda|\.json|\.dotm|\.xlsm|\.mk3d|\.dcm|dicomdir|\.hlp|\.kud|\.cml|\.kolfgame|\.lz4|\.viv|\.vivo|\.wpg|\.odm|\.pla|\.apk|\.mo3|\.pcapng|\.ntar|\.pcapng\.gz|\.ntar\.gz|\.mml|\.lrz|\.ent|\.c|core|\.amr|\.lhs){1}\b
Comment 7 Michael Palimaka 2016-09-09 19:09:33 UTC
I'm experiencing the same issue, bisecting it to the same commit as mentioned in comment #0. The lag/delays are bad enough to make Konsole basically unusable for me, so I'm more than happy to assist with testing or debugging anything.
Comment 8 Alexander 2016-12-01 20:24:52 UTC
Created attachment 102564 [details]
Program, that illustrates regexp slowness on complex regexps

I found a good test case when FileFilter causes consuming a lot of CPU:
echo '/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////'

And move the mouse inside the window.

The big regular expression is formed from mimeDatabase.allMimeTypes(). If you have more than 1000 mime types registered (it is 992 in default Kubuntu 16.10 installation) the pcre jit compiler generates very slow code.

I created small python program to illustrate this behaviour.

$ python3 slow_regexp.py
1000 in 0.08 sec
1001 in 4.62 sec

The constant 1000 is rec_limit in pcre_compile.c:
http://vcs.pcre.org/pcre/code/trunk/pcre_compile.c?view=markup

It seems, that other mechanism than mimeDatabase.allMimeTypes() is needed to create the regexp.
Comment 9 Kurt Hindenburg 2024-03-24 21:39:55 UTC
Let us know if this is still an issue on a recent qt6 version.
Comment 10 Bug Janitor Service 2024-04-08 03:47:26 UTC
Dear Bug Submitter,

This bug has been in NEEDSINFO status with no change for at least
15 days. Please provide the requested information as soon as
possible and set the bug status as REPORTED. Due to regular bug
tracker maintenance, if the bug is still in NEEDSINFO status with
no change in 30 days the bug will be closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

If you have already provided the requested information, please
mark the bug as REPORTED so that the KDE team knows that the bug is
ready to be confirmed.

Thank you for helping us make KDE software even better for everyone!
Comment 11 Bug Janitor Service 2024-04-23 03:47:16 UTC
This bug has been in NEEDSINFO status with no change for at least
30 days. The bug is now closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

Thank you for helping us make KDE software even better for everyone!