]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
2004-11-25 Havoc Pennington <hp@redhat.com>
authorHavoc Pennington <hp@redhat.com>
Fri, 26 Nov 2004 02:29:00 +0000 (02:29 +0000)
committerHavoc Pennington <hp@redhat.com>
Fri, 26 Nov 2004 02:29:00 +0000 (02:29 +0000)
* dbus/dbus-transport-unix.c (unix_do_iteration): if we're going
to write, without reading or blocking, try it before the poll()
and skip the poll() if nothing remains to write. This is about a
3% speedup in the echo client/server

ChangeLog
dbus/dbus-transport-unix.c

index c9f42f4c1e352980493d814f75c4e2caf8294a0f..3f41a25f5e9e62fdcc14ba8ce5ce40c5768d8923 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2004-11-25  Havoc Pennington  <hp@redhat.com>
+
+       * dbus/dbus-transport-unix.c (unix_do_iteration): if we're going
+       to write, without reading or blocking, try it before the poll()
+       and skip the poll() if nothing remains to write. This is about a
+       3% speedup in the echo client/server
+
 2004-11-25  Havoc Pennington  <hp@redhat.com>
 
         The primary change here is to always write() once before adding
index a33b8f7899f88d0157d1bb6afb59a0dd522e4321..4190da4674b2a8332bdcf76424c812368dc4feae 100644 (file)
@@ -945,13 +945,36 @@ unix_do_iteration (DBusTransport *transport,
   
   if (_dbus_transport_get_is_authenticated (transport))
     {
+      /* This is kind of a hack; if we have stuff to write, then try
+       * to avoid the poll. This is probably about a 5% speedup on an
+       * echo client/server.
+       *
+       * If both reading and writing were requested, we want to avoid this
+       * since it could have funky effects:
+       *   - both ends spinning waiting for the other one to read
+       *     data so they can finish writing
+       *   - prioritizing all writing ahead of reading
+       */
+      if ((flags & DBUS_ITERATION_DO_WRITING) &&
+          !(flags & (DBUS_ITERATION_DO_READING | DBUS_ITERATION_BLOCK)) &&
+          !transport->disconnected &&
+          _dbus_connection_has_messages_to_send_unlocked (transport->connection))
+        {
+          do_writing (transport);
+
+          if (transport->disconnected ||
+              !_dbus_connection_has_messages_to_send_unlocked (transport->connection))
+            goto out;
+        }
+
+      /* If we get here, we decided to do the poll() after all */
       _dbus_assert (unix_transport->read_watch);
       if (flags & DBUS_ITERATION_DO_READING)
        poll_fd.events |= _DBUS_POLLIN;
 
       _dbus_assert (unix_transport->write_watch);
       if (flags & DBUS_ITERATION_DO_WRITING)
-       poll_fd.events |= _DBUS_POLLOUT;
+        poll_fd.events |= _DBUS_POLLOUT;
     }
   else
     {