After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 137864 - gnome-terminal soaks up tons of CPU time
gnome-terminal soaks up tons of CPU time
Status: RESOLVED FIXED
Product: vte
Classification: Core
Component: general
0.11.x
Other Linux
: Normal normal
: ---
Assigned To: VTE Maintainers
VTE Maintainers
: 122871 131461 143345 144085 (view as bug list)
Depends on: 143914
Blocks: 96879 131461
 
 
Reported: 2004-03-21 18:35 UTC by Duraid Madina
Modified: 2006-03-06 00:22 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
a profile of a minimized gnome-terminal scrolling lots of text (25.75 KB, text/plain)
2004-04-07 19:47 UTC, Duraid Madina
  Details
a profile of a visible gnome-terminal scrolling lots of text (17.77 KB, text/plain)
2004-04-07 20:06 UTC, Duraid Madina
  Details
a profile of a visible gnome-terminal scrolling text - simple GTK theme (7.86 KB, text/plain)
2004-05-03 14:12 UTC, Duraid Madina
  Details
profile of 1600x1200 gnome-terminal scrolling tons of text, simple GTK theme (7.22 KB, text/plain)
2004-05-03 14:20 UTC, Duraid Madina
  Details
walk the string ourselves instead of using memchr 6+ times (1.41 KB, patch)
2004-08-18 18:47 UTC, Benjamin Otte (Company)
none Details | Review
use a custom GTree in the xfs backend (6.66 KB, patch)
2004-08-18 19:04 UTC, Benjamin Otte (Company)
committed Details | Review
Don't use a GArray, use a calloc'ed mem (2.17 KB, patch)
2004-08-18 19:13 UTC, Benjamin Otte (Company)
committed Details | Review
Don't update the slider when the slider didn't change (7.50 KB, patch)
2004-08-18 21:46 UTC, Benjamin Otte (Company)
none Details | Review
second try with not updating the slider (11.44 KB, patch)
2004-08-20 22:00 UTC, Benjamin Otte (Company)
needs-work Details | Review
scrollbar patch updated to CVS (12.55 KB, patch)
2005-08-29 11:23 UTC, Kjartan Maraas
none Details | Review

Description Duraid Madina 2004-03-21 18:35:04 UTC
I just built mozilla in a gnome-terminal that I promptly minimized. When
the build finished, gnome-terminal had used more than 10 *minutes* of CPU
time. This was a substantial fraction of the total build time! (I was using
a fairly snappy Itanium 2 system)

Where is this time being spent? I can understand that managing a scrollback
buffer would take _some_ effort (indeed, gnome-terminal also reported a VM
size of 64MB, 36MB RSS), but is it time to replace a linked list with
something a bit more sane? Or at least to have a better think about log
management? Perhaps maintaining an approximate (as opposed to
line-accurate) size scrollback buffer could help things.

Other than scrollback, I've no idea what a minimized terminal could be
doing to soak up CPU time like that.
Comment 1 Mariano Suárez-Alvarez 2004-04-06 07:16:05 UTC
One thing to note here is that all terminals are sharing the same process...

That said, it is true that we need to work on speed. Help with profiling vte
would be very appreciated...
Comment 2 Duraid Madina 2004-04-07 19:47:04 UTC
Created attachment 26446 [details]
a profile of a minimized gnome-terminal scrolling lots of text
Comment 3 Duraid Madina 2004-04-07 19:50:52 UTC
Here's a profile for you!

To generate this profile, I just ran hexdump -C <large AVI movie file> inside a
gnome-terminal, which I immediately minimized (i.e. for 99.9% of the time, there
was no window at all, just an entry in the gnome panel). 

The highlights seem to be: 

_vte_table_match (10% of total time)
_vte_draw_set_scroll (5%)
_vte_buffer_length (3%)
gdk_pixbuf_scale (15%)
pixops_scale (7%)
g_array_append_vals (4%)
g_tree_search (8%)


    I'm just guessing here, but looking at some of these names, perhaps it's
time to get the hash table shotgun out 8)
Comment 4 Duraid Madina 2004-04-07 20:06:34 UTC
Created attachment 26447 [details]
a profile of a visible gnome-terminal scrolling lots of text
Comment 5 Duraid Madina 2004-04-07 20:12:20 UTC
OK, here's another profile: the same test (long hexdump (several minutes), ^C,
exit), but this time with the gnome-terminal visible (80x25, no huge fonts or
anything).

Interestingly, _vte_table_match remains at 10%, g_array_append_vals is still 4%
and g_tree_search is still 8% but there are some new heavy hitters:

_vte_draw_fill_rectangle (5%)
_vte_buffer_clear (3%)
gdk_pixbuf_new_from_data (22% !)

One thing I noticed upon starting the hexdump is that for a few thousand lines
it seemed to run very quickly, but after that it slowed down to something like a
90% duty cycle, i.e. 10% of the time the terminal would just sit there, not
scrolling. About once a second or so, these 0.1s pauses would show up, but only
after a few thousand lines had scrolled past smoothly. I'm guessing this is the
terminal log buffer filling up, and gnome-terminal deciding to do some house
cleaning every once in a while...
Comment 6 Gabor Farkas 2004-05-02 19:51:54 UTC
could someone tell me how to profile gnome-terminal?

i got gnome-term and vte from gnome.org

compiled them with -pg, but still.. in the profiler output every
function is listed with 0% :(((
Comment 7 Duraid Madina 2004-05-02 21:05:20 UTC
Try qprof from HP: http://www.hpl.hp.com/research/linux/qprof/

It's designed for Itanium systems but I think you can get the basic
functionality on other platforms too.
Comment 8 Duraid Madina 2004-05-02 22:53:06 UTC
OK, I just performed a quick benchmark between gnome-terminal and rxvt-unicode
with the same font (10 point lucida console, antialiased (not subpixel
rendered)), running hexdump -C <1.7 megabyte file> in an 80x25 window.

rxvt-unicode:   17.90 seconds (baseline)
gnome-terminal: 71.11 seconds (4 times slower)


For the same test, but with a maximized (1600x1200 display) terminal window:

rxvt-unicode:    18.47 seconds (3.2% slower)
gnome-terminal: 288.06 seconds (**16 TIMES** slower (!))

Note: The same amount of text is being rendered in each case, and it's being
rendered the same way. The same amount of scrollback is being used in each case.
These terminals are basically doing the same thing. About the only visible
difference is that the gnome-terminal scrollbar has a "jellybean" widget whereas
rxvt has a simpler 2D scrollbar. (We're not completely redrawing the scrollbar
once per line scroll, are we?)

Another test: running the same hexdump test, but in a minimized (completely
invisible) terminal window:

rxvt-unicode:    2.891 seconds
gnome-terminal: 29.212 seconds

And now, for the "what the hell is going on here" factor: the previous two
figures were for terminal windows that were 80x25 characters in size before
being minimized (simply did a sleep 10; hexdump ... )

Maximizing the terminals (1600x1200 pixels) before minimizing them, the
rxvt-unicode time is unchanged but the gnome-terminal time is:

228.69 seconds. Not a bad effort for what should be effectively copying 10 or
20MB of data into a buffer.

Changing severity from "enhancement" to "normal" because while this is a
performance issue, something is going seriously wrong here.
 
Comment 9 Duraid Madina 2004-05-02 23:12:52 UTC
Moving this to vte: mariano assures me that the problem is there.

Upgrading to major: the first person to fix this (fix = performance is within a
factor of 2 of rxvt-unicode for all four of the tests here) gets $50 from me, or
an expensive dinner + all the beer they can handle if they ever visit Sydney,
Australia ;)
Comment 10 Pekka Pietikäinen 2004-05-03 07:39:17 UTC
https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=83472 might also have some
relevant information...
Comment 11 Duraid Madina 2004-05-03 13:57:29 UTC
Moving from the "grand canyon" theme to the "simple" one:

gnome-terminal: 71.11 seconds (4 times slower)

becomes 47.35 seconds

and when minimized,

gnome-terminal: 29.212 seconds

becomes 15.997 seconds

still terribly slow, but it's a start. _why_ are we even redrawing the scrollbar
when it is exactly the same 99.99% of the time?

(and once again, what the heck does the theme have to do with an invisible window?)

Comment 12 Duraid Madina 2004-05-03 14:05:20 UTC
interestingly, for the maximized window, the test ran slightly slower (about 2%)
with the simple GTK theme. within experimental error, I guess.
Comment 13 Duraid Madina 2004-05-03 14:11:17 UTC
OK, attaching a profile for a basic, visible (80x25 chars) terminal scrolling
hexdump -C <1.7MB bloat>, with a simple GTK theme.
Comment 14 Duraid Madina 2004-05-03 14:12:11 UTC
Created attachment 27332 [details]
a profile of a visible gnome-terminal scrolling text - simple GTK theme
Comment 15 Duraid Madina 2004-05-03 14:20:20 UTC
Created attachment 27334 [details]
profile of 1600x1200 gnome-terminal scrolling tons of text, simple GTK theme

and here's the same test as the previous profile, but this time the window is
1600x1200 pixels in size
Comment 16 Duraid Madina 2004-05-06 22:24:04 UTC
Nalin, sorry to drop this one on you without warning: I shouldn't have left this
sitting as a gnome-terminal bug for so long.
Comment 17 Mariano Suárez-Alvarez 2004-05-07 11:17:42 UTC
*** Bug 131461 has been marked as a duplicate of this bug. ***
Comment 18 Mariano Suárez-Alvarez 2004-05-07 11:20:19 UTC
Bug 131461, which I just marked as a dup, has some timings for the usual things
(ls -lR, print a few thousand lines of something, etc) of varying significance...
Comment 19 Gabor Farkas 2004-05-21 09:34:46 UTC
hmm... could the reporter add some info about his hardware?

what graphics card?
what driver for his graphics card ( a binary driver from the card-manufacturer?
or the driver from xfree?)
what version of xfree?
Comment 20 Duraid Madina 2004-05-21 09:46:12 UTC
Sure, no problem.

Graphics card: NVidia Quadro4 980 XGL
Driver: NVidia 53.36 and 53.47 binary drivers
XFree: tested both 4.3.0.1 (Debian 4.3.0.dfsg.1-1 20040428210751) and 4.4.0-ish
CVS (built by hand)

I would be very, very surprised if the hardware or video driver have anything to
do with this: remember, rxvt and other GTK+ programs (such as gvim) all scroll
text far, far more rapidly than gnome-terminal.
Comment 21 Gabor Farkas 2004-05-21 10:10:42 UTC
please read bug 131461 ..my comments to be exact...

so..could you try to switch to the xfree nvidia driver... (replace "nvidia" with
"nv" in XF86Config)
Comment 22 Duraid Madina 2004-05-21 12:04:58 UTC
OK, I just tried the xfree nv driver. Exactly the same behaviour, except that
characters come up more slowly so instead of using closer to 2 CPUs worth of
time (I have a 2-way SMP box), it's somewhat closer to 1.0 (XFree86 hits 100% as
before, but with the xfree driver hexdump/gnome-terminal don't use as much time
as they're waiting for a much slower xfree display...)

This bug really doesn't have much to do with XFree itself: there is no good
reason that XFree86 should be doing _anything_ significant while stuff is
happening inside a _completely invisible_ gnome-terminal window. Needless to
say, the minimized gnome-terminal continues to soak up massive amounts of CPU
time while a multi-megabyte hexdump inside rxvt runs about 20 times faster.
Comment 23 Mariano Suárez-Alvarez 2004-06-02 11:29:09 UTC
*** Bug 143345 has been marked as a duplicate of this bug. ***
Comment 24 Mariano Suárez-Alvarez 2004-07-01 18:55:22 UTC
*** Bug 144085 has been marked as a duplicate of this bug. ***
Comment 25 Duraid Madina 2004-07-01 20:44:45 UTC
Tagging this critical+urgent. How dare I, you ask? Doubling the reward - $100 if
this is fixed (see above) before September 1, 2004. $0 after that (and I'll
return it to a normal bug ;) If anyone else wants to contribute to whoever ends
up fixing this, please join in..
Comment 26 Gabor Farkas 2004-07-01 21:30:11 UTC
btw. maybe u will hate me for this.....

but imho many people who have problems with gnome-term will find this bug, and i
don't want them to switch to kde (btw. which has a PERFECT console app),

here's a small list about what can u use until this gets fixed:
mlterm: does utf8 + transparency + especially optimised for asian fonts/input
(every transparent mlterm uses a copy of the wallpaper. they don't share that
between their instances like gnome-term does)

rxvt-unicde (i use this one): does utf8 + transparency (no sharing of the
wallpaper between instances). no menu... for the beginning try this command-line:

urxvt -ip -fg white -bg black -fn "xft:Bitstream Vera Sans Mono" -tint
-rgb:30/30/30 -sr -sl 1024 -colorBD white
Comment 27 Cristian Adam 2004-07-02 11:08:14 UTC
Me and friend of mine are sick and tired of this bug (it's haunting us from
gnome 2.0) so we are decided to do something about it! Until 1 Sep 2004 the bug
will be gone! :)
Comment 28 Duraid Madina 2004-07-02 13:23:00 UTC
Great, good luck! If you send patches here, I'll do my best to try and update
the profile information.
Comment 29 Marc Lehmann 2004-08-14 18:12:53 UTC
Hi, I am the author of rxvt-unicode, and have some comments.

First of all @Gabor Farkas: of course rxvt-unicode has a menu. There is no
excuse for people sprreading FUD that could easily be clarified by reading rthe
manual page *g*.

Xft fonts are slow, but that is not the problem of gnome-terminal, as xterm
(Also slow) and rxvt-unicode (much slower than non-xft) are much afster. So much
is already clear from reading this bug-report.

gnome-terminal uses pango, and I hear that this is required for correct i18n. I
just installed gnome-terminal 2.6.1-4 (debian), and found that, while
gnome-terminal uses pango, the font drawing is much worse than rxvt-unicode:
arabic is broken, characters run into each other.

Pango is *extremely* slow (orders of magnitude slower than using x core fonts or
even directly using xft fonts), but what you get from using pango is correct
rendeing of realyl complex scripts (arabic for example). In gnome-terminal, it
seems as if pango slows down gnome-terminal with no additional benefit.

Redrawing the scrollbar should not be a bottleneck in gnome-temrinal, as rxvt
redraws the scrollbar completely, unptimised, on every scroll.

Also, using blitting on scrolls and waiting for expose events (as suggested) is
slowing down redrawing immensely, and is only of help on slow links (blitz ==
less data over the link).

In almost all cases it is much faster to just re-draw the screen on changes.
Don'T create expose events by using any kind of optimized scroll, that might be
a bit better for cpu time, but slows down redrawing because it needs
server-turnarounds.

For example, strace rxvt and gnome-terminal: when scorlling, rxvt does not read
from the server, it just sends data to the server: no server timearound. (the
effect can bets be seen if you emnable blinking and use blinking tetx. usually
rxvt-unicode's strace will look like
select/timeout/gettimeofday/write/write/select/timeout etc.

Also, double-buffering is very slow. Try turning of double-buffering in the
display widget. If it now flickers, you have a problem. xterm flickers a lot on
redraws, rxvt less and rxvt-unicode almost none as it draws the background while
redraing characters (useing XDrawImageString if possible, or clearing just
before drawing in other cases).

I just improved rxvt-unicode's scrolling speed a lot, and I am seeing similar
problems to xterm and gnome-terminal which I tried to solve. First of all, a
major point of slowdown (ignoring actual drawing of the characters) is not doing
jump-scrolling. I am not sure wether gnome-terminal does jump-scroling, it
doesn't look that way to me.

Some terminals (eterm for example) cheat a lot by only showing 1/5th of the
text, i.e. only drawing every firth full-screen when scorling hard. rxvt-unicode
also dowsa this, but only for every second screen. You can edit command.h
REFRESH_PERIODS to adjuts this value for tests. I think xterm cheats even more,
but I think it's important to show almost all the text, so I don't think
omitting output excessively is a good idea.

A common problem (as testified in other gnome-terminal bug-reports) is scheduler
interaction. The original rxvt dfoes not realyl suffer from this, as it uses a
tight inenr loop, while rxvt-unicode and gnome-temrinal use an event system,
which makes these things mroe difficult (Difefrent priorities for different file
handles for example).

Terminal output is often line-by-line: redrawing after eahc tty-read is
therefore going to be dog-slow. Newer linux kernels can buffer up to 4095 (sic!)
characters, but that's not universal, and might help terminals.

rxvt-unicode has two modes of scrolling: normal mode, where refreshes are
delayed by 0.01 seconds (i.e. it will only update the screen 0.01s aftere the
last change, wqhich is always early enough), and hard-scrolling, which is
triggered automatically when there is more output than fits on one screen.

The latter ensures that redraws are done more often when lots of tetx scrolls
by. Also, only showing every second screen is only done when the amount of data
overwhelms rxvt, on normal output (typicall ls output) it will still show every
screen.

In any case, redrawing immediately after receiving data is a no-no.

Also, resources: urxvtd with 10 open terminals (no scrolling done yet) uses 6MB
of memory (2MB rss), while a single gnome-terminal already uses 40MB memory
(15MB RSS). cpu caching is a major concern in modern machins, and it's possible
that the sheer amountof code run in gnome-terminal causes a lot of cache-misses
that smaller terminals don't have. This does not apply to konsole as much, which
is also big (but way smaller than gnome-terminal still :)

Last not leats: the scrollback buffer. I use large scrollback buffer s(many
thousands of lines). original rxvt uses a for-loop to shuffle the line pointers
around in memory. replacing that by a memmove gave me (GNU/Linux-x86) a 5%
increase in scrolling speed. I wil be able to reduce this further.

Other data structures (lists etc.) are bound to be slower, though, due to
cache-effects and the sheer slowness of acecssing them.

Please note that rxvt-unicode also uses jump-scrolling _internally_, i.e. it can
add a screenful of lines without doing any scorlling internally). As copying
characters from the tty to internal buffers is using a non-trivial amount of
time (using mbtowc is already a major-time-burner!) this saves a LOT of time.

... I think I forgot a few minor points, but the above might be helpful for
anybody trying to improve gnome-terminal... I must honestly admit that
gnome-terminal really *is* slow, even for it's features... :)
Comment 30 Marc Lehmann 2004-08-14 20:12:44 UTC
Sorry fot the additional comment, and sorry for the many typoes (a textarea is
not a nice place to edit large amounts of text :).

I just did some experiments with konsole, which seems to ahve become very much
faster (it's almost as fats as rxvt-unicode, sometiems even fatser). However, I
noticed that it only redraws the screen about 7 times per second (see the
section about terminals cheating in my last comment). When this is switched off,
konsole isn't that much faster anymore than gnome-terminal.

I am thinking about making this a prefernces option in rxvt-unicode: some people
don't really want all tetx on screen screen, others (like me) want that,a s
analysing afst output streams (e.g. tcpdump) is still possible even when youc
an'T read the text scrolling by (the human visual system is amazing :).

Aggressively mitigating and delaying scrolls by 0.1s or more might be a major
speed increase, at least profilign data suddenly becomes more valid. If this is
a prefernces item than most of the problems (related to redraw time, there might
be others) are gone, at the same cost as konsole, and I don't see many peopel
complaining.
Comment 31 Benjamin Otte (Company) 2004-08-18 18:47:35 UTC
Created attachment 30710 [details] [review]
walk the string ourselves instead of using memchr 6+ times

First optimization:
There's a function that tries to find the first control character in a string.
The current code walks that string using memchr for every control character
resulting in 6+ iterations over the string.
This patch optimizes it and walks the string only once.
Comment 32 Elijah Newren 2004-08-18 18:59:01 UTC
Benjamin: Note that your patch is already included as part of the patch in bug
143914 (submitted a couple months ago).  Also note that there are various
patches in bug 122656 (some up to a year old, although some may be solaris
specific).  You may want to read those patches before continuing.
Comment 33 Benjamin Otte (Company) 2004-08-18 19:04:14 UTC
Created attachment 30714 [details] [review]
use a custom GTree in the xfs backend

This is a minor optimization that creates a custom GTree type that optimizes
ASCII character lookups by having the first n values cached in an array instead
of adding them to the tree.
Comment 34 Benjamin Otte (Company) 2004-08-18 19:13:46 UTC
Created attachment 30715 [details] [review]
Don't use a GArray, use a calloc'ed mem

vte_terminal_draw_row allocates a GArray every time it is called to assemble
the drawing requests. This causes a lot of (re)allocations. This patch changes
it to use alloca with the maximum number of requests (column width, or can
there be more?) instead.
Comment 35 Benjamin Otte (Company) 2004-08-18 21:46:15 UTC
Created attachment 30723 [details] [review]
Don't update the slider when the slider didn't change

This patch is a bit intrusive and might have side effects I didn't find yet.
But it improves speed a lot.

VTE has a GtkAdjustment that's used by the slider in gnome-terminal. Currently
the adjustment's values are absolute, that means the maximum value is the
number of lines ever added inside the terminal. So when you add a new line to
the terminal (by pressing return for example), the last line from the history
gets deleted, but  the asjustment gets updated: Upper bound, lower bound and
current value all get incremented by one. This causes gnome-terminal to update
the slider.

This patch makes the adjustment always number the oldest line in the history -
and therefore the lower bound of the adjustment - as 0. The upper bound is
therefore only limited by the visible area and the number of scrollback lines
and doesn't get changed when lines get inserted.

This results in the slider not being updated. 

hexdumping or cat'ing a big file is up to 50% faster with this patch.
Comment 36 Benjamin Otte (Company) 2004-08-18 21:53:09 UTC
Elijah: yeah, someone should apply those patches at some point or assemble all
performance improvements in one bug report it seems :)

The last 3 patches are new though. And the first one was obvious anyway. ;)

FWIW, with all these patches applied cat'ing a ~1MB file in a fullscreen
terminal (150x40 I think) now takes 14 instead of 43 seconds, in a 80x25
terminal it takes 7 instead of 23 seconds.
Comment 37 Benjamin Otte (Company) 2004-08-20 22:00:47 UTC
Created attachment 30798 [details] [review]
second try with not updating the slider

The last patch was quite a bit broken, this one is supposed to be better.
Comment 38 Duraid Madina 2004-08-20 22:30:46 UTC
Thanks for that - I had tried your previous patch set, but the scrolling was
indeed very broken. I'll try again soon (sometime today), and get back with
performance figures.
Comment 39 Duraid Madina 2004-08-21 14:01:12 UTC
Benjamin, bad news :(  Here are my timings:

baseline (gnome-terminal 2.7.3, vte 0.11.11): 65 (+/-5) seconds (some fixed
hexdump output)

applying only the slider patch: 80 seconds

applying all the patches except the custom GTree: 74 seconds

applying all the patches: 77 seconds

So I wonder, what is your system like? Which theme are you using? What does
'x11perf -aaftext' report for your system? (I get 1,230,000 chars/sec, or in
other words, just drawing the glyphs for this test should take around 7.5 seconds)
Comment 40 Elijah Newren 2004-08-21 20:14:44 UTC
Duraid: Could you post what timings you obtain with the patches in bug 143914
and maybe also bug 122656?
Comment 41 Duraid Madina 2004-08-21 21:45:59 UTC
OK, I just tested the patch in bug 143914. This patch seems to be a win. In an
attempt to get something like a fair comparison, I altered VTE_COALESCE_TIMEOUT
and VTE_DISPLAY_TIMEOUT to both be 2.

The benchmark then completed in 51.8 seconds, not 65 as before. Nevertheless, it
did still seem as if less text was being rendered but that could just be my
memory playing tricks on me. It's also worth bearing in mind that the "optimal"
time for this test (i.e. if gnome-terminal and vte both use zero CPU time) is
still around 10 seconds, not zero. So the improvement is significant: a 25%
boost or so.

However, the real win comes when setting VTE_COALESCE_TIMEOUT and
VTE_DISPLAY_TIMEOUT to larger values. e.g. using values of 3 and 5 respectively,
the benchmark finishes in 23 seconds, but appears to be scrolling at the same
rate as with 2/2. Nevertheless, there are still usability issues, even with
these small values. If I maximize gnome-terminal and 'ls -la' my messy home
directory (around 1000 files+), it finishes quickly enough but the variance in
what I see between runs is huge, and if it wasn't for the fact that I already
know what's in there, I wouldn't be able to tell much. The text moves slowly
enough that it's easily readable and I think a user will get the illusion that
he has seen enough, when he actually hasn't - the majority of the text is simply
never drawn. With rxvt-unicode on the other hand, the text scrolls SO fast that
at least the user makes the correct judgement: he didn't catch the output, and
must use a pager or something.

For the record, with Soren's patch as-is, the benchmark finishes in under 20
seconds but the amount of text output is pitifully small. This, as far as I'm
aware, is changing gnome-terminal in the same way KDE's terminal has changed
recently (boost speed by massively reducing the amount of text output) and I
really feel that's the wrong direction to be going in.
Comment 42 Benjamin Otte (Company) 2004-08-22 12:03:15 UTC
I might have been using a slightly more demanding theme and since the slider is
repainted immediately after changes, it might have been more visible for me.
(I'm using the aquativo theme.)

I'll just attach all my changes I've currently done in a big cumulative patch
when I'm back on my machine.

We should also try to use roughly the same benchmark, so we know what we are
talking about. I'm using time gnome-terminal --disable-factory -x <command>
where command is one of {cat|hexdump} {configure|src/vte.c} for the default test
or I run time <command> in a maximized window (40x150).
Comment 43 devsk 2004-08-23 18:52:30 UTC
here are some times that I came up with: My X server is on a machine on the LAN
but terminals are run on my local machine. All terminals use same AA font, same
size window(80x40), and transparency where available(urxvt, g-t). This is on
solaris.

this was run repeatedly in all terminals to avoid I/O caching unfairness to the
first runner.

time /bin/ls -R /usr/share

urxvt: 36 secs
xterm: 15 secs
g-t: 6 secs

network usage:
urxvt: < 1M
xterm: 5-6M
g-t: 4-5M

urxvt slows down a lot because it talks to X server in smaller chunk sizes as is
evident from the network usage shown by gkrellm. Even locally on my gentoo box,
my results show it to be slower(please don't flame me, because I am the only one
saying this) than g-t and xterm....g-t has patches applied only from bug 122656.
vte has URL highlight turned off as described in 122656. The URL highlight was
the biggest slow down and removing which made it faster than everything else.
Comment 44 Marc Lehmann 2004-08-23 20:57:41 UTC
It might be worthwhile to comment out #define NO_SLOW_LINK_SUPPORT in
src/features.h of urxvt to get a more comparable benchmark for this case, as by
default urxvt will try to save bandwidth by using xcopyarea when run without a
local display (the effetc of which cna be seen by the amount of data transferred).

XCopyArea can slow down scorlling a lot, due to the high number of event
turnarounds that this generates, but it is rather effective when using a
terminal emulator over  aslow line.

If you wanted to do the urxvt author a favour you could also try without
transparency and with the most current version (3.7+), as urxvt's wekanesses
include transparency,a nd it would be nice to find out why urxvt suddenly became
so slow compared to xterm :)

It is very interetsing that xterm is slower than g-t. So I expect that g-t will
also be faster than urxvt even without the bandwidth optimizaton.

Is this with gnome-terminal not refreshing every screen or does it still show
every screenful?
Comment 45 devsk 2004-08-24 01:26:58 UTC
g-t refreshes every screen...I have urxvt 3.6 and turning off transparency did
not make much difference(avg. about 35secs). for urxvt, I think its very
conservative about the amount of data it sends to X server in one request and I
think if I change NO_SLOW_LINK_SUPPORT, I might get better results. I will post
later with that.

turning off URL highlight and g-t patch in 122656 made a HUGE difference in g-t
performance, without those and even with patch in bug 143914, I had near 100%
cpu usage when I moved mouse and 2-3 seconds delay when selecting text in a g-t
with lot of text. On solaris the slowdown is very prominent because of slower
regex impl.
Comment 46 devsk 2004-08-24 17:38:00 UTC
urxvt +ip with NO_SLOW_LINK_SUPPORT defined: time /bin/ls -R /usr/share -> 38 secs

urxvt +ip -fn 7x13 -> 1.362 secs. its all about AA fonts, isn't it? g-t leads
the pack so far with AA.
Comment 47 Marc Lehmann 2004-08-26 03:42:30 UTC
I have never measured a slowdown of more than 3 times for aa-fonts (and
cetrainly never heard of urxvt beign slower on aa-fonts than other terminals :).
something clearly goes wrong in urxvt that, unfortunately, would require quite
some digging on your setup.

Thanks for doing the additional benchmark, the result is very interesting, It
serves to show that being fast on soem amchines does not mean being fast on all
of them (and/or that rxvt-unicode must have a big bug somewhere :)
Comment 48 Olav Vitters 2004-08-29 12:22:33 UTC
" Reassign bug to owner of selected component "
Comment 49 Duraid Madina 2004-09-12 20:56:37 UTC
Well, it looks like this bug is still with us, despite everyone's best efforts.
In particular I appreciate the patches here (and in bug 143914) but none of
these solve what I see as the basic problem: when text should not be scrolling,
e.g. if you are examining the scrollback buffer, or if the window is
invisible/minimized, gnome-terminal still soaks up tons of CPU time and unless
you have an extremely fast X server for your hardware, even _more_ X time.

With all that in mind, and given that gnome-terminal/vte are (IMO) far too
complex for what they actually do, I ask the following:

- Can anyone come up with a short list (5 or 10 points or so) of the things that
gnome-terminal does, which rxvt-unicode *doesn't do*? Personally, there is only
one feature of G-T I miss when using rxvt-unicode: I can't hit ctrl+shift+N to
pop up a new terminal in the current working directory.

- What would people think about dropping the current gnome-terminal code
completely, importing rxvt-unicode, and rewriting whatever functionality is
missing (i.e. the menubar+configuration, things like ctrl+shift+N etc), to have
a complete looks-alike, works-alike (but 20x faster!) replacement for
gnome-terminal. Is this crazy?

I just don't see how either gnome-terminal or vte are going to get significantly
faster without being rewritten. And since we have an almost-perfect, open-source
terminal program already (i.e. rxvt-unicode), why not adopt it? It is too good
to be ignored, I think.
Comment 50 Gabor Farkas 2004-09-12 21:11:27 UTC
there's also mlterm. opensource, transparency capable, and unicode-enough ;)

well...there is one thing that gnome-term can do and rxvt-unicode cannot:
gtk2 input modules.

if you only write in latin-based languages, this is not an issue.
but when you try to write in japanese or chinese for example you need much more
complicated input method support.
and that's where the gtk2 system uses the input modules.

rxvt-unicode only uses XIM which is far less usable than gtk2 input modules.

mlterm at least can use UIM natively, which is better than XIM, but still not
the gtk2 level.

imho this would be a stopper for rxvt-unicode or for mlterm.
because imho it's quite understandable that the gnome devels want the gnome
terminal app to be able to use the gtk2 input modules.
Comment 51 Duraid Madina 2004-09-12 21:16:13 UTC
OK, what the heck, I use terminals (almost) every waking moment of my life....

So the previous $100 competition is over - sorry, no winners. My hope, roughly
speaking, was that someone would make gnome-terminal less stupid, not make it
act stupid more quickly. Having said that, the patches are appreciated (I do use
them, and they help) - Benjamin and Soren, I'll email you now with how you can
collect your $20 consolation prizes. ;)

Well, time for a new bounty? $100 to the first person who, before December 25
2004 (yes, it's my christmas present to myself this year...), implements
whatever extra functionality rxvt-unicode needs such that I can't distinguish it
from gnome-terminal except via performance. CHEAT: all this means is that you
have to get rxvt-unicode to do the following: 1) ctrl+shift+N pops up a new
terminal window in the current working directory, ctrl+shift+T does the same
thing but in a tab, 2) the current command appears in the title bar, 3) a menu
where the font and size can be selected using the GNOME font selector and where
the colours may be chosen using the GTK colour dialog.

A bonus $25 if your new terminal is adopted into mainline GNOME. (I guess that
means it'll need gtk2 input-method support. An extra $25 on top of that if it
leads to the old gnome-terminal being thrown out! Yes, that's a potential $150
up for grabs! Surely that covers the day or two it would take to implement. :)

Someone, anyone, please make my christmas a happy one this year. :)
Comment 52 Kjartan Maraas 2004-10-18 10:15:23 UTC
So, this really needs to be gone through and patches applied. No use in having a
bunch of improvements in here if they don't get commited and released...
Comment 53 Duraid Madina 2004-10-18 11:24:45 UTC
Absolutely. This might not be the last word on gnome-terminal, but there are
some real improvements here and they should go in. FWIW, I've been using some of
the patches (mentioned) herein for the last few weeks and they've made a
definite improvement.
Comment 54 Benjamin Otte (Company) 2004-10-18 14:08:42 UTC
The biggest problem IMO is that vte needs a backend/frontend separation.
There are lots of redraws triggered (sometimes instantly, like the scrollbar) by
random side effects and it's very hard to figure out from looking at code if
something schedules a redraw. Another bad side effect is that it sometimes
doesn't redraw even though it should (like when entering text while the CPU
utilization is peaked).

At least those were my impressions from working with the code.
Comment 55 Duraid Madina 2004-12-18 10:32:38 UTC
"ping!"

Does anyone (Kjartan?) know if any of the patches here are going to be applied
to mainline in the near future? Or indeed, if anyone has any news at all on
things related to vte/gnome-term performance...
Comment 56 Elijah Newren 2004-12-18 18:01:28 UTC
Duraid: VTE is totally and completely unmaintained.  The previous (it's hard to
say "current") maintainer has not reviewed any patches submitted in the last 6
months (there's been about 25 of them); many patches are well over a year old
and haven't been reviewed.  It's not that he doesn't care; it's just that he has
a lot of other responsibilities and those have taken all his time away.  We
really need to get a new maintainer.  Sven expressed interest on d-d-l; maybe we
should try to kick him and Nalin into action in transferring maintainership...
Comment 57 Kjartan Maraas 2005-02-28 22:05:00 UTC
Comment on attachment 30710 [details] [review]
walk the string ourselves instead of using memchr 6+ times

This patch does not apply any longer because of other patches having been
commited. Could you check if this is still relevant and update the patch
accordingly if it is still needed?
Comment 58 Kjartan Maraas 2005-02-28 22:05:40 UTC
Comment on attachment 30798 [details] [review]
second try with not updating the slider

This patch does not apply any longer because of other patches having been
commited. Could you check if this is still relevant and update the patch
accordingly if it is still needed?
Comment 59 Kjartan Maraas 2005-02-28 22:13:31 UTC
I've made a test tarball with the two patches that still apply cleanly and put
it at http://www.gnome.org/~kmaraas/testing/vte-0.11.12.tar.gz
Comment 60 Kjartan Maraas 2005-03-02 10:04:27 UTC
Comment on attachment 30714 [details] [review]
use a custom GTree in the xfs backend

I commited this.
Comment 61 Kjartan Maraas 2005-03-02 10:05:01 UTC
Comment on attachment 30715 [details] [review]
Don't use a GArray, use a calloc'ed mem

This was commited too.
Comment 62 Kjartan Maraas 2005-08-29 10:30:02 UTC
Comment on attachment 30710 [details] [review]
walk the string ourselves instead of using memchr 6+ times

Looks like a slightly different variant was commited.
Comment 63 Kjartan Maraas 2005-08-29 11:23:12 UTC
Created attachment 51509 [details] [review]
scrollbar patch updated to CVS

I updated the slider related patch to CVS (hopefully I didn't break it in the
process) and that actually gave me worse results on hexdump -C somefile.png
than what I have with current CVS...
Comment 64 Kjartan Maraas 2005-08-29 11:26:56 UTC
Reducing priority and severity now that most of these have gone into CVS.
Comment 65 Kjartan Maraas 2005-08-29 12:06:04 UTC
*** Bug 122871 has been marked as a duplicate of this bug. ***
Comment 66 Christian Rudh 2005-09-04 14:59:10 UTC
I've found a "funny behaviour" that is somewhat related to this.

For testing purposes I ssh:d to another box and ran a program (emerge unmerge
<kernel>) that gives massive output in the terminal so all CPU used on my
desktop should be the drawing in gnome-terminal.

This gives about 95% CPU usage on my desktop. So I thought I would minimize it
so that the output isn't shown. But that didn't do any differance, still about
95% CPU usage. Then I un-minimized it again so I would see the output, and then
I moved another window over gnome-terminal. This lead to CPU usage below 5%!

So why is CPU usage 95% when gnome-terminal is minimized but 5% when it is
covered by another window?
Comment 67 Christian Rudh 2005-09-04 15:17:32 UTC
I should mention that this was on gnome-terminal 2.10.0.
Comment 68 Behdad Esfahbod 2006-02-14 07:00:37 UTC
Kjartan, do we need this scrollbar patch still?
Comment 69 Benjamin Berg 2006-03-06 00:18:05 UTC
Behdad, no need for it. GTK does not redraw the scrollbar anymore if it is not necessary. (see bug 313991)
Comment 70 Behdad Esfahbod 2006-03-06 00:22:09 UTC
Nice. Thanks.