Mir

Merge lp:~alan-griffiths/mir/fix-1288570 into lp:mir

Proposed by Alan Griffiths
Status: Merged
Approved by: Alan Griffiths
Approved revision: no longer in the source branch.
Merged at revision: 1458
Proposed branch: lp:~alan-griffiths/mir/fix-1288570
Merge into: lp:mir
Diff against target: 81 lines (+27/-19)
2 files modified
src/server/compositor/switching_bundle.cpp (+26/-19)
src/server/compositor/switching_bundle.h (+1/-0)
To merge this branch: bzr merge lp:~alan-griffiths/mir/fix-1288570
Reviewer Review Type Date Requested Status
Daniel van Vugt Approve
PS Jenkins bot (community) continuous-integration Approve
Alexandros Frantzis (community) Needs Fixing
Review via email: mp+209662@code.launchpad.net

Commit message

compositor: check that client buffers are actually available before completing client_acquire. (fixes 1288570)

Description of the change

compositor: check that client buffers are actually available before completing client_acquire. (fixes 1288570)

To post a comment you must log in.
Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

Without this patch I get a constant 120 FPS when the app is between screens. Applying this patch I get 60FPS for a few seconds, then a couple of seconds of increased frame rate, and so on:

120 FPS
60 FPS
60 FPS
60 FPS
60 FPS
60 FPS
80 FPS
120 FPS
61 FPS
60 FPS
60 FPS
60 FPS
60 FPS
77 FPS
120 FPS
64 FPS
60 FPS
60 FPS
60 FPS
60 FPS
78 FPS
120 FPS
62 FPS
60 FPS
60 FPS
60 FPS
60 FPS
78 FPS

review: Needs Fixing
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

> Without this patch I get a constant 120 FPS when the app is between screens.
> Applying this patch I get 60FPS for a few seconds, then a couple of seconds of
> increased frame rate, and so on:

Weird. I see a steady 60fps for minutes.

As I can't reproduce your result could you help by trying -r1455 of this branch (which simply reinstates the synchronous behavior).

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

With r1455 behavior is the same as with r1457:

60 FPS
66 FPS
120 FPS
77 FPS
60 FPS
60 FPS
60 FPS
60 FPS
65 FPS
120 FPS
78 FPS
60 FPS
60 FPS
60 FPS
60 FPS
65 FPS
120 FPS
78 FPS

FWIW, this is on an intel laptop with screen 1280x800, and external screen 1920x1080 connected with VGA.

Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

On my intel laptop with screen 1600x900 and external 1920x1080 I see a slight variation in speed. (between 56fps and 62fps)

The animation looks fine throughout.

Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

Update - I just saw it hit 90fps

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Seems to solve the problem for me. Though I don't yet understand the new algorithm to understand why.

Some thoughts:

(1) This shouldn't be inline. There's no performance benefit and it will just bloat the code slightly:
8 +inline
9 +bool mc::SwitchingBundle::client_buffers_available(std::unique_lock<std::mutex> const& /*lock*/)

(2) The lock parameter in the above function is unnecessary (except as documentation?), so should be removed. The function is always called inside a lock anyway.

review: Approve
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

The effect Alexandros reports running on his laptop already exists in -r 1397 and clearly has a different root cause to 1288570.

Landing this and reporting a new bug.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/server/compositor/switching_bundle.cpp'
--- src/server/compositor/switching_bundle.cpp 2014-03-06 05:29:00 +0000
+++ src/server/compositor/switching_bundle.cpp 2014-03-06 12:38:10 +0000
@@ -182,6 +182,29 @@
182 return ring[slot].buf;182 return ring[slot].buf;
183}183}
184184
185inline
186bool mc::SwitchingBundle::client_buffers_available(std::unique_lock<std::mutex> const& /*lock*/)
187{
188 /*
189 * Even if there are free buffers available, we might wish to still
190 * wait. This is so we don't touch (hence allocate) a third or higher
191 * buffer until/unless it's absolutely necessary. It becomes necessary
192 * only when framedropping (above) or with overlapping compositors
193 * (like with bypass).
194 * The performance benefit of triple buffering is usually minimal,
195 * but always uses 50% more memory. So try to avoid it when possible.
196 */
197
198 int min_free =
199#if 0 // FIXME: This memory optimization breaks timing tests
200 (nbuffers > 2 && !overlapping_compositors) ? nbuffers - 1 : 1;
201#else
202 1;
203#endif
204
205 return nfree() >= min_free;
206}
207
185void mc::SwitchingBundle::client_acquire(std::function<void(graphics::Buffer* buffer)> complete)208void mc::SwitchingBundle::client_acquire(std::function<void(graphics::Buffer* buffer)> complete)
186{209{
187 std::unique_lock<std::mutex> lock(guard);210 std::unique_lock<std::mutex> lock(guard);
@@ -199,24 +222,7 @@
199 }222 }
200 else223 else
201 {224 {
202 /*225 if (!client_buffers_available(lock))
203 * Even if there are free buffers available, we might wish to still
204 * wait. This is so we don't touch (hence allocate) a third or higher
205 * buffer until/unless it's absolutely necessary. It becomes necessary
206 * only when framedropping (above) or with overlapping compositors
207 * (like with bypass).
208 * The performance benefit of triple buffering is usually minimal,
209 * but always uses 50% more memory. So try to avoid it when possible.
210 */
211
212 int min_free =
213#if 0 // FIXME: This memory optimization breaks timing tests
214 (nbuffers > 2 && !overlapping_compositors) ? nbuffers - 1 : 1;
215#else
216 1;
217#endif
218
219 if (nfree() < min_free)
220 return;226 return;
221 }227 }
222228
@@ -362,7 +368,8 @@
362 ncompositors--;368 ncompositors--;
363 }369 }
364370
365 if (client_acquire_todo) complete_client_acquire(std::move(lock));371 if (client_buffers_available(lock) && client_acquire_todo)
372 complete_client_acquire(std::move(lock));
366 }373 }
367}374}
368375
369376
=== modified file 'src/server/compositor/switching_bundle.h'
--- src/server/compositor/switching_bundle.h 2014-03-06 05:29:00 +0000
+++ src/server/compositor/switching_bundle.h 2014-03-06 12:38:10 +0000
@@ -84,6 +84,7 @@
8484
85 const std::shared_ptr<graphics::Buffer> &alloc_buffer(int slot);85 const std::shared_ptr<graphics::Buffer> &alloc_buffer(int slot);
86 void complete_client_acquire(std::unique_lock<std::mutex> lock);86 void complete_client_acquire(std::unique_lock<std::mutex> lock);
87 bool client_buffers_available(std::unique_lock<std::mutex> const& lock);
87 struct SharedBuffer88 struct SharedBuffer
88 {89 {
89 std::shared_ptr<graphics::Buffer> buf;90 std::shared_ptr<graphics::Buffer> buf;

Subscribers

People subscribed via source and target branches