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

2005-08-04 Thread remm
remm2005/08/04 00:07:57

  Modified:jk/java/org/apache/coyote/ajp AjpAprProcessor.java
   http11/src/java/org/apache/coyote/http11
InternalAprOutputBuffer.java
Http11AprProcessor.java
  Log:
  - Remove useless HTTP/1.1 PAs (which seem to be only there for initial
access to the util package).
  - Fix AJP APR when security is enabled (access to the util package was 
failing).
  
  Revision  ChangesPath
  1.17  +7 -4  
jakarta-tomcat-connectors/jk/java/org/apache/coyote/ajp/AjpAprProcessor.java
  
  Index: AjpAprProcessor.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/jk/java/org/apache/coyote/ajp/AjpAprProcessor.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- AjpAprProcessor.java  30 Jul 2005 22:22:57 -  1.16
  +++ AjpAprProcessor.java  4 Aug 2005 07:07:57 -   1.17
  @@ -92,14 +92,17 @@
   readTimeout = 100 * 1000;
   }
   
  -// Cause loading of HexUtils
  -int foo = HexUtils.DEC[0];
  -
   // Allocate input and output buffers
   inputBuffer = ByteBuffer.allocateDirect(16 * 1024);
   inputBuffer.limit(0);
   outputBuffer = ByteBuffer.allocateDirect(16 * 1024);
   
  +// Cause loading of HexUtils
  +int foo = HexUtils.DEC[0];
  +
  +// Cause loading of HttpMessages
  +HttpMessages.getMessage(200);
  +
   }
   
   
  @@ -886,7 +889,7 @@
   responseHeaderMessage.appendInt(response.getStatus());
   String message = response.getMessage();
   if (message == null){
  -message= HttpMessages.getMessage(response.getStatus());
  +message = HttpMessages.getMessage(response.getStatus());
   } else {
   message = message.replace('\n', ' ').replace('\r', ' ');
   }
  
  
  
  1.5   +6 -30 
jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/InternalAprOutputBuffer.java
  
  Index: InternalAprOutputBuffer.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/InternalAprOutputBuffer.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- InternalAprOutputBuffer.java  18 May 2005 09:25:08 -  1.4
  +++ InternalAprOutputBuffer.java  4 Aug 2005 07:07:57 -   1.5
  @@ -18,8 +18,6 @@
   
   import java.io.IOException;
   import java.nio.ByteBuffer;
  -import java.security.AccessController;
  -import java.security.PrivilegedAction;
   
   import org.apache.tomcat.jni.Socket;
   import org.apache.tomcat.util.buf.ByteChunk;
  @@ -78,6 +76,9 @@
   committed = false;
   finished = false;
   
  +// Cause loading of HttpMessages
  +HttpMessages.getMessage(200);
  +
   }
   
   
  @@ -428,42 +429,17 @@
   // Write message
   String message = response.getMessage();
   if (message == null) {
  -write(getMessage(status));
  +write(HttpMessages.getMessage(status));
   } else {
   write(message);
   }
   
   // End the response status line
  -if (System.getSecurityManager() != null){
  -   AccessController.doPrivileged(
  -new PrivilegedAction(){
  -public Object run(){
  -buf[pos++] = Constants.CR;
  -buf[pos++] = Constants.LF;
  -return null;
  -}
  -}
  -   );
  -} else {
  -buf[pos++] = Constants.CR;
  -buf[pos++] = Constants.LF;
  -}
  +buf[pos++] = Constants.CR;
  +buf[pos++] = Constants.LF;
   
   }
   
  -private String getMessage(final int message){
  -if (System.getSecurityManager() != null){
  -   return (String)AccessController.doPrivileged(
  -new PrivilegedAction(){
  -public Object run(){
  -return HttpMessages.getMessage(message); 
  -}
  -}
  -   );
  -} else {
  -return HttpMessages.getMessage(message);
  -}
  -}
   
   /**
* Send a header.
  
  
  
  1.31  +4 -15 
jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/Http11AprProcessor.java
  
  Index: Http11AprProcessor.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/Http11AprProcessor.java,v
  retrieving revision 1.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- Http11AprProcessor.java   31 Jul 2005 09:23:02 -  1.30
  +++ 

Re: cvs commit: jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11 InternalAprOutputBuffer.java Http11AprProcessor.java

2005-08-04 Thread Bill Barker

- Original Message -
From: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Thursday, August 04, 2005 12:07 AM
Subject: cvs commit:
jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11
InternalAprOutputBuffer.java Http11AprProcessor.java


 remm2005/08/04 00:07:57

   Modified:jk/java/org/apache/coyote/ajp AjpAprProcessor.java
http11/src/java/org/apache/coyote/http11
 InternalAprOutputBuffer.java
 Http11AprProcessor.java
   Log:
   - Remove useless HTTP/1.1 PAs (which seem to be only there for initial
 access to the util package).
   - Fix AJP APR when security is enabled (access to the util package was
failing).


It looks like you did the same thing I did with JK:  Remove the useless PAs,
and then don't bother to test on a clean build (so that SecurityClassLoad
can still find the removed classes and doesn't complain).  If you don't want
BZ 35894 re-opened, you also need to remove the reference to the removed PAs
in SecurityClassLoad ;-).



This message is intended only for the use of the person(s) listed above as the 
intended recipient(s), and may contain information that is PRIVILEGED and 
CONFIDENTIAL.  If you are not an intended recipient, you may not read, copy, or 
distribute this message or any attachment. If you received this communication 
in error, please notify us immediately by e-mail and then delete all copies of 
this message and any attachments.

In addition you should be aware that ordinary (unencrypted) e-mail sent through 
the Internet is not secure. Do not send confidential or sensitive information, 
such as social security numbers, account numbers, personal identification 
numbers and passwords, to us via ordinary (unencrypted) e-mail.


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



Re: cvs commit: jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11 InternalAprOutputBuffer.java Http11AprProcessor.java

2005-08-04 Thread Remy Maucherat

Bill Barker wrote:

It looks like you did the same thing I did with JK:  Remove the useless PAs,
and then don't bother to test on a clean build (so that SecurityClassLoad
can still find the removed classes and doesn't complain).  If you don't want
BZ 35894 re-opened, you also need to remove the reference to the removed PAs
in SecurityClassLoad ;-).


I made the changes only to the APR versions, so it looks ok to me.

Rémy

-
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 InternalAprOutputBuffer.java

2005-05-18 Thread remm
remm2005/05/18 02:25:08

  Modified:http11/src/java/org/apache/coyote/http11
InternalAprOutputBuffer.java
  Log:
  - Fix write algorithm (at least a return was missing), which could likely be
improved further. Thanks to Jean-Francois for spotting the problem.
  
  Revision  ChangesPath
  1.4   +12 -7 
jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/InternalAprOutputBuffer.java
  
  Index: InternalAprOutputBuffer.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/InternalAprOutputBuffer.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- InternalAprOutputBuffer.java  14 May 2005 20:41:26 -  1.3
  +++ InternalAprOutputBuffer.java  18 May 2005 09:25:08 -  1.4
  @@ -743,15 +743,20 @@
   public int doWrite(ByteChunk chunk, Response res) 
   throws IOException {
   
  -if (bbuf.position() + chunk.getLength()  bbuf.capacity()) {
  -flushBuffer();
  -if (chunk.getLength()  bbuf.capacity()) {
  -if (Socket.send(socket, chunk.getBuffer(), 
chunk.getStart(), 
  -chunk.getLength())  0)
  -throw new 
IOException(sm.getString(iib.failedwrite));
  +// FIXME: It would likely be more efficient to do a number of 
writes
  +// through the direct BB; however, the case should happen very 
rarely.
  +// An algorithm similar to ByteChunk.append may also be better.
  +if (chunk.getLength()  bbuf.capacity()) {
  +if (Socket.send(socket, chunk.getBuffer(), chunk.getStart(), 
  +chunk.getLength())  0) {
  +throw new IOException(sm.getString(iib.failedwrite));
   }
  +} else {
  +if (bbuf.position() + chunk.getLength()  bbuf.capacity()) {
  +flushBuffer();
  +}
  +bbuf.put(chunk.getBuffer(), chunk.getStart(), 
chunk.getLength());
   }
  -bbuf.put(chunk.getBuffer(), chunk.getStart(), chunk.getLength());
   return chunk.getLength();
   
   }
  
  
  

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



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

2005-05-15 Thread Remy Maucherat
Bill Barker wrote:
remm2005/05/14 13:41:26
 Modified:http11/src/java/org/apache/coyote/http11
   InternalAprOutputBuffer.java
 Log:
 - Optimize a little using a direct byte buffer to replace the socket 
buffer.
 - I'll experiment with doing the same optimization for reads, but I 
don't expect it to do anything
   (other than waste memory) as copying bytes will be needed.

Cool.  I had been thinking that the savings with NIO were all do to the 
fact that SocketChannel.write would allocate and copy to another 
ByteBuffer instance if I didn't use direct ByteBuffers.
Yes, it's a little bit faster (the optimization seems a bit more 
efficient on Java 5, also). Not much difference, though, but it confirms 
virtually all the overhead is likely on JNI. I assume it is saving one 
copy of the bytes.

On input, saving a copy won't be possible, so I don't think it'll make a 
difference (maybe it will on Java 5, who knows), but I'll try it anyway.

Right now, with my localhost ab test on tomcat.gif (/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), I'm at (in relative numbers): APR 1.00, 
regular IO 1.13

This is clearly the worst situation, however. Not doing localhost tests 
should hide some of the JNI overhead (as the network stack will actually 
have stuff to do), so I think the results are quite good overall.

Rémy
-
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 InternalAprOutputBuffer.java

2005-05-14 Thread remm
remm2005/05/14 13:41:26

  Modified:http11/src/java/org/apache/coyote/http11
InternalAprOutputBuffer.java
  Log:
  - Optimize a little using a direct byte buffer to replace the socket buffer.
  - I'll experiment with doing the same optimization for reads, but I don't 
expect it to do anything
(other than waste memory) as copying bytes will be needed.
  
  Revision  ChangesPath
  1.3   +25 -45
jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/InternalAprOutputBuffer.java
  
  Index: InternalAprOutputBuffer.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/InternalAprOutputBuffer.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- InternalAprOutputBuffer.java  20 Apr 2005 16:13:23 -  1.2
  +++ InternalAprOutputBuffer.java  14 May 2005 20:41:26 -  1.3
  @@ -17,6 +17,7 @@
   package org.apache.coyote.http11;
   
   import java.io.IOException;
  +import java.nio.ByteBuffer;
   import java.security.AccessController;
   import java.security.PrivilegedAction;
   
  @@ -38,7 +39,7 @@
* @author a href=mailto:[EMAIL PROTECTED]Remy Maucherat/a
*/
   public class InternalAprOutputBuffer 
  -implements OutputBuffer, ByteChunk.ByteOutputChannel {
  +implements OutputBuffer {
   
   
   // -- 
Constants
  @@ -66,15 +67,14 @@
   headerBuffer = new byte[headerBufferSize];
   buf = headerBuffer;
   
  +bbuf = ByteBuffer.allocateDirect((headerBufferSize / 1500 + 1) * 
1500);
  +
   outputStreamOutputBuffer = new SocketOutputBuffer();
   
   filterLibrary = new OutputFilter[0];
   activeFilters = new OutputFilter[0];
   lastActiveFilter = -1;
   
  -socketBuffer = new ByteChunk();
  -socketBuffer.setByteOutputChannel(this);
  -
   committed = false;
   finished = false;
   
  @@ -168,17 +168,11 @@
   
   
   /**
  - * Socket buffer.
  - */
  -protected ByteChunk socketBuffer;
  -
  -
  -/**
  - * Socket buffer (extra buffering to reduce number of packets sent).
  + * Direct byte buffer used for writing.
*/
  -protected boolean useSocketBuffer = false;
  -
  +protected ByteBuffer bbuf = null;
   
  +
   // - 
Properties
   
   
  @@ -202,14 +196,7 @@
* Set the socket buffer size.
*/
   public void setSocketBuffer(int socketBufferSize) {
  -
  -if (socketBufferSize  500) {
  -useSocketBuffer = true;
  -socketBuffer.allocate(socketBufferSize, socketBufferSize);
  -} else {
  -useSocketBuffer = false;
  -}
  -
  +// FIXME: Remove
   }
   
   
  @@ -295,9 +282,7 @@
   }
   
   // Flush the current buffer
  -if (useSocketBuffer) {
  -socketBuffer.flushBuffer();
  -}
  +flushBuffer();
   
   }
   
  @@ -326,7 +311,7 @@
   
   // Recycle Request object
   response.recycle();
  -socketBuffer.recycle();
  +bbuf.clear();
   
   socket = 0;
   buf = headerBuffer;
  @@ -348,7 +333,6 @@
   
   // Recycle Request object
   response.recycle();
  -socketBuffer.recycle();
   
   // Determine the header buffer used for next request
   buf = headerBuffer;
  @@ -390,9 +374,7 @@
   if (lastActiveFilter != -1)
   activeFilters[lastActiveFilter].end();
   
  -if (useSocketBuffer) {
  -socketBuffer.flushBuffer();
  -}
  +flushBuffer();
   
   finished = true;
   
  @@ -595,12 +577,7 @@
   
   if (pos  0) {
   // Sending the response header buffer
  -if (useSocketBuffer) {
  -socketBuffer.append(buf, 0, pos);
  -} else {
  -if (Socket.send(socket, buf, 0, pos)  0)
  -throw new IOException(sm.getString(iib.failedwrite));
  -}
  +bbuf.put(buf, 0, pos);
   }
   
   }
  @@ -738,11 +715,13 @@
   /**
* Callback to write data from the buffer.
*/
  -public void realWriteBytes(byte[] buf, int off, int len)
  +protected void flushBuffer()
   throws IOException {
  -if (len  0) {
  -if (Socket.send(socket, buf, off, len)  0)
  +if (bbuf.position()  0) {
  +if (Socket.sendb(socket, bbuf, 0, bbuf.position())  0) {
   throw new IOException(sm.getString(iib.failedwrite));
  +}
  +bbuf.clear();
   }
   }
   
  @@ -764,14 +743,15 @@
   public int doWrite(ByteChunk chunk, Response res) 
 

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

2005-05-14 Thread Bill Barker
- Original Message - 
From: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Saturday, May 14, 2005 1:41 PM
Subject: cvs commit: 
jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11 
InternalAprOutputBuffer.java


remm2005/05/14 13:41:26
 Modified:http11/src/java/org/apache/coyote/http11
   InternalAprOutputBuffer.java
 Log:
 - Optimize a little using a direct byte buffer to replace the socket 
buffer.
 - I'll experiment with doing the same optimization for reads, but I don't 
expect it to do anything
   (other than waste memory) as copying bytes will be needed.

Cool.  I had been thinking that the savings with NIO were all do to the fact 
that SocketChannel.write would allocate and copy to another ByteBuffer 
instance if I didn't use direct ByteBuffers.


This message is intended only for the use of the person(s) listed above as the 
intended recipient(s), and may contain information that is PRIVILEGED and 
CONFIDENTIAL.  If you are not an intended recipient, you may not read, copy, or 
distribute this message or any attachment. If you received this communication 
in error, please notify us immediately by e-mail and then delete all copies of 
this message and any attachments.
In addition you should be aware that ordinary (unencrypted) e-mail sent through 
the Internet is not secure. Do not send confidential or sensitive information, 
such as social security numbers, account numbers, personal identification 
numbers and passwords, to us via ordinary (unencrypted) e-mail.

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