cvs commit: jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11 InternalAprInputBuffer.java

2005-06-10 Thread remm
remm2005/06/10 07:36:18

  Modified:util/java/org/apache/tomcat/util/net AprEndpoint.java
   http11/src/java/org/apache/coyote/http11
InternalAprInputBuffer.java
  Log:
  - Update after change of the status codes used.
  
  Revision  ChangesPath
  1.41  +1 -1  
jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net/AprEndpoint.java
  
  Index: AprEndpoint.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net/AprEndpoint.java,v
  retrieving revision 1.40
  retrieving revision 1.41
  diff -u -r1.40 -r1.41
  --- AprEndpoint.java  10 Jun 2005 12:55:12 -  1.40
  +++ AprEndpoint.java  10 Jun 2005 14:36:18 -  1.41
  @@ -1217,7 +1217,7 @@
   // Add socket to the poller
   if (addS.size()  0) {
   synchronized (addS) {
  -for (int i = addS.size() - 1; i = 0; i--) {
  +for (int i = (addS.size() - 1); i = 0; i--) {
   SendfileData data = (SendfileData) 
addS.get(i);
   int rv = Poll.add(sendfilePollset, 
data.socket, 0, Poll.APR_POLLOUT);
   if (rv == Status.APR_SUCCESS) {
  
  
  
  1.8   +3 -3  
jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/InternalAprInputBuffer.java
  
  Index: InternalAprInputBuffer.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/InternalAprInputBuffer.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- InternalAprInputBuffer.java   25 May 2005 12:45:38 -  1.7
  +++ InternalAprInputBuffer.java   10 Jun 2005 14:36:18 -  1.8
  @@ -412,7 +412,7 @@
   bbuf.get(buf, pos, nRead);
   lastValid = pos + nRead;
   } else {
  -if (Status.APR_STATUS_IS_ETIMEDOUT(-nRead)) {
  +if ((-nRead) == Status.ETIMEDOUT || (-nRead) == 
Status.TIMEUP) {
   return false;
   } else {
   throw new 
IOException(sm.getString(iib.failedread));
  @@ -442,7 +442,7 @@
   bbuf.get(buf, pos, nRead);
   lastValid = pos + nRead;
   } else {
  -if (Status.APR_STATUS_IS_ETIMEDOUT(-nRead)) {
  +if ((-nRead) == Status.ETIMEDOUT || (-nRead) == 
Status.TIMEUP) {
   return false;
   } else {
   throw new IOException(sm.getString(iib.failedread));
  @@ -786,7 +786,7 @@
   bbuf.get(buf, pos, nRead);
   lastValid = pos + nRead;
   } else {
  -if (Status.APR_STATUS_IS_EAGAIN(-nRead)) {
  +if ((-nRead) == Status.EAGAIN) {
   return false;
   } else {
   throw new IOException(sm.getString(iib.failedread));
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11 InternalAprInputBuffer.java

2005-05-15 Thread remm
remm2005/05/15 08:49:31

  Modified:http11/src/java/org/apache/coyote/http11
InternalAprInputBuffer.java
  Log:
  - Use a direct ByteBuffer for input as well, as the performance impact turned 
out to be bigger than on output (probably
due to the fact that the byte array used is actually bigger).
  - /usr/sbin/ab.exe -c 20 -k -n 2 http://127.0.0.1:8080/tomcat.gif, Sun 
Java 5 server, Windows XP with no firewall:
- APR HTTP: 1.00
- regular HTTP: 1.03
- when removing -k, APR is actually slightly faster now (about the same 
very hard to measure difference, though)
  - This means the difference is negligible, and I expect it to be impossible 
to measure when testing over a network. If
confirmed, these results will make APR recommendable for everyone running a 
Tomcat production server.
  
  Revision  ChangesPath
  1.6   +28 -6 
jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/InternalAprInputBuffer.java
  
  Index: InternalAprInputBuffer.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/InternalAprInputBuffer.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- InternalAprInputBuffer.java   15 Apr 2005 17:19:52 -  1.5
  +++ InternalAprInputBuffer.java   15 May 2005 15:49:31 -  1.6
  @@ -19,6 +19,7 @@
   
   import java.io.IOException;
   import java.io.EOFException;
  +import java.nio.ByteBuffer;
   
   import org.apache.tomcat.jni.Socket;
   import org.apache.tomcat.jni.Status;
  @@ -58,6 +59,7 @@
   headerBuffer2 = new byte[headerBufferSize];
   bodyBuffer = new byte[headerBufferSize];
   buf = headerBuffer1;
  +bbuf = ByteBuffer.allocateDirect(headerBufferSize);
   
   headerBuffer = new char[headerBufferSize];
   ascbuf = headerBuffer;
  @@ -162,6 +164,12 @@
   
   
   /**
  + * Direct byte buffer used to perform actual reading.
  + */
  +protected ByteBuffer bbuf;
  +
  +
  +/**
* Underlying socket.
*/
   protected long socket;
  @@ -393,9 +401,12 @@
   // Read new bytes if needed
   if (pos = lastValid) {
   // Do a simple read with a short timeout
  -int nRead = Socket.recvt
  -(socket, buf, pos, buf.length - lastValid, readTimeout);
  +bbuf.clear();
  +int nRead = Socket.recvbt
  +(socket, bbuf, 0, buf.length - lastValid, readTimeout);
   if (nRead  0) {
  +bbuf.limit(nRead);
  +bbuf.get(buf, pos, nRead);
   lastValid = pos + nRead;
   } else {
   if (Status.APR_STATUS_IS_ETIMEDOUT(-nRead)) {
  @@ -417,9 +428,12 @@
   
   if (pos = lastValid) {
   // Do a simple read with a short timeout
  -int nRead = Socket.recvt
  -(socket, buf, pos, buf.length - lastValid, readTimeout);
  +bbuf.clear();
  +int nRead = Socket.recvbt
  +(socket, bbuf, 0, buf.length - lastValid, readTimeout);
   if (nRead  0) {
  +bbuf.limit(nRead);
  +bbuf.get(buf, pos, nRead);
   lastValid = pos + nRead;
   } else {
   if (Status.APR_STATUS_IS_ETIMEDOUT(-nRead)) {
  @@ -758,8 +772,12 @@
   (sm.getString(iib.requestheadertoolarge.error));
   }
   
  -nRead = Socket.recv(socket, buf, pos, buf.length - lastValid);
  +bbuf.clear();
  +nRead = Socket.recvb
  +(socket, bbuf, 0, buf.length - lastValid);
   if (nRead  0) {
  +bbuf.limit(nRead);
  +bbuf.get(buf, pos, nRead);
   lastValid = pos + nRead;
   } else {
   if (Status.APR_STATUS_IS_EAGAIN(-nRead)) {
  @@ -774,8 +792,12 @@
   buf = bodyBuffer;
   pos = 0;
   lastValid = 0;
  -nRead = Socket.recv(socket, buf, 0, buf.length);
  +bbuf.clear();
  +nRead = Socket.recvb
  +(socket, bbuf, 0, buf.length);
   if (nRead  0) {
  +bbuf.limit(nRead);
  +bbuf.get(buf, 0, nRead);
   lastValid = nRead;
   } else {
   throw new IOException(sm.getString(iib.failedread));
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11 InternalAprInputBuffer.java

2005-04-15 Thread remm
remm2005/04/15 10:19:52

  Modified:util/java/org/apache/tomcat/util/net AprEndpoint.java
   http11/src/java/org/apache/coyote/http11
InternalAprInputBuffer.java
  Log:
  - Fixed keepalive handling (so it works *and* it runs fast).
  
  Revision  ChangesPath
  1.7   +1 -18 
jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net/AprEndpoint.java
  
  Index: AprEndpoint.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net/AprEndpoint.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- AprEndpoint.java  15 Apr 2005 16:37:39 -  1.6
  +++ AprEndpoint.java  15 Apr 2005 17:19:52 -  1.7
  @@ -773,21 +773,12 @@
   // Get the socket pool
   pools[n] = Poll.data(desc[n]);
   // Get retuned events for this socket
  -//events[n] = Poll.events(desc[n]);
  +events[n] = Poll.events(desc[n]);
   // Remove each socket from the poll right 
away
   remove(sockets[n]);
   }
   }
   for (int n = 0; n  rv; n++) {
  -// Check the health of the socket 
  -int res = Socket.recvt(sockets[n], null, 0, 0, 
0);
  -//System.out.println(Events:  + sockets[n] +  
code:  + events[n] +  res:  + res);
  -if (res  0) {
  -// Close socket and clear pool
  -Pool.destroy(pools[n]);
  -continue;
  -}
  -/*
   // Problem events
   if (((events[n]  Poll.APR_POLLHUP) == 
Poll.APR_POLLHUP)
   || ((events[n]  Poll.APR_POLLERR) == 
Poll.APR_POLLERR)) {
  @@ -795,15 +786,7 @@
   Pool.destroy(pools[n]);
   continue;
   }
  -// Anything non normal
  -if (!((events[n]  Poll.APR_POLLIN) == 
Poll.APR_POLLIN)) {
  -// Close socket and clear pool
  -Pool.destroy(pools[n]);
  -continue;
  -}
  -*/
   // Hand this socket off to a worker
  -//System.out.println(Process:  + sockets[n]);
   getWorkerThread().assign(sockets[n], pools[n]);
   }
   }
  
  
  
  1.5   +10 -2 
jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/InternalAprInputBuffer.java
  
  Index: InternalAprInputBuffer.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/InternalAprInputBuffer.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- InternalAprInputBuffer.java   15 Apr 2005 15:49:33 -  1.4
  +++ InternalAprInputBuffer.java   15 Apr 2005 17:19:52 -  1.5
  @@ -398,7 +398,11 @@
   if (nRead  0) {
   lastValid = pos + nRead;
   } else {
  -return false;
  +if (Status.APR_STATUS_IS_ETIMEDOUT(-nRead)) {
  +return false;
  +} else {
  +throw new 
IOException(sm.getString(iib.failedread));
  +}
   }
   }
   
  @@ -418,7 +422,11 @@
   if (nRead  0) {
   lastValid = pos + nRead;
   } else {
  -return false;
  +if (Status.APR_STATUS_IS_ETIMEDOUT(-nRead)) {
  +return false;
  +} else {
  +throw new IOException(sm.getString(iib.failedread));
  +}
   }
   }
   
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11 InternalAprInputBuffer.java

2005-04-14 Thread remm
remm2005/04/14 13:09:16

  Modified:http11/src/java/org/apache/coyote/http11
InternalAprInputBuffer.java
  Log:
  - Use slightly better parameters to optimize straight low latency pipelining 
for my hack.
  
  Revision  ChangesPath
  1.2   +2 -2  
jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/InternalAprInputBuffer.java
  
  Index: InternalAprInputBuffer.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/InternalAprInputBuffer.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- InternalAprInputBuffer.java   14 Apr 2005 18:52:28 -  1.1
  +++ InternalAprInputBuffer.java   14 Apr 2005 20:09:16 -  1.2
  @@ -400,7 +400,7 @@
   // Set socket in non blocking mode and try to read
   int attempts = 0;
   try {
  -while (attempts  1  !fill()) {
  +while (attempts  3  !fill()) {
   Thread.sleep(2);
   attempts++;
   }
  @@ -430,7 +430,7 @@
   // Set socket in non blocking mode and try to read
   int attempts = 0;
   try {
  -while (attempts  1  !fill()) {
  +while (attempts  3  !fill()) {
   Thread.sleep(2);
   attempts++;
   }
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]