<table><tr><td style="">mwolff added a comment.
</td><a style="text-decoration: none; padding: 4px 8px; margin: 0 8px 8px; float: right; color: #464C5C; font-weight: bold; border-radius: 3px; background-color: #F7F7F9; background-image: linear-gradient(to bottom,#fff,#f1f0f1); display: inline-block; border: 1px solid rgba(71,87,120,.2);" href="https://phabricator.kde.org/D11487">View Revision</a></tr></table><br /><div><div><blockquote style="border-left: 3px solid #8C98B8;
color: #6B748C;
font-style: italic;
margin: 4px 0 12px 0;
padding: 8px 12px;
background-color: #F8F9FC;">
<div style="font-style: normal;
padding-bottom: 4px;">In <a href="https://phabricator.kde.org/D11487#231656" style="background-color: #e7e7e7;
border-color: #e7e7e7;
border-radius: 3px;
padding: 0 4px;
font-weight: bold;
color: black;text-decoration: none;">D11487#231656</a>, <a href="https://phabricator.kde.org/p/jtamate/" style="
border-color: #f1f7ff;
color: #19558d;
background-color: #f1f7ff;
border: 1px solid transparent;
border-radius: 3px;
font-weight: bold;
padding: 0 4px;">@jtamate</a> wrote:</div>
<div style="margin: 0;
padding: 0;
border: 0;
color: rgb(107, 116, 140);"><blockquote style="border-left: 3px solid #8C98B8;
color: #6B748C;
font-style: italic;
margin: 4px 0 12px 0;
padding: 8px 12px;
background-color: #F8F9FC;">
<div style="font-style: normal;
padding-bottom: 4px;">In <a href="https://phabricator.kde.org/D11487#231522" style="background-color: #e7e7e7;
border-color: #e7e7e7;
border-radius: 3px;
padding: 0 4px;
font-weight: bold;
color: black;text-decoration: none;">D11487#231522</a>, <a href="https://phabricator.kde.org/p/mwolff/" style="
border-color: #f1f7ff;
color: #19558d;
background-color: #f1f7ff;
border: 1px solid transparent;
border-radius: 3px;
font-weight: bold;
padding: 0 4px;">@mwolff</a> wrote:</div>
<div style="margin: 0;
padding: 0;
border: 0;
color: rgb(107, 116, 140);"><p><a href="https://phabricator.kde.org/p/jtamate/" style="
border-color: #f1f7ff;
color: #19558d;
background-color: #f1f7ff;
border: 1px solid transparent;
border-radius: 3px;
font-weight: bold;
padding: 0 4px;">@jtamate</a> looking at your screenshots, it represents closely what I see locally. Most notably, there are no red underlines in your screenshots which could arise due to spell checking. Thus I really wonder why you are seeing such a big hotspot there.</p>
<p>Try perf, or try a poor mans profiler like GDB and regularly interrupt. Do you really end up in <tt style="background: #ebebeb; font-size: 13px;">TextLineData::attribute()</tt>? Or, alternatively: Measure the time it takes for kate/kwrite to open the file and then go to the end. Then compare this before and after your patch. Do you see anything in the order of ~75% reduction for the time then too? Note how callgrind only measure instructions, so a supposed reduction of 75% of instructions should certainly have an impact on time too - of course not 75% too... I simply cannot fathom why you are seeing such an impact but I cannot reproduce this at all!</p></div>
</blockquote>
<p>I've done some measurements, as the times are so big, with a stopwatch 2 times each test.<br />
With "Enable autodetection of Language" and "Automatic spell checking enabled by default" enabled,<br />
the test as before: since pressing "Temporarily raise limit and reload file", press Ctrl+end and finish the scroll to the end of the document.</p>
<p>without any version of the patch:<br />
1 min 25 seconds <br />
With <span class="phabricator-remarkup-mention-unknown">@mwolf</span> solution, used only in spellCheckWrtHighlightingRanges.<br />
38 seconds<br />
With the binary search:<br />
34 seconds</p></div>
</blockquote>
<p>OK, this is a huge win, so I guess one way or another we should integrate this patch. One question to that though: Why do you sort/lookup by <tt style="background: #ebebeb; font-size: 13px;">x.offset + x.length <= p</tt>? Note how lower_bound returns the first iterator that is _not_ going to return true. To me, it looks like your code cannot actually work and will always return 0? Personally, I'd try to use <tt style="background: #ebebeb; font-size: 13px;">upper_bound</tt> with <tt style="background: #ebebeb; font-size: 13px;">x.offset < p</tt> in the comparison. The iterator should then point to the first item that has it's offset larger than <tt style="background: #ebebeb; font-size: 13px;">p</tt>. So decrementing the iterator once (while checking against <tt style="background: #ebebeb; font-size: 13px;">begin()</tt>) yields the iterator that could potentially match. Thus, check if <tt style="background: #ebebeb; font-size: 13px;">p</tt> is contained in its range and if so return it's attribute, otherwise return 0.</p>
<p>Besides this: I am still looking for an explanation why spell checking is so extremely slow for you. I have the same settings enabled, and spell checking is seemingly fast for me... Am I missing some dictionary or something other to reproduce this?</p></div></div><br /><div><strong>REPOSITORY</strong><div><div>R39 KTextEditor</div></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D11487">https://phabricator.kde.org/D11487</a></div></div><br /><div><strong>To: </strong>jtamate, Frameworks, Kate<br /><strong>Cc: </strong>anthonyfieroni, dhaumann, mwolff, cullmann, michaelh, kevinapavew, ngraham, demsking, sars<br /></div>