dean gaudet wrote:
>On Mon, 2 Jul 2001, Brian Pane wrote:
>
>>then it should be possible to eliminate a system call by not doing the
>>initial read before the select.
>>
>
>that sounds correct and a desirable change. i think the current behaviour
>goes all the way back to the first iol stuff i did, and was possibly just
>a thinko?
>
>oh perhaps it was because i didn't want to pay for a stack allocation on
>every entry to the low level send/recv routines? (which is why there's a
>separate wait_for_io_or_timeout routine)
>
>that change is worth benchmarking.
>
>-dean
>
Here's a patch that disables the read before the select, but only for
the HTTP client socket. Can somebody with a decent benchmark lab
test it out to see if the throughput change is significant?
Thanks,
--Brian
Index: server/protocol.c
===================================================================
RCS file: /home/cvspublic/httpd-2.0/server/protocol.c,v
retrieving revision 1.28
diff -u -r1.28 protocol.c
--- server/protocol.c 2001/06/27 20:18:09 1.28
+++ server/protocol.c 2001/07/03 06:15:36
@@ -588,6 +588,8 @@
(int)(keptalive
? r->server->keep_alive_timeout * APR_USEC_PER_SEC
: r->server->timeout * APR_USEC_PER_SEC));
+
+ apr_setsocketopt(conn->client_socket, APR_OPTIMISTIC_READ, 0);
/* Get the request... */
if (!read_request_line(r)) {
Index: srclib/apr/include/apr_network_io.h
===================================================================
RCS file: /home/cvspublic/apr/include/apr_network_io.h,v
retrieving revision 1.102
diff -u -r1.102 apr_network_io.h
--- srclib/apr/include/apr_network_io.h 2001/05/02 02:32:44 1.102
+++ srclib/apr/include/apr_network_io.h 2001/07/03 06:15:40
@@ -102,6 +102,7 @@
* APR_TCP_NODELAY should be turned on
* again when NOPUSH is turned off
*/
+#define APR_OPTIMISTIC_READ 4096
#define APR_POLLIN 0x001
#define APR_POLLPRI 0x002
Index: srclib/apr/include/arch/unix/locks.h
===================================================================
RCS file: /home/cvspublic/apr/include/arch/unix/locks.h,v
retrieving revision 1.35
diff -u -r1.35 locks.h
--- srclib/apr/include/arch/unix/locks.h 2001/07/01 05:49:44 1.35
+++ srclib/apr/include/arch/unix/locks.h 2001/07/03 06:15:51
@@ -164,6 +164,7 @@
#if APR_USE_PTHREAD_SERIALIZE
pthread_mutex_t *intraproc;
#endif
+
#ifdef HAVE_PTHREAD_RWLOCK_INIT
pthread_rwlock_t rwlock;
#endif
Index: srclib/apr/network_io/unix/sendrecv.c
===================================================================
RCS file: /home/cvspublic/apr/network_io/unix/sendrecv.c,v
retrieving revision 1.65
diff -u -r1.65 sendrecv.c
--- srclib/apr/network_io/unix/sendrecv.c 2001/05/03 22:38:00 1.65
+++ srclib/apr/network_io/unix/sendrecv.c 2001/07/03 06:15:57
@@ -125,13 +125,15 @@
apr_status_t apr_recv(apr_socket_t *sock, char *buf, apr_size_t *len)
{
ssize_t rv;
-
- do {
- rv = read(sock->socketdes, buf, (*len));
- } while (rv == -1 && errno == EINTR);
- if (rv == -1 && (errno == EAGAIN || errno == EWOULDBLOCK) &&
- sock->timeout != 0) {
+ if (sock->netmask & APR_OPTIMISTIC_READ) {
+ do {
+ rv = read(sock->socketdes, buf, (*len));
+ } while (rv == -1 && errno == EINTR);
+ }
+ if (!(sock->netmask & APR_OPTIMISTIC_READ) ||
+ (rv == -1 && (errno == EAGAIN || errno == EWOULDBLOCK) &&
+ sock->timeout != 0)) {
apr_status_t arv = wait_for_io_or_timeout(sock, 1);
if (arv != APR_SUCCESS) {
*len = 0;
Index: srclib/apr/network_io/unix/sockets.c
===================================================================
RCS file: /home/cvspublic/apr/network_io/unix/sockets.c,v
retrieving revision 1.74
diff -u -r1.74 sockets.c
--- srclib/apr/network_io/unix/sockets.c 2001/05/02 02:32:47 1.74
+++ srclib/apr/network_io/unix/sockets.c 2001/07/03 06:15:57
@@ -111,6 +111,7 @@
*/
sock->netmask |= APR_TCP_NODELAY;
#endif
+ sock->netmask |= APR_OPTIMISTIC_READ;
}
static void alloc_socket(apr_socket_t **new, apr_pool_t *p)
{
Index: srclib/apr/network_io/unix/sockopt.c
===================================================================
RCS file: /home/cvspublic/apr/network_io/unix/sockopt.c,v
retrieving revision 1.45
diff -u -r1.45 sockopt.c
--- srclib/apr/network_io/unix/sockopt.c 2001/04/05 18:56:08 1.45
+++ srclib/apr/network_io/unix/sockopt.c 2001/07/03 06:15:57
@@ -279,6 +279,9 @@
return APR_ENOTIMPL;
#endif
}
+ if (opt & APR_OPTIMISTIC_READ) {
+ apr_set_option(&sock->netmask, APR_OPTIMISTIC_READ, on);
+ }
return APR_SUCCESS;
}