--nextPart6536127.11dkFo2nLB Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Hey all, https://phabricator.kde.org/D11487 got me interested in the performance of Katepart for long lines again. The culprit on my machine really is line layouting - which shouldn't come as a surprise if the line is really long. But what *does* surprise me is the amount of layouting we do. The five lines in the document get layouted ~40 times, even though nothing really changes in the view... Biggest culprits seems to be: Moving Ranges :) The on-the-fly spellchecker code e.g. is using moving ranges. The moving ranges can trigger view updates via notifyAboutRangeChange which gets called in quite a few places, e.g.: #0 0x00007f5553560458 in KTextEditor::ViewPrivate::delayedUpdateOfView()@plt () from /home/milian/projects/compiled/kf5-dbg/lib64/libKF5TextEditor.so.5 #1 0x00007f5553563246 in Kate::TextBuffer::notifyAboutRangeChange (this=, view=0x0, startLine=0, endLine=0, rangeWithAttribute=false) at /home/milian/projects/kf5/src/frameworks/ktexteditor/src/buffer/ katetextbuffer.cpp:991 #2 0x00007f55536917f2 in KateOnTheFlyChecker::misspelling (this=0x55a29c4922d0, word=..., start=) at /home/milian/projects/kf5/src/frameworks/ktexteditor/src/spellcheck/ ontheflycheck.cpp:609 Or also the following. Note there's a frame for TextRange::setFeedback missing below somehow (devirtualization?!): #0 0x00007f9aaddf3458 in KTextEditor::ViewPrivate::delayedUpdateOfView()@plt () from /home/milian/projects/compiled/kf5-dbg/lib64/libKF5TextEditor.so.5 #1 0x00007f9aaddf6246 in Kate::TextBuffer::notifyAboutRangeChange (this=, view=0x0, startLine=0, endLine=0, rangeWithAttribute=false) at /home/milian/projects/kf5/src/frameworks/ktexteditor/src/buffer/ katetextbuffer.cpp:991 #2 0x00007f9aadf234a6 in KateOnTheFlyChecker::deleteMovingRangeQuickly (this=this@entry=0x55e2bd1f9390, range=range@entry=0x55e2bddac920) at /home/milian/projects/kf5/src/frameworks/ktexteditor/src/spellcheck/ ontheflycheck.cpp:863 #3 0x00007f9aadf2361c in KateOnTheFlyChecker::spellCheckDone (this=0x55e2bd1f9390) at /home/milian/projects/kf5/src/frameworks/ktexteditor/ src/spellcheck/ontheflycheck.cpp:633 This will then eventually trigger a relayout: #0 0x00007f554ea21f28 in QTextLine::layout_helper(int) () from /usr/lib/ libQt5Gui.so.5 #1 0x00007f554ea231a1 in QTextLine::setLineWidth(double) () from /usr/lib/ libQt5Gui.so.5 #2 0x00007f555361bd28 in KateRenderer::layoutLine (this=0x55a29c4cc9e0, lineLayout=..., maxwidth=1810, cacheLayout=) at /home/milian/projects/kf5/src/frameworks/ktexteditor/src/render/ katerenderer.cpp:1033 #3 0x00007f55536217e6 in KateLayoutCache::line (this=this@entry=0x55a29ca0e2c0, realLine=realLine@entry=0, virtualLine=virtualLine@entry=-1) at /home/milian/projects/kf5/src/frameworks/ktexteditor/src/render/ katelayoutcache.cpp:313 #4 0x00007f5553621f58 in KateLayoutCache::updateViewCache (this=this@entry=0x55a29ca0e2c0, startPos=..., newViewLineCount=48, newViewLineCount@entry=-1, viewLinesScrolled=viewLinesScrolled@entry=0) at /home/milian/projects/kf5/ src/frameworks/ktexteditor/src/render/katelayoutcache.cpp:242 #5 0x00007f555366caa0 in KateViewInternal::tagLines (this=0x55a29c3ead80, start=..., end=..., realCursors=realCursors@entry=true) at /home/milian/projects/kf5/src/frameworks/ktexteditor/src/view/ kateviewinternal.cpp:2203 #6 0x00007f555366cd49 in KateViewInternal::tagLines (this=, start=, end=, realLines=realLines@entry=true) at /home/milian/projects/kf5/src/frameworks/ktexteditor/src/view/ kateviewinternal.cpp:2176 #7 0x00007f55536548ff in KTextEditor::ViewPrivate::tagLines (this=this@entry=0x55a29ca46050, start=, end=, realLines=realLines@entry=true) at /home/milian/projects/kf5/src/frameworks/ktexteditor/src/view/ kateview.cpp:2012 #8 0x00007f5553663735 in KTextEditor::ViewPrivate::slotDelayedUpdateOfView (this=0x55a29ca46050) at /home/milian/projects/kf5/src/frameworks/ktexteditor/ src/view/kateview.cpp:3385 I don't see an easy way around this. I just note that some calls to `m_buffer.notifyAboutRangeChange` in katetextrange.cpp are guarded with if (m_attribute || m_feedback) while others are not, e.g. in TextRange::setFeedback. Adding those checks could potentially remove some relayouting calls, but I'm not sure whether this is OK to do or not. Christoph? I'll dig a bit deeper and see if more can be found and removed... -- Milian Wolff mail@milianw.de http://milianw.de --nextPart6536127.11dkFo2nLB Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part. Content-Transfer-Encoding: 7Bit -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEezawi1aUvUGg3A1+8zYW/HGdOX8FAlq1cIUACgkQ8zYW/HGd OX+p6RAAmBHZL/XW6xn8AmUtavLXH5s+gk2U7C7XxYZ5JgrkVzdUGXMv08UDp78D l1i+mA/126ZoeVZLPjbfP/4w2i/hDB0RumgGTjzDyBa6DR3lyjPrd1UJUwv1jpQ+ OdZnXQgdpWK+dycBH3apw5IXXlOkHm41m1MbsXy36PhW8cNnR9Qdjnai/Y7G6NzY kSb+6pRjhtjnvk0RcVMOy6h4u6j6YFXVHR7q7WYdi4xILVO5I/qcxk2pLG9/wxaO ArV9N5nMGK4JoeHmxXUAV9bJzNGlRf5xr4fVOLfFROXswGztVLXBfNIeR4hmZooO tfvIyEAaKCxv7mAMXPsUX/35Xhbwh8+qAtSQaXA0Tta7WuT65stISB061w6d4Owf 5IsFU7T1cpE7snBFDXbmu6uDkR+R0dcroWIiwhzthgkbAcNE49CElep0wC5+9lLi 7x+xX2HI+xfiJ8L6WER3676JqIl7dgewYYxOsE/3fuLUSzDm2pTCqxNLLBP8Sjus 4mTnyr0nXrin/Q0vx2R/o3npjRDPpHP0EG4R0Whxb1b8LRZ9og7lXsaowGSAadvT aA2tuuQZIVN1L8nifBQ+Bdlv7TyAgSUbIH5fWYzBkDqrtpALqHWkkHwPRovBoWKf EeP6c2+oP7cLmHwQjCafNDIIgS7ilMm0B1dW7rBfKEuTZSLFd4s= =rSKl -----END PGP SIGNATURE----- --nextPart6536127.11dkFo2nLB--