[Xapian-discuss] Performance of remote database

Olly Betts olly at survex.com
Tue Nov 7 22:14:10 GMT 2006


On Tue, Nov 07, 2006 at 09:39:48PM +0000, Rafael SDM Sierra wrote:
> Hmm, it's pretty good, especially with replace_document, now both
> (add/replace) take the same time, now I'm getting arround of 9~10
> documents/s

And the attached patch makes the same change for the client side, which
improves things further for the testsuite at least.

> But isn't equal this method (progsrv)

We should be able to do at least slightly better than progsrv does,
since we don't have the overhead of authentication or encryption.

Cheers,
    Olly
-------------- next part --------------
Index: net/tcpclient.cc
===================================================================
--- net/tcpclient.cc	(revision 7437)
+++ net/tcpclient.cc	(working copy)
@@ -29,6 +29,7 @@
 
 #include <netdb.h>
 #include <netinet/in.h>
+#include <netinet/tcp.h>
 #include <string.h>
 #ifdef __WIN32__
 # include <winsock2.h>
@@ -87,8 +88,22 @@
     remaddr.sin_port = htons(port);
     memcpy(&remaddr.sin_addr, host->h_addr, sizeof(remaddr.sin_addr));
 
-    fcntl(socketfd, F_SETFL, O_NDELAY);
+    if (fcntl(socketfd, F_SETFL, O_NDELAY) < 0) {
+	int saved_errno = errno; // note down in case close hits an error
+	close(socketfd);
+	throw Xapian::NetworkError("Couldn't set O_NDELAY", get_tcpcontext(hostname,  port), saved_errno);
+    }
 
+    {
+	int optval = 1;
+	if (setsockopt(socketfd, IPPROTO_TCP, TCP_NODELAY,
+		       reinterpret_cast<void *>(&optval), sizeof(optval)) < 0) {
+	    int saved_errno = errno; // note down in case close hits an error
+	    close(socketfd);
+	    throw Xapian::NetworkError("Couldn't set TCP_NODELAY", get_tcpcontext(hostname,  port), saved_errno);
+	}
+    }
+
     int retval = connect(socketfd, reinterpret_cast<sockaddr *>(&remaddr),
 			 sizeof(remaddr));
 


More information about the Xapian-discuss mailing list