This patch was submitted to gnome-terminal folks sometime back and it hasn't made it into the main. Please include it in the next gnome-terminal ebuild. The bug is as follows: Code tries to match every text selection to a set of patterns. This matched pattern is not used if CTRL is not pressed. That means every click and drag of mouse leads to few regular expression searches for the text getting selected, although the selected text will never be used if CTRL is not pressed even if it matches one of those regular expressions, hence wasting CPU cycles for each click. This makes text selection consume lot of CPU and very slow. This patch moves the pattern matching inside of the check for CTRL mask so that we match only if CTRL is pressed, hence not hindering normal text selection. This patch makes a LOT of difference to g-t's performance. Reproducible: Always Steps to Reproduce: 1.Open up a gnome-terminal 2.make the window large. 3.open a document with large amount of text. 4. start randomly selecting and deselecting text 5. watch how cpu usage goes up and how slow the highlight appears on screen. Actual Results: text selection slow Expected Results: text selection shouldn't so slow.
Created attachment 32625 [details, diff] Don't match patterns when not needed
this patch is against 2.6.1
any news?
i think this patch would be better attended to upstream with the gnome-terminal developers. have you sent this patch to them?
yes...report number 122656 http://bugs.gnome.org/show_bug.cgi?id=122656 but it never made it.
any news on this patch?
it looks good to me.. although i've never seen the described behaviour. I'm not sure what this has todo with CTRL, i guess thats keyboard behaviour i'm not familiar with. Can you give a specific scenario to reproduce this ? Note that with this patch applied i did have a non-reproducable crash, it might be unrelated.
OK, the problem is that when you move your mouse around in a g-t, internally it searches for patterns(currently only URL spec, skey) matching the strings under the mouse using regex library. Just have a huge(not nece'ly full screen) g-t window with lots of text in it and just moving your mouse inside it will raise your CPU usage. You can hold CTRL down and left click on a URL and it will open up a epiphany/galeon/mozilla window or CTRL-right click will popup a special URL menu. The code keeps matching the URL even when CTRL is not held. This patch makes sure that pattern match happens only when CTRL is pressed, because that's the only codepath using the matched string. Selecting text will raise CPU usage more. Huge amounts of scrolling text will also produce the similar spike in CPU.
Added to gnome-terminal 2.6.1-r1.