Mir

Merge lp:~vanvugt/mir/fix-1420678 into lp:mir

Proposed by Daniel van Vugt
Status: Merged
Approved by: Daniel van Vugt
Approved revision: no longer in the source branch.
Merged at revision: 2323
Proposed branch: lp:~vanvugt/mir/fix-1420678
Merge into: lp:mir
Diff against target: 107 lines (+53/-19)
2 files modified
src/server/compositor/buffer_queue.cpp (+0/-19)
tests/unit-tests/compositor/test_buffer_queue.cpp (+53/-0)
To merge this branch: bzr merge lp:~vanvugt/mir/fix-1420678
Reviewer Review Type Date Requested Status
Chris Halse Rogers Approve
PS Jenkins bot (community) continuous-integration Approve
Alan Griffiths Approve
Review via email: mp+249456@code.launchpad.net

Commit message

Fix the multi-monitor frame sync logic to support high speed
compositors (tm) which only need to hold buffers very briefly
(introduced in r2183). (LP: #1420678)

Both the multi-monitor frame sync logic and the optimization of r2183
behave correctly independently. It's only when combined that they start
to interfere with each other. But we'd very much like to keep both...

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

Failure in ServerShutdown.normal_exit_removes_endpoint appears to be unrelated valgrind issue

4: [ RUN ] ServerShutdown.normal_exit_removes_endpoint
4: ==27126==
4: ==27126== HEAP SUMMARY:
4: ==27126== in use at exit: 13,363 bytes in 53 blocks
4: ==27126== total heap usage: 533,640 allocs, 533,587 frees, 34,288,827 bytes allocated
4: ==27126==
4: ==27126== LEAK SUMMARY:
4: ==27126== definitely lost: 0 bytes in 0 blocks
4: ==27126== indirectly lost: 0 bytes in 0 blocks
4: ==27126== possibly lost: 944 bytes in 9 blocks
4: ==27126== still reachable: 12,419 bytes in 44 blocks
4: ==27126== suppressed: 0 bytes in 0 blocks
4: ==27126== Reachable blocks (those to which a pointer was found) are not shown.
4: ==27126== To see them, rerun with: --leak-check=full --show-leak-kinds=all
4: ==27126==
4: ==27126== For counts of detected and suppressed errors, rerun with: -v
4: ==27126== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
4: /tmp/buildd/mir-0.11.0bzr2317pkg0vivid957/tests/mir_test_framework/interprocess_client_server_test.cpp:153: Failure
4: Value of: result.exit_code
4: Expected: is equal to 0
4: Actual: 1 (of type int)
4: [ FAILED ] ServerShutdown.normal_exit_removes_endpoint (532 ms)

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

I don't see any problems with this, but I don't feel confident that it covers all cases. Further opinions would be good.

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

Arguably a more elegant solution was what I had up to r2316. That just removed the whole block of code (removed the double buffering fix for LP: #1319765).

But I too would like a third more elegant solution... Haven't found it yet. It's hard to make logic changes there and still pass all the existing tests (which is good at least).

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Chris Halse Rogers (raof) wrote :

Hm. This doesn't look incorrect, but it also looks like it's papering over a problem elsewhere.

I *think* this might be an artefact of an incorrect fix for bug #1319765? The problem identified there being that there's no additional composition scheduled when the client has submitted a frame and is blocking for its next buffer. This was solved by fake-consuming the client frame; it would seem to be more correct to ensure that the frame that the client has already submitted appropriately triggers composition?

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

It would take me a while to get my head around the problem again. Sounds like we might have been papering over bug 1395581, which was only fixed very recently.

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

raof: Fixed. Thanks!

It's complicated. Took two brains and the coordination of three different bug fixes to realise the interplay...

Revision history for this message
Chris Halse Rogers (raof) wrote :

Looks good now.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/server/compositor/buffer_queue.cpp'
2--- src/server/compositor/buffer_queue.cpp 2015-01-22 09:12:04 +0000
3+++ src/server/compositor/buffer_queue.cpp 2015-02-17 06:41:51 +0000
4@@ -271,25 +271,6 @@
5 if (nbuffers <= 1)
6 return;
7
8- /*
9- * We can't release the current_compositor_buffer because we need to keep
10- * a compositor buffer always-available. But there might be a new
11- * compositor buffer available to take its place immediately. Moving to
12- * that one immediately will free up the old compositor buffer, allowing
13- * us to call back the client with a buffer where otherwise we couldn't.
14- */
15- if (current_compositor_buffer == buffer.get() &&
16- !ready_to_composite_queue.empty())
17- {
18- current_compositor_buffer = pop(ready_to_composite_queue);
19-
20- // Ensure current_compositor_buffer gets reused by the next
21- // compositor_acquire:
22- current_buffer_users.clear();
23- void const* const impossible_user_id = this;
24- current_buffer_users.push_back(impossible_user_id);
25- }
26-
27 if (current_compositor_buffer != buffer.get())
28 release(buffer.get(), std::move(lock));
29 }
30
31=== modified file 'tests/unit-tests/compositor/test_buffer_queue.cpp'
32--- tests/unit-tests/compositor/test_buffer_queue.cpp 2015-01-22 09:12:04 +0000
33+++ tests/unit-tests/compositor/test_buffer_queue.cpp 2015-02-17 06:41:51 +0000
34@@ -489,6 +489,44 @@
35 }
36 }
37
38+TEST_F(BufferQueueTest, multiple_fast_compositors_are_in_sync)
39+{ // Regression test for LP: #1420678
40+ for (int nbuffers = 3; nbuffers <= max_nbuffers_to_test; ++nbuffers)
41+ {
42+ mc::BufferQueue q(nbuffers, allocator, basic_properties, policy_factory);
43+
44+ // Client generates first frame
45+ auto handle1 = client_acquire_async(q);
46+ ASSERT_TRUE(handle1->has_acquired_buffer());
47+ auto client_id1 = handle1->id();
48+ handle1->release_buffer();
49+
50+ // Client generates second frame
51+ auto handle2 = client_acquire_async(q);
52+ ASSERT_TRUE(handle2->has_acquired_buffer());
53+ auto client_id2 = handle2->id();
54+ handle2->release_buffer();
55+
56+ // Many monitors... verify they all get the first frame.
57+ for (int monitor = 0; monitor < 10; monitor++)
58+ {
59+ void const* user_id = reinterpret_cast<void const*>(monitor);
60+ auto comp_buffer = q.compositor_acquire(user_id);
61+ ASSERT_EQ(client_id1, comp_buffer->id());
62+ q.compositor_release(comp_buffer);
63+ }
64+
65+ // Still many monitors... verify they all get the second frame.
66+ for (int monitor = 0; monitor < 10; monitor++)
67+ {
68+ void const* user_id = reinterpret_cast<void const*>(monitor);
69+ auto comp_buffer = q.compositor_acquire(user_id);
70+ ASSERT_EQ(client_id2, comp_buffer->id());
71+ q.compositor_release(comp_buffer);
72+ }
73+ }
74+}
75+
76 TEST_F(BufferQueueTest, compositor_acquires_frames_in_order)
77 {
78 for (int nbuffers = 2; nbuffers <= max_nbuffers_to_test; ++nbuffers)
79@@ -1236,6 +1274,14 @@
80 q.client_release(client_acquire_sync(q));
81
82 q.compositor_release(b);
83+
84+ /*
85+ * Update to the original test case; This additional compositor acquire
86+ * represents the fixing of LP: #1395581 in the compositor logic.
87+ */
88+ if (q.buffers_ready_for_compositor(this))
89+ q.compositor_release(q.compositor_acquire(this));
90+
91 auto handle = client_acquire_async(q);
92 // With the fix, a buffer will be available instantaneously:
93 ASSERT_TRUE(handle->has_acquired_buffer());
94@@ -1272,6 +1318,13 @@
95
96 q.compositor_release(b);
97
98+ /*
99+ * Update to the original test case; This additional compositor acquire
100+ * represents the fixing of LP: #1395581 in the compositor logic.
101+ */
102+ if (q.buffers_ready_for_compositor(this))
103+ q.compositor_release(q.compositor_acquire(this));
104+
105 auto z = client_acquire_async(q);
106 ASSERT_TRUE(z->has_acquired_buffer());
107 z->release_buffer();

Subscribers

People subscribed via source and target branches