<div dir="ltr"><div><div>Alberto pointed out a gap in my suggestion #2/#6, which is that the client wouldn't have a way of getting ownership of the additional buffers. So maybe that idea (#2/#6) should become:<br><br>

</div><div>rpc exchange_buffer(Buffer) returns (Buffer)<br></div>rpc allocate_additional_buffer(Void) returns (Buffer)<br></div>rpc remove_additional_buffer(Buffer) returns (Void)<br><br>This still would have the submission happen on the exchange call, but make additional buffer allocations more explicit than the #5 idea.<br>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Jul 9, 2014 at 12:04 PM, Kevin DuBois <span dir="ltr"><<a href="mailto:kevin.dubois@canonical.com" target="_blank">kevin.dubois@canonical.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div><div><div>Attempting to steer the convo more towards the near term (kgunn's "First"), I'm just trying to make sure that the protocol change is somewhat forward-looking without wading into changing the buffer distribution/swapping system too much.<br>

</div><div><br></div><div>Trying to distil the potential directions suggested a bit more:<br></div><div><br></div><div>#1 what we currently have:<br></div>rpc next_buffer(SurfaceId) returns (Buffer)<br>
<br></div>#2 what I've proposed:<br>rpc exchange_buffer(Buffer) returns (Buffer)<br><br></div>#3 "push buffers", the server pushes out buffers to the clients<br></div><div><br></div>#4 multiple buffers owned by the client/client allocated buffers<br>


<br></div><div>now,<br></div><div>#3 and #4 are interesting and 
potentially beneficial, but outside the scope of what I want to 
accomplish [1] with the optimization I'm aiming for. Its good to 
future-proof the protocol for when/if we decide to experiment.<br>
<br></div><div>#3 strikes me as something I'd want to avoid (especially in the near term), because 
when you're pushing buffers to the client, the server is 'driving' the 
activity of the client processes, which seems strange. Now, I'd be fine 
with the client /making a request/ and then getting the buffer back 
asynchronously, but couldn't think of an advantage to this.<br>
<br></div><div>I think #4 could be accommodated by having idea #5:<br>#5<br></div><div>rpc next_buffer(SurfaceId) returns (Buffer);<br></div><div>rpc submit_buffer(Buffer) returns (Void);<br><br></div><div>or supplementing idea #2 to make idea #6 (in the future)<br>


</div><div>rpc exchange_buffer(Buffer) returns (Buffer)<br></div><div>rpc request_client_buffer_count(int) returns (Void)<br></div><div><br></div><div>Effectively,
 #5 removes the implicit release of the client buffer, making the 
submission of the filled buffer explicit. This seems a bit less nice to 
me than #2/#6 from an RAII mindset, so I think I still prefer #2 with a 
future expansion to #6 for multiple client buffers.<br>
<br></div><div>So I guess #2/#6 or  #5 are fine for my immediate 
purposes, and both seem acceptible at the current time, and have some 
forward-thinking in them. Interested if others share my slight 
preference for #2/#6<br>
<br></div>[1]<br>My aim is to let the android 
platform's clients delay waiting for the gpu to finish with the buffer. 
It lets the client pass the fence and the uncompleted buffer back to the
 server without waiting, and requires that the fences are waited upon in
 the compositon pass. About a year or so ago,  doing something similar 
with internal clients in the first landing of unity, we saw some 
noticeable performance improvements that makes us think this would be 
useful in the USC/unity8 setup we have now.<br>
</div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Jul 9, 2014 at 11:39 AM, Kevin Gunn <span dir="ltr"><<a href="mailto:kevin.gunn@canonical.com" target="_blank">kevin.gunn@canonical.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">First<div>Not sure we're still on topic necessarily wrt changing from id's to fd's </div><div>

do we need to conflate that with the double/triple buffering topic ?</div><div>let's answer this first...<br>
<div><br></div><div>Second</div><div>while we're at it :) triple buffering isn't always a win. In the case of small, frequent renders (as an example "8x8 pixel square follow my finger") you'll have potentially 2 extra buffers that need their 16ms of fame on the screen in the queue, 1 at session server, 1 at system server. Which can look a little laggy. I'm willing to say in the same breath though, that this may be lunatic fringe. The win for the triple buffering case is likely more common, which is spikey render times (14+ms) amongst more normal render times (9-12ms)</div>


<div>+1 on giving empty buffers back to the clients to allow them to have a "queue" of empty buffers at their disposal (i'm not sure if RAOF is correct or duflu in that its "<span style="font-family:arial,sans-serif;font-size:12.727272033691406px">synchronously waiting for a round trip every swap"</span>...can we already have an empty buffer queue on the client side ?)</div>


</div></div><div><div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Jul 9, 2014 at 4:35 AM, Daniel van Vugt <span dir="ltr"><<a href="mailto:daniel.van.vugt@canonical.com" target="_blank">daniel.van.vugt@canonical.com</a>></span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Forgive me for rambling on but I just had an important realisation...<br>
<br>
Our current desire to get back to double buffering is only because the Mir protocol is synchronously waiting for a round trip every swap, and somehow I thought that the buffer queue length affected time spent in the ready_to_composite state. Now I'm not so sure that's true.<br>



<br>
If we changed the protocol to implement parallelism, then in theory, keeping triple buffering with a fancy zero-latency swap buffers should perform better than the current protocol that has to wait for a round trip.<br>
<br>
I cannot remember why I thought the length of the buffer queue affected the time from client-rendering to server-compositing. Perhaps we really do need to keep triple-buffering always-on so that the performance gain of a zero-latency client swap-buffers can be achieved...<br>



<br>
In summary, I'm back to thinking any protocol change from next_buffer() needs to support parallelism and not be so synchronous.<span><font color="#888888"><br>
<br>
- Daniel</font></span><div><div><br>
<br>
<br>
On 09/07/14 16:08, Daniel van Vugt wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Oops. I keep forgetting that the new BufferQueue disallows the<br>
compositor to own less than one buffer, so there would no longer be any<br>
benefit to double buffered clients from a more concurrent protocol :(<br>
<br>
Maybe Kevin's suggestion is just fine then. So long as the server is<br>
able to figure out the surface(Id) from the Buffer struct.<br>
<br>
<br>
On 09/07/14 15:41, Daniel van Vugt wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Note that we're working on making double-buffering the default again and<br>
triple the exception. In that case fixing LP: #1253868 may seem<br>
pointless, but it is surprisingly still relevant. Because a fully<br>
parallelized design would significantly speed up double buffering too...<br>
client swap buffers would no longer have to wait for a round-trip before<br>
returning and would instead be almost instant.<br>
<br>
<br>
On 09/07/14 10:00, Daniel van Vugt wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Sounds better to just pass buffers around although I'm not keen on any<br>
change that doesn't make progress on the performance bottleneck LP:<br>
#1253868. The bottleneck is the swapping/exchanging approach which<br>
limits the client to holding only one buffer, so I don't think it's a<br>
good idea for new designs to still have that problem.<br>
<br>
In order to improve parallelism per LP: #1253868 you'd really have to<br>
receive new buffers as soon as they're free, which means getting them as<br>
MirEvents. Then you only need an RPC function to release them back to<br>
the server:<br>
<br>
    rpc release_buffer(Buffer) returns (Void);<br>
<br>
Keep in mind the inter-process communication is the bottleneck here. If<br>
you allow a context switch between the server and client then that's<br>
half to one millisecond (see mirping) per RPC round trip. More than<br>
double that for nested servers and you see the protocol delay could be a<br>
significant factor. So I think any protocol enhancement should have<br>
parallelism designed in.<br>
<br>
I also think we need to be careful about not landing any protocol<br>
changes to RTM candidate series' 0.4-0.5, so the foundation for RTM is<br>
maximally mature (albeit not yet optimal).<br>
<br>
- Daniel<br>
<br>
<br>
On 08/07/14 21:10, Kevin DuBois wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hello mir team,<br>
<br>
In order to get the next buffer for the client, we currently have:<br>
<br>
rpc next_buffer(SurfaceId) returns (Buffer);<br>
<br>
which is problematic for me in working on [1] because this implicitly<br>
releases the buffer from the client side, whereas in working on that<br>
performance improvement, I have to send a fd back to the server. So I<br>
was thinking of adding an rpc method more like:<br>
<br>
rpc exchange_buffer(Buffer) returns (Buffer);<br>
<br>
This would be sufficient to pass the fd fence back, and the buffer<br>
id in<br>
the Buffer protocol message would be sufficient for the server to<br>
figure<br>
out which surface has sent back its buffer. (given the global buffer<br>
id's we're using)<br>
<br>
This does not address the problem noted in:<br>
<a href="https://bugs.launchpad.net/mir/+bug/1253868" target="_blank">https://bugs.launchpad.net/<u></u>mir/+bug/1253868</a><br>
but I think that might be better addressed by having an exchange type<br>
rpc call (explicit or implicit) and negotiating/increasing how many<br>
buffers the client owns somehow else.<br>
<br>
This seems like something that could have diverse opinions, so I'm<br>
hoping to get some input on the protocol change here first.<br>
<br>
Thanks!<br>
Kevin<br>
<br>
[1]<br>
<a href="https://blueprints.launchpad.net/ubuntu/+spec/client-1410-mir-performance" target="_blank">https://blueprints.launchpad.<u></u>net/ubuntu/+spec/client-1410-<u></u>mir-performance</a><br>
<br>
<br>
item:<br>
"[kdub] fencing improvements for clients add the ipc plumbing"<br>
<br>
<br>
</blockquote>
<br>
</blockquote>
<br>
</blockquote>
<br>
</blockquote>
<br>
-- <br>
Mir-devel mailing list<br>
<a href="mailto:Mir-devel@lists.ubuntu.com" target="_blank">Mir-devel@lists.ubuntu.com</a><br>
Modify settings or unsubscribe at: <a href="https://lists.ubuntu.com/mailman/listinfo/mir-devel" target="_blank">https://lists.ubuntu.com/<u></u>mailman/listinfo/mir-devel</a><br>
</div></div></blockquote></div><br></div>
</div></div><br>--<br>
Mir-devel mailing list<br>
<a href="mailto:Mir-devel@lists.ubuntu.com" target="_blank">Mir-devel@lists.ubuntu.com</a><br>
Modify settings or unsubscribe at: <a href="https://lists.ubuntu.com/mailman/listinfo/mir-devel" target="_blank">https://lists.ubuntu.com/mailman/listinfo/mir-devel</a><br>
<br></blockquote></div><br></div>
</div></div></blockquote></div><br></div>