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 778926 - [gnome-terminal] Very poor scrolling performance on wayland with high DPI
[gnome-terminal] Very poor scrolling performance on wayland with high DPI
Status: RESOLVED OBSOLETE
Product: gtk+
Classification: Platform
Component: Backend: Wayland
3.22.x
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2017-02-19 22:49 UTC by François Guerraz
Modified: 2018-05-02 18:08 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
gnom-shell profiling (438.72 KB, text/plain)
2017-02-22 12:55 UTC, François Guerraz
Details
gnome-terminal-server profiling (1.29 MB, text/plain)
2017-02-22 12:56 UTC, François Guerraz
Details

Description François Guerraz 2017-02-19 22:49:12 UTC
On wayland, just running 

while true; do echo 1; sleep 0.1; done

is enough to have gnome-terminal & gnome-shell using 30%CPU *each*. This is not immediate and pre-filling the buffer helps reproducing the issue.
Comment 1 François Guerraz 2017-02-19 22:55:13 UTC
For comparison on X11, the combined CPU usage of gnome-shell, gnome-terminal and Xorg is negligible (<10% whilst keeping the CPU at the lowest frequency)
Comment 2 Christian Persch 2017-02-20 16:22:37 UTC
Is that with a gnome-terminal from upstream git/tarball, or from some distro with the transparency patch (e.g. fedora) ?
Comment 3 François Guerraz 2017-02-20 16:24:49 UTC
That's on arch, the PKGBUILD shows that there is no patch applied at all.
Just in case it's relevant, I have a HiDPI screen with UI scaling set to 2.
Comment 4 Christian Persch 2017-02-20 18:30:15 UTC
Since gnome-terminal & vte don't have any gdk backend specific code, it's highly unlikely to be due to something g-t/vte do. Most likely some problem in gtk+/gdk, and possibly a duplicate of bug 772075.
Comment 5 François Guerraz 2017-02-20 18:53:33 UTC
I'm sure you know but the patch for bug 772075 is included in the version I'm using. Also, even if the vte being refreshed is in a tab in the background, CPU usage is still as high even if there is nothing visible to refresh.
Comment 6 Christian Persch 2017-02-20 21:14:11 UTC
(In reply to François Guerraz from comment #5)
> I'm sure you know but the patch for bug 772075 is included in the version
> I'm using. 

How could I know one way or the other, since the gtk+ version used is not mentioned in this bug report.
Comment 7 François Guerraz 2017-02-20 21:30:34 UTC
Apologies, this comment came out wrong :-)

I'm using extra/gtk3 3.22.8-1 from arch, which AFAIK includes that patch.
Comment 8 François Guerraz 2017-02-22 12:55:43 UTC
Created attachment 346436 [details]
gnom-shell profiling

With gtk3 2.22.8 arch compiled with -fno-omit-frame-pointer
Comment 9 François Guerraz 2017-02-22 12:56:24 UTC
Created attachment 346437 [details]
gnome-terminal-server profiling

With gtk3 2.22.8 arch compiled with -fno-omit-frame-pointer
Comment 10 François Guerraz 2017-02-26 22:29:31 UTC
I found a workaround: unticking "Show scrollbar" in the g-t profile reduces the CPU usage to almost nothing (similar to the normal behaviour on X11)
Comment 11 Jan Alexander Steffens (heftig) 2017-03-01 09:42:07 UTC
I see this message from gnome-terminal-server in my log a few times:

Allocating size to GtkScrollbar 0x1670390 without calling gtk_widget_get_preferred_width/height(). How does the code know the size to allocate?

Maybe it's related.
Comment 12 Christian Persch 2017-04-01 20:44:22 UTC
I think what's happening is that with the scrollbar visible, each scroll adjustment change queues a full resize of the window, which in turn recalcs the window shadows which for some reason are (/were?) expensive to redraw on high DPI.
Comment 13 François Guerraz 2017-04-13 15:03:30 UTC
Not sure about that, disabling the scrollbars only helps, it doesn't fix the issue and the problem also occurs in full screen mode and there are no shadows in that case (or at lease, they should not be calculated).
Comment 14 François Guerraz 2017-07-23 08:10:24 UTC
FYI this is still unresolved and it's a shame that a scrolling terminal uses more power that watching an HD movie.

Can you confirm you can at least reproduce the problem? If not I can try to provide more information, find a more detailed test case, anything.
Comment 15 Egmont Koblinger 2018-02-02 13:36:54 UTC
Could you guys please check whether, by any chance, this recent VTE commit: https://git.gnome.org/browse/vte/commit/?id=809e79770 [bug 771899] causes any noticeable performance improvement?
Comment 16 jean-louis 2018-02-02 14:04:17 UTC
Just tested that commit (0.50.2-4ubuntu2 + that patch) on Ubuntu artful, and it seems to make ALOT of difference already.
Its way faster now. But not yet the speed we had on X.
Comment 17 Jan Alexander Steffens (heftig) 2018-02-02 14:10:22 UTC
Yes, there is now little difference in performance between with and without scrollbar.
Comment 18 Egmont Koblinger 2018-02-02 14:18:07 UTC
Great to hear this!

(In reply to jean-louis from comment #16)
> [...] But not yet the speed we had on X.

Could you please elaborate on this? How "usable" is this now, does it still lag the whole desktop (as you reported at https://bugs.launchpad.net/ubuntu/+source/gnome-terminal/+bug/1746949)? Or just simply a "bit" slower than on X?
Comment 19 François Guerraz 2018-02-02 14:35:49 UTC
I don't see any major improvement with this commit but it seems to me now that vte3 performance is comparable on X11 & Wayland, but unrelated to this commit.
Comment 20 Jan Alexander Steffens (heftig) 2018-02-02 14:38:56 UTC
Performance suffers a lot with scale 2 drawing (and large window sizes), so maybe what performance you remember from X was from before we had Hi-DPI.
Comment 21 Jan Alexander Steffens (heftig) 2018-02-02 14:40:53 UTC
GNOME Shell lagging is much more noticeable on Wayland as it's also responsible for input handling and updating the mouse cursor. On X this happens independently from the compositor.
Comment 22 François Guerraz 2018-02-02 14:43:29 UTC
When I reported the bug, I was comparing performance on the same machine with HiDPI in both cases.

Looking back on it, I do not think it's a very scientific comparison as "CPU usage" is a vary vague indication of actual performance on a laptop with CPU frequency scaling.

It may be that it was using more % on wayland, but actually fewer or same amount of CPU cycles.
Comment 23 Egmont Koblinger 2018-02-02 17:50:36 UTC
(In reply to François Guerraz from comment #22)

> Looking back on it, I do not think it's a very scientific comparison [...]

Anything along the lines of 30%+ CPU usage for scrolling every tenth of a second is obviously pretty bad, no need for more accurate CPU measurement here.
Comment 24 jean-louis 2018-02-05 09:36:34 UTC
(In reply to Egmont Koblinger from comment #18)
> Great to hear this!
> 
> (In reply to jean-louis from comment #16)
> > [...] But not yet the speed we had on X.
> 
> Could you please elaborate on this? How "usable" is this now, does it still
> lag the whole desktop (as you reported at
> https://bugs.launchpad.net/ubuntu/+source/gnome-terminal/+bug/1746949)? Or
> just simply a "bit" slower than on X?

Well if there is some terminal open with fast scrolling text (tail -f for example). It still gives some fps drop on the desktop.
But its like 10% anymore of what it was before the patch applied..

So way faster, not as fast as it was on X. But surely workable now!
Comment 25 François Guerraz 2018-03-25 15:49:13 UTC
Now that 3.28 is out, I've looked into it properly again, that is monitoring not only the CPU usage but also the cpu frequency and power usage.

On my system (Skylake, HiDPI screen, Gnome 3.28), on battery, running 

$ while true; do sleep 0.1; echo 1; done

On X, average cpu frequency is about 550MHz, terminal + X + gnome-shell cpu usage combined is 25%, average power usage is 7.49W

On Wayland , average cpu frequency is about 650MHz, terminal + gnome-shell cpu usage combined is 50%, average power usage is 10.17W

So we still have a measurably huge regression in cpu & power usage.
Comment 26 GNOME Infrastructure Team 2018-05-02 18:08:54 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/gtk/issues/763.