Bug 42413 - Window movement only smooth when running opengl applications [SNA, 2.16.901]
Summary: Window movement only smooth when running opengl applications [SNA, 2.16.901]
Status: RESOLVED FIXED
Alias: None
Product: xorg
Classification: Unclassified
Component: Driver/intel (show other bugs)
Version: git
Hardware: Other All
: medium normal
Assignee: Chris Wilson
QA Contact: Xorg Project Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-10-31 01:21 UTC by Clemens Eisserer
Modified: 2011-11-26 14:41 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
xorg log (28.65 KB, application/octet-stream)
2011-10-31 01:21 UTC, Clemens Eisserer
no flags Details

Description Clemens Eisserer 2011-10-31 01:21:54 UTC
Created attachment 52935 [details]
xorg log

When using xfce without compositor, window movement feels slow (however system load stays low) except an opengl application is running.
Theres also tearing involved, hard to describe - definitivly doesn't look like the system can't keep up with rendering.

It somehow looks like movement events are dispatched too lazily, or if some buffers are scanned out at a very low frequency.

When moving windows arround while glxgears is running, window movement is smooth, whereas its slow again when glxgears is terminated. (this behaviour differs from intel-2.16.0 where window movement would stay fast, when glxgears was started once).

If you need more information, I would be happy to provide it.

intel i945GM

libdrm-2.4.27
pixman-0.23.8
linux-3.1.0
xorg 1.11.1
Comment 1 Clemens Eisserer 2011-10-31 01:27:29 UTC
Forgot to mention, the problem only manifests with SNA, with UXA window movement is smooth without tearing.
Comment 2 Chris Wilson 2011-10-31 02:28:33 UTC
I suspect the tearing is a perception issue, as the front buffer rendering of an uncomposited X server is unchanged. However, a delay is built into sna to avoid flushing the batch on every block handler and there I have erred on the side of slow updates during periods of small changes.

I've added an option to disable the deferred update mechanism entirely,
  Option "DelayedFlush" "False",
but you can also play with

diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c
index f6095b5..6a6c841 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -6008,9 +6008,9 @@ static Bool sna_accel_do_flush(struct sna *sna)
        to.it_value.tv_sec = 0;
        to.it_value.tv_nsec = 10 * 1000 * 1000;
 
-       /* Then periodic updates at 25Hz.*/
+       /* Then periodic updates at 100Hz.*/
        to.it_interval.tv_sec = 0;
-       to.it_interval.tv_nsec = 40 * 1000 * 1000;
+       to.it_interval.tv_nsec = 10 * 1000 * 1000;
        timerfd_settime(sna->timer[FLUSH_TIMER], 0, &to, NULL);
 
        sna->timer_active |= 1 << FLUSH_TIMER;

to see if there is a better value which works for you. I plucked a figure that was half my monitor's refresh rate, which I think is an acceptable compromise - maybe I should make that an automatic selection...
Comment 3 Clemens Eisserer 2011-10-31 02:33:59 UTC
Thanks for the fast response.

I can confirm that the issue disappears when adjusting the timer to 100Hz :)
Probably the 40Hz bite a bit with my laptop's refresh rate of 60Hz - maybe 2x refresh rate wouldn't be a bad idea?

Thanks, Clemens
Comment 4 Chris Wilson 2011-10-31 05:30:22 UTC
I've tweaked the flush interval to be set to twice the vblank. Can you please experiment and see if that is acceptable, might need to go to vblank or half-vblank. :|
Comment 5 Clemens Eisserer 2011-10-31 09:37:34 UTC
Hi,

Does the current code set it to half-vblank? Because with the automatic adoption I don't see an improvement - whereas setting it to 100Hz makes everything smooth again. 
Why is it so important to keep flush frequency so low - power consumption?

Thanks, Clemens
Comment 6 Chris Wilson 2011-10-31 09:46:24 UTC
Unmeasured yet, but the goal is indeed to reduce the number of unnecessary wakeups and improve power consumption and throughput at the cost of latency -- which is meant to still be around the one or two vblank mark and supposedly unnoticeable. ;-)

I'm curious as to what the actual update rates are and so I'll get around to adding some low impact debugging to measure them and see if I can find a reason why it is so noticeable for you. One starting point would be to use
  trace-cmd record -e i915
which we give me a timeline of all events and that way I can work out the frequency that the ddx is submitting batches.
Comment 7 Chris Wilson 2011-10-31 09:49:36 UTC
(In reply to comment #5)
> Does the current code set it to half-vblank?

Currently two-vblank.

diff --git a/src/sna/sna_display.c b/src/sna/sna_display.c
index a82ccd8..dacf7bf 100644
--- a/src/sna/sna_display.c
+++ b/src/sna/sna_display.c
@@ -601,7 +601,7 @@ static void update_flush_interval(struct sna *sna)
        if (max_vrefresh == 0)
                max_vrefresh = 40;
 
-       sna->flush_interval = 2000 * 1000 * 1000 / max_vrefresh;
+       sna->flush_interval = 1000 * 1000 * 1000 / max_vrefresh;
        DBG(("max_vrefresh=%d, flush_interval=%d ns\n",
               max_vrefresh, sna->flush_interval));
 }

would set it to be vblank (16ms, I guess in your case)
Comment 8 Clemens Eisserer 2011-11-03 02:05:27 UTC
Thanks, setting it to vblank seems to do the trick :)
Comment 9 Chris Wilson 2011-11-04 15:46:30 UTC
If you can find a moment to test current tip of sna, I'm interested to see if you can notice any change in the default behaviour. Thanks.
Comment 10 Clemens Eisserer 2011-11-04 16:15:10 UTC
the perceived behaviour with default settings is unchanged unfourtunatly.
Comment 11 Chris Wilson 2011-11-04 16:36:25 UTC
I pushed the patch to flush the batch at least once for each vblank. Can you please confirm happiness? :)
Comment 12 Clemens Eisserer 2011-11-04 17:15:14 UTC
Hapiness confirmed :)
Comment 13 Chris Wilson 2011-11-04 17:24:21 UTC
commit 676cb4e38dc381b2ef4fb092b66db80687aa5013
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Fri Nov 4 23:30:09 2011 +0000

    sna: Run the deferred flush at vrefresh
    
    This helps to reduce the perceived jerkiness of the redraw.
    
    Reported-by: Clemens Eisserer <linuxhippy@gmail.com>
    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=42413
    Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

Let me know if you find any other areas that can be improved. Many thanks!
Comment 14 Clemens Eisserer 2011-11-26 14:06:12 UTC
just stumbled over a video which has tearing issues with SNA, whereas playback is fine with UXA (using mplayer + XV backend).

I'll do some testing with delayed flushing disabled to see if it makes a difference.
Comment 15 Chris Wilson 2011-11-26 14:41:56 UTC
vsync'ed video is emitted asap, irrespective of delayed flushing. Are you sure it should be vsync'ed? The debug=full Xorg.log will have the entire batch for you to verify that the wait-for-scanlines is being emitted... After which it is not my fault! ;-)


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.