lib/tsocket: add a fast path to tsocket_sendto_send/recv()
authorStefan Metzmacher <metze@samba.org>
Wed, 11 Mar 2009 16:11:22 +0000 (17:11 +0100)
committerStefan Metzmacher <metze@samba.org>
Thu, 19 Mar 2009 15:25:57 +0000 (16:25 +0100)
By first trying to send data without waiting for the socket
to become writeable we gain about 10-20% performance in the
LDAP-BENCH-CLDAP test.

metze

lib/tsocket/tsocket_sendto.c

index 4531c403212976af202e08f13415a5e9b838e250..9c0a76bf166b42ca5da78b8124aefa8fa45231d8 100644 (file)
@@ -75,6 +75,16 @@ struct tevent_req *tsocket_sendto_send(struct tsocket_context *sock,
        state->caller.dst       = dst;
        state->ret              = -1;
 
+       /*
+        * this is a fast path, not waiting for the
+        * socket to become explicit writeable gains
+        * about 10%-20% performance in benchmark tests.
+        */
+       tsocket_sendto_handler(sock, req);
+       if (!tevent_req_is_in_progress(req)) {
+               goto post;
+       }
+
        talloc_set_destructor(state, tsocket_sendto_state_destructor);
 
        ret = tsocket_set_writeable_handler(sock,