[PATCH] os: Immediately queue initial WriteToClient

Chris Wilson chris at chris-wilson.co.uk
Fri Jun 21 14:58:31 PDT 2013


If we immediately put the WriteToClient() buffer into the socket's write
queue, not only do we benefit from sending the response back to client
earlier, but we also avoid the overhead of copying the data into our own
staging buffer and causing extra work in the next select(). The write is
effectively free as typically we may only send one reply per client per
select() call, so the cost of the FlushClient() is the same.

shmget10:   26400 -> 110000
getimage10: 25000 -> 108000

shmget500:   3160 -> 13500
getimage500: 1000 -> 1010

The knock-on effect is that on a mostly idle composited desktop, the CPU
overhead is dominated by the memmove in WriteToClient, which is in turn
eliminated by this patch.

Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
---
 os/io.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/os/io.c b/os/io.c
index 0d980ab..d34bc39 100644
--- a/os/io.c
+++ b/os/io.c
@@ -814,7 +814,7 @@ WriteToClient(ClientPtr who, int count, const void *__buf)
         }
     }
 #endif
-    if (oco->count + count + padBytes > oco->size) {
+    if (oco->count == 0 || oco->count + count + padBytes > oco->size) {
         FD_CLR(oc->fd, &OutputPending);
         if (!XFD_ANYSET(&OutputPending)) {
             CriticalOutputPending = FALSE;
-- 
1.8.3.1



More information about the xorg-devel mailing list