hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r912533 - in /httpcomponents/httpcore/trunk/httpcore-benchmark/src/main/java/org/apache/http/benchmark: Benchmark.java httpcore/HttpCoreNIOServer.java httpcore/NHttpListener.java jetty/JettyNIOServer.java jetty/JettyServer.java
Date Mon, 22 Feb 2010 11:10:29 GMT
Author: olegk
Date: Mon Feb 22 11:10:29 2010
New Revision: 912533

URL: http://svn.apache.org/viewvc?rev=912533&view=rev
Log:
Desperate attempt at sweezing more performance out of Jetty; some tweaks to HttpCore NIO benchmark
code

Modified:
    httpcomponents/httpcore/trunk/httpcore-benchmark/src/main/java/org/apache/http/benchmark/Benchmark.java
    httpcomponents/httpcore/trunk/httpcore-benchmark/src/main/java/org/apache/http/benchmark/httpcore/HttpCoreNIOServer.java
    httpcomponents/httpcore/trunk/httpcore-benchmark/src/main/java/org/apache/http/benchmark/httpcore/NHttpListener.java
    httpcomponents/httpcore/trunk/httpcore-benchmark/src/main/java/org/apache/http/benchmark/jetty/JettyNIOServer.java
    httpcomponents/httpcore/trunk/httpcore-benchmark/src/main/java/org/apache/http/benchmark/jetty/JettyServer.java

Modified: httpcomponents/httpcore/trunk/httpcore-benchmark/src/main/java/org/apache/http/benchmark/Benchmark.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-benchmark/src/main/java/org/apache/http/benchmark/Benchmark.java?rev=912533&r1=912532&r2=912533&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-benchmark/src/main/java/org/apache/http/benchmark/Benchmark.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore-benchmark/src/main/java/org/apache/http/benchmark/Benchmark.java
Mon Feb 22 11:10:29 2010
@@ -60,7 +60,7 @@
             CommandLineUtils.parseCommandLine(cmd, config);
         } else {
             config.setKeepAlive(true);
-            config.setRequests(10000);
+            config.setRequests(20000);
             config.setThreads(25);
         }
         

Modified: httpcomponents/httpcore/trunk/httpcore-benchmark/src/main/java/org/apache/http/benchmark/httpcore/HttpCoreNIOServer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-benchmark/src/main/java/org/apache/http/benchmark/httpcore/HttpCoreNIOServer.java?rev=912533&r1=912532&r2=912533&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-benchmark/src/main/java/org/apache/http/benchmark/httpcore/HttpCoreNIOServer.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore-benchmark/src/main/java/org/apache/http/benchmark/httpcore/HttpCoreNIOServer.java
Mon Feb 22 11:10:29 2010
@@ -53,12 +53,14 @@
 
 public class HttpCoreNIOServer implements HttpServer {
 
+    private final int port;
     private final NHttpListener listener;
     
     public HttpCoreNIOServer(int port) throws IOException {
         if (port <= 0) {
             throw new IllegalArgumentException("Server port may not be negative or null");
         }
+        this.port = port;
         
         HttpParams params = new SyncBasicHttpParams();
         params
@@ -85,8 +87,6 @@
         handler.setHandlerResolver(reqistry);
 
         ListeningIOReactor ioreactor = new DefaultListeningIOReactor(2, params);
-        ioreactor.listen(new InetSocketAddress(port));
-        
         IOEventDispatch ioEventDispatch = new DefaultServerIOEventDispatch(handler, params);
         this.listener = new NHttpListener(ioreactor, ioEventDispatch);
     }
@@ -103,6 +103,7 @@
 
     public void start() throws Exception {
         this.listener.start();
+        this.listener.listen(new InetSocketAddress(this.port));
     }
     
     public void shutdown() {

Modified: httpcomponents/httpcore/trunk/httpcore-benchmark/src/main/java/org/apache/http/benchmark/httpcore/NHttpListener.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-benchmark/src/main/java/org/apache/http/benchmark/httpcore/NHttpListener.java?rev=912533&r1=912532&r2=912533&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-benchmark/src/main/java/org/apache/http/benchmark/httpcore/NHttpListener.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore-benchmark/src/main/java/org/apache/http/benchmark/httpcore/NHttpListener.java
Mon Feb 22 11:10:29 2010
@@ -27,19 +27,22 @@
 package org.apache.http.benchmark.httpcore;
 
 import java.io.IOException;
+import java.net.InetSocketAddress;
 
 import org.apache.http.nio.reactor.IOEventDispatch;
-import org.apache.http.nio.reactor.IOReactor;
+import org.apache.http.nio.reactor.ListenerEndpoint;
+import org.apache.http.nio.reactor.ListeningIOReactor;
 
 public class NHttpListener extends Thread {
 
-    private final IOReactor ioreactor;
+    private final ListeningIOReactor ioreactor;
     private final IOEventDispatch ioEventDispatch;
-
+    
     private volatile Exception exception;
     
     public NHttpListener(
-            final IOReactor ioreactor, final IOEventDispatch ioEventDispatch) throws IOException
{
+            final ListeningIOReactor ioreactor, 
+            final IOEventDispatch ioEventDispatch) throws IOException {
         super();
         this.ioreactor = ioreactor;
         this.ioEventDispatch = ioEventDispatch;
@@ -54,6 +57,11 @@
         }
     }
 
+    public void listen(final InetSocketAddress address) throws InterruptedException {
+        ListenerEndpoint endpoint = this.ioreactor.listen(address);
+        endpoint.waitFor();
+    }
+    
     public void terminate() {
         try {
             this.ioreactor.shutdown();

Modified: httpcomponents/httpcore/trunk/httpcore-benchmark/src/main/java/org/apache/http/benchmark/jetty/JettyNIOServer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-benchmark/src/main/java/org/apache/http/benchmark/jetty/JettyNIOServer.java?rev=912533&r1=912532&r2=912533&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-benchmark/src/main/java/org/apache/http/benchmark/jetty/JettyNIOServer.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore-benchmark/src/main/java/org/apache/http/benchmark/jetty/JettyNIOServer.java
Mon Feb 22 11:10:29 2010
@@ -32,6 +32,7 @@
 import org.apache.http.benchmark.HttpServer;
 import org.eclipse.jetty.server.Server;
 import org.eclipse.jetty.server.nio.SelectChannelConnector;
+import org.eclipse.jetty.util.thread.QueuedThreadPool;
 
 public class JettyNIOServer implements HttpServer {
 
@@ -47,9 +48,15 @@
         connector.setPort(port);
         connector.setRequestBufferSize(12 * 1024);
         connector.setResponseBufferSize(12 * 1024);
+        connector.setAcceptors(2);
+        
+        QueuedThreadPool threadpool = new QueuedThreadPool();
+        threadpool.setMinThreads(25);
+        threadpool.setMaxThreads(200);
         
         this.server = new Server();
         this.server.addConnector(connector);
+        this.server.setThreadPool(threadpool);
         this.server.setHandler(new RandomDataHandler());
     }
     

Modified: httpcomponents/httpcore/trunk/httpcore-benchmark/src/main/java/org/apache/http/benchmark/jetty/JettyServer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-benchmark/src/main/java/org/apache/http/benchmark/jetty/JettyServer.java?rev=912533&r1=912532&r2=912533&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-benchmark/src/main/java/org/apache/http/benchmark/jetty/JettyServer.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore-benchmark/src/main/java/org/apache/http/benchmark/jetty/JettyServer.java
Mon Feb 22 11:10:29 2010
@@ -32,6 +32,7 @@
 import org.apache.http.benchmark.HttpServer;
 import org.eclipse.jetty.server.Server;
 import org.eclipse.jetty.server.bio.SocketConnector;
+import org.eclipse.jetty.util.thread.QueuedThreadPool;
 
 public class JettyServer implements HttpServer {
 
@@ -47,9 +48,15 @@
         connector.setPort(port);
         connector.setRequestBufferSize(12 * 1024);
         connector.setResponseBufferSize(12 * 1024);
+        connector.setAcceptors(2);
+        
+        QueuedThreadPool threadpool = new QueuedThreadPool();
+        threadpool.setMinThreads(25);
+        threadpool.setMaxThreads(200);
         
         this.server = new Server();
         this.server.addConnector(connector);
+        this.server.setThreadPool(threadpool);
         this.server.setHandler(new RandomDataHandler());
     }
     



Mime
View raw message