chjj / compton

A compositor for X11.
Other
2.25k stars 500 forks source link

Usage of compton significantly lowers RC6(p, pp) time and increases power usage #150

Open pschyska opened 11 years ago

pschyska commented 11 years ago

Hey,

first of all, thanks for compton. It was the only solution to me tearing problems so far :smile:

I'm using arch linux on a Lenovo X230 with ivybridge integrated intel graphics chip. I don't use a DE but i3wm on plain Xorg. This setup gives me heavy tearing, i.e. when scrolling vim buffers. TearFree with sna acceleration OTOH leads to laggy display/skipped frames.

Compton with glx backend and vsync opengl-swc works like a charm. I don't have tearing and the display is smooth.

However I noticed in powertop an increase of power drain of about 1-2W (going up to 11W from 9W in my test). The intel chip's power saving time is about 20% (RC6/RC6p/RC6pp depending on my module setting - the percentage stays the same for all settings). With XRender backend or no compton I get about 80-90% RC6 with heavy tearing though.

Is there some setting I could try to save some power?

I wondered if the chip is set to "3D-mode" when using the glx backend and that's why I can't sleep properly. BTW, this test is with a terminator instance in fullscreen and powertop open. Powertop itself will only refresh display every 10s or so, but I use a blinking cursor. Also the i3bar refreshes every 5s.

If this is not something that can be fixed in compton, just close this issue. I will use it regardless :+1:

Thanks Paul

richardgv commented 11 years ago

Update: Does compton --vsync opengl under XRender backend works?

Well, it probably is something that could be fixed in compton, but none of us are professionals in the field of core X and OpenGL implementation and hardware, that makes the problem tricky to fix. I myself almost always use a desktop computer and has never cared about power usage.

You are not first one who noticed the issue. p4ddy, which used to stay on our IRC channel (FreeNode/#compton), reported the same thing once, but he indicated that upgrading the kernel and driver helped a lot. Not applicable for an Arch user with bleeding-edge packages, though.

Usually, compton paints a lot, more than all your applications combined (except when you have a 3D game), because it paints everything your application paints for another time and occasionally other areas (e.g. wallpaper, shadow), as well. And a compositor processes typically much more events than an application. Thus you may consider a compositor inherently expensive. The X architecture, formed in 1980s, contributes a lot of the overhead, though, and Wayland/Mir may be direction of the future.

I did a number of tests with powertop on compton, xcompmgr, and cairo-compmgr, and found compton generally causes a significant higher amount of GFX wakeups (200% - 300%), but less "usage", especially GLX backend. It might has something to do with our attempts to minimize painting which involves synchronous communication with X that fragmented compton's usage on resources, and porting to XCB may be helpful. (But we can't. People are using compton on very old systems where XCB probably doesn't exist yet.) I lost patience when I found high statistical variance on the results I got, somehow.

I believe 2D and 3D are basically equivalently handled on modern graphic systems, so the 3D mode thing is most likely non-existent.

Some advices, although I truly doubt if they would help much: compton has some options that may have either positive or negative effects on the wakeups: --glx-no-stencil, --glx-swap-method, --glx-no-rebind-pixmap, --paint-on-overlay, --vsync (try other VSync methods). --glx-use-copysubbuffermesa may break VSync, and --glx-copy-from-front generally performs poorly on open-source drivers. Lift some options you don't need (e.g. shadow, background blur), if you think it's going to help. Tuning your driver options and playing with its VSync may give you something interesting.

If (and only if) you have a lot of spare time, comparing the results of using different options of compton, and other compositors, tracing which part of compton is causing the wakeups (e.g. by commenting out certain code), tracing which commit is introducing high wakeups (by building old versions compton), tracing under what kind of workload compton works the poorest and best, etc., probably will lead to the correct answer of the question. Try to build a reliable test environment and use longer and repeated tests to get rid of statistical variance, and don't forget to look at the X process. I will do some tests here when I have time, but I believe it depends on the driver a lot, and I don't have a laptop.

pschyska commented 11 years ago

Does compton --vsync opengl under XRender backend works? Well, it does work and I get up to 96% RC6pp, but the tearing is back. I tried all vsync modes and there is no difference to none. My kernel is 3.11.3 and I'm using the git version of xf86-video-intel from yesterday, because it fixes a bug with corrupted display in chromium with sna. So I don't think is the problem. The X architecture, formed in 1980s, contributes a lot of the overhead, though, and Wayland may be direction of the future. FTFY. Sorry, couldn't resist :smile:

I did play around with all the options mentioned in the performance FAQ, but didn't see any difference either in --benchmark or power usage (but I didn't test in a sane testing environment).

FWIW, I don't use any of the effects like shadow and blur. It's just a tear-free X I'm after.

Thanks again for your thorough explanation. I guess I will live with this issue and wait for Wayland. At least now I can choose between slightly longer battery and tearing :+1:

richardgv commented 11 years ago

Well, it does work and I get up to 96% RC6pp, but the tearing is back. I tried all vsync modes and there is no difference to none. I did play around with all the options mentioned in the performance FAQ, but didn't see any difference either in --benchmark or power usage (but I didn't test in a sane testing environment). FWIW, I don't use any of the effects like shadow and blur. It's just a tear-free X I'm after.

Huh, I'm sorry, then. I will come back when I get some related info.

The X architecture, formed in 1980s, contributes a lot of the overhead, though, and Wayland may be direction of the future. FTFY. Sorry, couldn't resist :smile:

Sorry? You mean, the removal of "Mir"?

pschyska commented 11 years ago

I don't put much hope into Mir, but we will see.

AGenchev commented 10 years ago

@pschyska: Did you try to comment the vsync option in compton's config to let the OpenGL driver default to be used ? In my setup (Xubuntu v13.10@2013'Q4, SandyBridge GPU) this does the trick of fixing vsync, because it's on by default.

mutcianm commented 10 years ago

@AGenchev This doesn't help. The issue persists if any vsync method is used with glx backend regardless of other options. hardware: x230 with i5-3210M IvyBridge compton version: d8977408fd48f0ab220e2897bbaa7456f23650a6

pschyska commented 10 years ago

@AGenchev I made the same observation as @dedoz I have tried different combinations of all the settings, and as soon as glx was used, I got virtually no RC6*.

If you say "this does the trick for me", can you please report your RC6* percentages from powertop? For example, I get without compton, but with intel's TearFree implementation, powertop in terminator (no blinking cursor): 1.2%, 98.8% RC6pp.

AGenchev commented 10 years ago

I don't know about powertop, installed it today and it gives me a rather long (to include whole) report: Summary: 147,4 wakeups/second, 5,9 GPU ops/seconds, 0,0 VFS ops/sec and 2,4% CPU use -- the rest is removed by me. This is with compton active. Probably you watch "Idle stats" tab, GPU values. For me they're: GPU: Powered On 22,8%, | RC6 77,2% | RC6p 0,0% | RC6pp 0,0%

pschyska commented 10 years ago

GPU: Powered On 22,8%, | RC6 77,2% | RC6p 0,0% | RC6pp 0,0%

That looks actually not too bad. Is this with the opengl backend? Can you give me the command line start your start compton with, config and version?

I might give it another try. TearFree is still kinda janky :-1:

AGenchev commented 10 years ago

I configured XFCE to run it -> at "session & startup". The command line is "compton".
Version: compton_0.0.9+1git20131210 the config is in the ~/.config/compton.conf file: backend = "glx"; glx-no-stencil = true; glx-copy-from-front = false; glx-swap-method = "undefined"; shadow = true; no-dnd-shadow = true; no-dock-shadow = true; clear-shadow = true; shadow-radius = 5; shadow-offset-x = -5; shadow-offset-y = -5; shadow-opacity = 0.5;

shadow-exclude = [ "! name~=''", "name = 'Notification'", "name = 'Plank'", "name = 'Docky'", "name = 'Kupfer'", "name = 'xfce4-notifyd'", "name = 'VLC'", "name = 'compton'", "name = 'Chromium'", "name = 'Chrome'", "name *= 'Firefox'", "class_g = 'Conky'", "class_g = 'Kupfer'", "class_g = 'Synapse'", "class_g ?= 'Notify-osd'", "class_g ?= 'Cairo-dock'", "class_g ?= 'Xfce4-notifyd'", "class_g ?= 'Xfce4-power-manager'" ]; shadow-ignore-shaped = false; menu-opacity = 1; inactive-opacity = 1; active-opacity = 1; frame-opacity = 1; inactive-opacity-override = false; alpha-step = 0.06; blur-background-fixed = false; blur-background-exclude = [ "window_type = 'dock'", "window_type = 'desktop'" ];

fading = false; mark-wmwin-focused = true; mark-ovredir-focused = true; use-ewmh-active-win = true; detect-rounded-corners = true; detect-client-opacity = true; refresh-rate = 0; dbe = false; paint-on-overlay = true; sw-opti = false; unredir-if-possible = true; focus-exclude = [ ]; detect-transient = true; detect-client-leader = true; wintypes: { tooltip = { fade = true; shadow = false; opacity = 0.85; focus = true; }; };

mutcianm commented 10 years ago

Commit fbd70e146c6fa46250dc2b435afb347c3cf54539 seems to be a viable workaround. C6 values are back to normal >90% in idle. Although it is mentioned that blur and opacity performance might degrade with xr_glx_hybird backend, the only features I use are vsync and shadows, so it's no big deal.

pschyska commented 10 years ago

RC6PP over 90% with git-v0.1_beta2-3-gfbd70e1-2013-12-10. Thanks, guys! :thumbsup: Works for me. I think this issue can be closed.

richardgv commented 10 years ago

Heh, I've glad you have found a... Sort of workaround. But it remains an issue that GLX backends leads to higher power consumption. The fact that xr_glx_hybird works probably indicate it's compton's painting (or something related, like pixmap-texture binding) in GLX backend that wakes your GPU up...