[DBCP]a question about ManualPoolingDriverExample

2013-09-29 Thread Li Li
hi all
I am using DBCP as a connection pool using codes like
http://svn.apache.org/repos/asf/commons/proper/dbcp/branches/DBCP_1_3_x_BRANCH/doc/ManualPoolingDriverExample.java

   there is a line:  PoolableConnectionFactory
poolableConnectionFactory = new
PoolableConnectionFactory(connectionFactory,connectionPool,null,null,false,true);

   it creates a PoolableConnectionFactory but never use it.

   do I need add this? connectionPool.setFactory(poolableConnectionFactory);

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



commons pool benchmark issue

2013-09-29 Thread Daniel Wu
Hi guys,I wrote a simple test for commons-pool. The result shows that the performance drops dramatically when concurrent threads increase. e.g, With 50 threads, the throughput is 603326 transactions per second, when threads increase to 600, the throughput drops to 32797. The diagram below is the response time in milliseconds, you can see as the threads increase, the response time grows quickly.I guess my benchmark test code must have something wrong, could you guys help me review the test code below and figure out what's wrong with my test code?public class BenchmarkCommons {  public BenchmarkCommons(int workerCount, int loop) throws Exception {double[] statsAvgRespTime = new double[workerCount];CountDownLatch latch = new CountDownLatch(workerCount);GenericObjectPool pool = new GenericObjectPool(new PoolableObjectFactory() {  @Override  public Object makeObject() throws Exception {return new StringBuilder();  }  @Override  public void destroyObject(Object o) throws Exception {  }  @Override  public boolean validateObject(Object o) {return true;  }  @Override  public void activateObject(Object o) throws Exception {  }  @Override  public void passivateObject(Object o) throws Exception {  }});pool.setMinIdle(25);pool.setMaxIdle(50);pool.setMaxActive(50);Worker[] workers = new Worker[workerCount];for (int i = 0; i  workerCount; i++) {  workers[i] = new Worker(i, pool, latch, loop, statsAvgRespTime);}long t1 = System.currentTimeMillis();for (int i = 0; i  workerCount; i++) {  workers[i].start();}latch.await();long t2 = System.currentTimeMillis();double stats = 0;for (int i = 0; i  workerCount; i++) {  stats += statsAvgRespTime[i];}System.out.println("Average Response Time:" + new DecimalFormat("0").format(stats / workerCount));System.out.println("Average Througput Per Second:" + new DecimalFormat("0").format(( (double) loop * workerCount * 1000 ) / (t2 - t1) ));  }  private static class Worker extends Thread {private final int id;private final GenericObjectPool pool;private final CountDownLatch latch;private final int loop;private final double[] statsAvgRespTime;public Worker(int id, GenericObjectPool pool, CountDownLatch latch, int loop, double[] statsAvgRespTime) {  this.id = id;  this.pool = pool;  this.latch = latch;  this.loop = loop;  this.statsAvgRespTime = statsAvgRespTime;}@Override public void run() {  long t1 = System.currentTimeMillis();  for (int i = 0; i  loop; i++) {StringBuilder obj = null;try {  obj = (StringBuilder) pool.borrowObject();  obj.append("x");} catch (Exception e) {  e.printStackTrace();} finally {  if (obj != null) {try {  pool.returnObject(obj);} catch (Exception e) {  e.printStackTrace();}  }}  }  long t2 = System.currentTimeMillis();  statsAvgRespTime[id] = ((double) (t2 - t1)) / loop;  latch.countDown();}  }  public static void main(String[] args) throws Exception {System.out.println("---warm up");new BenchmarkCommons(50, 100);System.out.println("Apache commons pool test---");new BenchmarkCommons(50, 50);new BenchmarkCommons(100, 50);new BenchmarkCommons(150, 30);new BenchmarkCommons(200, 30);new BenchmarkCommons(250, 10);new BenchmarkCommons(300, 10);new BenchmarkCommons(350, 5);new BenchmarkCommons(400, 5);new BenchmarkCommons(450, 2);new BenchmarkCommons(500, 2);new BenchmarkCommons(550, 1);new BenchmarkCommons(600, 1);  }}Regards,Daniel Wu

[dbcp] GenericObjectPool.borrowObject: Timeout waiting for idle object

2013-09-29 Thread Bosio Andrea
Hello all,

I'm getting the following exception, using commons-dbcp-1.4.

Caused by: java.util.NoSuchElementException: Timeout waiting for idle object
 at 
org.apache.commons.pool.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:1144)
 ~[commons-pool-1.5.5.jar:1.5.5]
 at 
org.apache.commons.dbcp.PoolingDataSource.getConnection(PoolingDataSource.java:106)
 ~[commons-dbcp-1.4.jar:1.4]
 ... 62 common frames omitted

Connections are managed by spring. These are the dbcp config parameters:

poolPreparedStatements=true
defaultAutoCommit=false
driverClassName=oracle.jdbc.driver.OracleDriver
validationQuery=select 0 from dual
initialSize=1
maxActive=15
maxIdle=15
maxWait=6
removeAbandoned=false
removeAbandonedTimeout=300

On the database (oracle) I see no active connections when the problem occurs, 
and sometimes a few inactive connections (5 connections).

I got an heap dump, and found that the ConnectionPool object (instance of 
org.apache.commons.pool.impl.GenericObjectPool) numActive variable value is 15, 
so I understand that the connection pool thinks that there are 15 active 
connections.
I can't understand why this happen, because on the database there aren't so 
many connections.

On the heap dump, another thing is strange: the ConnectionPool object variable 
pool, which as far I understand is the list of the connections managed by the 
pool, contains no element!

Bye,
Andrea



Andrea Bosio
Manager

Technology Reply
Via Cardinal Massaia, 71
10147 - Torino - ITALY
phone: +39 011 29100
mobile: +39 348 9504513
a.bo...@reply.it
www.reply.it

[Technology Reply]




--
The information transmitted is intended for the person or entity to which it is 
addressed and may contain confidential and/or privileged material. Any review, 
retransmission, dissemination or other use of, or taking of any action in 
reliance upon, this information by persons or entities other than the intended 
recipient is prohibited. If you received this in error, please contact the 
sender and delete the material from any computer.


Re: [DBCP]a question about ManualPoolingDriverExample

2013-09-29 Thread Phil Steitz
Good question, Li Li.  The answer is no, this is done by the
PoolableConnectionFactory constructor.  You can see that in the
source here:
http://svn.apache.org/repos/asf/commons/proper/dbcp/branches/DBCP_1_3_x_BRANCH/src/java/org/apache/commons/dbcp/PoolableConnectionFactory.java.

Phil

On 9/28/13 10:09 PM, Li Li wrote:
 hi all
 I am using DBCP as a connection pool using codes like
 http://svn.apache.org/repos/asf/commons/proper/dbcp/branches/DBCP_1_3_x_BRANCH/doc/ManualPoolingDriverExample.java

there is a line:  PoolableConnectionFactory
 poolableConnectionFactory = new
 PoolableConnectionFactory(connectionFactory,connectionPool,null,null,false,true);

it creates a PoolableConnectionFactory but never use it.

do I need add this? connectionPool.setFactory(poolableConnectionFactory);

 -
 To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
 For additional commands, e-mail: user-h...@commons.apache.org




-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: commons pool benchmark issue

2013-09-29 Thread Phil Steitz
On 9/28/13 11:50 PM, Daniel Wu wrote:
 Hi guys,

 I wrote a simple test for commons-pool. The result shows that the
 performance drops dramatically when concurrent threads increase.
 e.g, With 50 threads, the throughput is 603326 transactions per
 second, when threads increase to 600, the throughput drops to
 32797. The diagram below is the response time in milliseconds,
 you can see as the threads increase, the response time grows quickly.



 I guess my benchmark test code must have something wrong, could
 you guys help me review the test code below and figure out what's
 wrong with my test code?


 public class BenchmarkCommons {

 public BenchmarkCommons(int workerCount, int loop) throws
 Exception {
 double[] statsAvgRespTime = new double[workerCount];
 CountDownLatch latch = new CountDownLatch(workerCount);

 GenericObjectPool pool = new GenericObjectPool(new
 PoolableObjectFactory() {
 @Override
 public Object makeObject() throws Exception {
 return new StringBuilder();
 }
 @Override
 public void destroyObject(Object o) throws Exception {
 }
 @Override
 public boolean validateObject(Object o) {
 return true;
 }
 @Override
 public void activateObject(Object o) throws Exception {
 }
 @Override
 public void passivateObject(Object o) throws Exception {
 }
 });
 pool.setMinIdle(25);
 pool.setMaxIdle(50);
 pool.setMaxActive(50);

 Worker[] workers = new Worker[workerCount];
 for (int i = 0; i  workerCount; i++) {
 workers[i] = new Worker(i, pool, latch, loop,
 statsAvgRespTime);
 }
 long t1 = System.currentTimeMillis();
 for (int i = 0; i  workerCount; i++) {
 workers[i].start();
 }
 latch.await();
 long t2 = System.currentTimeMillis();
 double stats = 0;
 for (int i = 0; i  workerCount; i++) {
 stats += statsAvgRespTime[i];
 }
 System.out.println(Average Response Time: + new
 DecimalFormat(0).format(stats / workerCount));
 System.out.println(Average Througput Per Second: + new
 DecimalFormat(0).format(( (double) loop * workerCount * 1000 )
 / (t2 - t1) ));
 }

 private static class Worker extends Thread {

 private final int id;
 private final GenericObjectPool pool;
 private final CountDownLatch latch;
 private final int loop;
 private final double[] statsAvgRespTime;

 public Worker(int id, GenericObjectPool pool,
 CountDownLatch latch, int loop, double[] statsAvgRespTime) {
 this.id = id;
 this.pool = pool;
 this.latch = latch;
 this.loop = loop;
 this.statsAvgRespTime = statsAvgRespTime;
 }

 @Override public void run() {
 long t1 = System.currentTimeMillis();
 for (int i = 0; i  loop; i++) {
 StringBuilder obj = null;
 try {
 obj = (StringBuilder) pool.borrowObject();
 obj.append(x);
 } catch (Exception e) {
 e.printStackTrace();
 } finally {
 if (obj != null) {
 try {
 pool.returnObject(obj);
 } catch (Exception e) {
 e.printStackTrace();
 }
 }
 }
 }
 long t2 = System.currentTimeMillis();
 statsAvgRespTime[id] =  ((double) (t2 - t1)) / loop;
 latch.countDown();
 }
 }

 public static void main(String[] args) throws Exception {
 System.out.println(---warm up);
 new BenchmarkCommons(50,  100);
 System.out.println(Apache commons pool
 test---);
 new BenchmarkCommons(50,  50);
 new BenchmarkCommons(100, 50);
 new BenchmarkCommons(150, 30);
 new BenchmarkCommons(200, 30);
 new BenchmarkCommons(250, 10);
 new BenchmarkCommons(300, 10);
 new BenchmarkCommons(350, 5);
 new BenchmarkCommons(400, 5);
 new BenchmarkCommons(450, 2);
 new BenchmarkCommons(500, 2);
 new BenchmarkCommons(550, 1);
 new BenchmarkCommons(600, 1);
 }

 }


First some questions, then some observations.

0) What version of Commons Pool are you running?
1) How many physical CPU cores does the machine you are using to run
the test have?

Now some observations:

2) To measure the performance of the pool itself, you should time
the borrows and returns, not the full loop including the client action
3) With a 

Re: [dbcp] GenericObjectPool.borrowObject: Timeout waiting for idle object

2013-09-29 Thread Phil Steitz
On 9/29/13 7:13 AM, Bosio Andrea wrote:

 Hello all,

 I’m getting the following exception, using commons-dbcp-1.4.

 Caused by: java.util.NoSuchElementException: Timeout waiting for
 idle object

 at
 org.apache.commons.pool.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:1144)
 ~[commons-pool-1.5.5.jar:1.5.5]

 at
 org.apache.commons.dbcp.PoolingDataSource.getConnection(PoolingDataSource.java:106)
 ~[commons-dbcp-1.4.jar:1.4]

 ... 62 common frames omitted

 Connections are managed by spring. These are the dbcp config
 parameters:

 poolPreparedStatements=true

 defaultAutoCommit=false

 driverClassName=oracle.jdbc.driver.OracleDriver

 validationQuery=select 0 from dual

 initialSize=1

 maxActive=15

 maxIdle=15

 maxWait=6

 removeAbandoned=false

 removeAbandonedTimeout=300

 On the database (oracle) I see no active connections when the
 problem occurs, and sometimes a few inactive connections (5
 connections).

 I got an heap dump, and found that the ConnectionPool object
 (instance of org.apache.commons.pool.impl.GenericObjectPool)
 numActive variable value is 15, so I understand that the
 connection pool thinks that there are 15 active connections.

 I can’t understand why this happen, because on the database there
 aren’t so many connections.

 On the heap dump, another thing is strange: the ConnectionPool
 object variable “pool”, which as far I understand is the list of
 the connections managed by the pool, contains no element!


The most likely explanation for this is that connections checked out
from the pool are being abandoned by client threads - i.e., never
returned via the close() method. The first thing to check is that on
all code execution paths (including exceptions), the connections
borrowed from the pool are being closed. You can turn on abandoned
connection removal and logging to verify that this is not happening.
If turning on abandoned connection removal makes the problem go
away, you should still find and fix the code paths that abandon
connections.

Unless client threads are being interrupted, this will not likely
fix anything, but you can try upgrading to version 1.5.7 of Commons
Pool.

Phil

 Bye,
 Andrea



 Andrea Bosio
 Manager

 Technology Reply
 Via Cardinal Massaia, 71
 10147 - Torino - ITALY
 phone: +39 011 29100
 mobile: +39 348 9504513
 a.bo...@reply.it
 www.reply.it

 Technology Reply


 

 --
 The information transmitted is intended for the person or entity
 to which it is addressed and may contain confidential and/or
 privileged material. Any review, retransmission, dissemination or
 other use of, or taking of any action in reliance upon, this
 information by persons or entities other than the intended
 recipient is prohibited. If you received this in error, please
 contact the sender and delete the material from any computer.


-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [dbcp] GenericObjectPool.borrowObject: Timeout waiting for idle object

2013-09-29 Thread James Carman
Try running FindBugs on your code (using something like Sonar or an
IDE plugin).  The rules you're going to be looking for would be these:

http://findbugs.sourceforge.net/bugDescriptions.html#ODR_OPEN_DATABASE_RESOURCE


On Sun, Sep 29, 2013 at 12:41 PM, Phil Steitz phil.ste...@gmail.com wrote:
 On 9/29/13 7:13 AM, Bosio Andrea wrote:

 Hello all,

 I’m getting the following exception, using commons-dbcp-1.4.

 Caused by: java.util.NoSuchElementException: Timeout waiting for
 idle object

 at
 org.apache.commons.pool.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:1144)
 ~[commons-pool-1.5.5.jar:1.5.5]

 at
 org.apache.commons.dbcp.PoolingDataSource.getConnection(PoolingDataSource.java:106)
 ~[commons-dbcp-1.4.jar:1.4]

 ... 62 common frames omitted

 Connections are managed by spring. These are the dbcp config
 parameters:

 poolPreparedStatements=true

 defaultAutoCommit=false

 driverClassName=oracle.jdbc.driver.OracleDriver

 validationQuery=select 0 from dual

 initialSize=1

 maxActive=15

 maxIdle=15

 maxWait=6

 removeAbandoned=false

 removeAbandonedTimeout=300

 On the database (oracle) I see no active connections when the
 problem occurs, and sometimes a few inactive connections (5
 connections).

 I got an heap dump, and found that the ConnectionPool object
 (instance of org.apache.commons.pool.impl.GenericObjectPool)
 numActive variable value is 15, so I understand that the
 connection pool thinks that there are 15 active connections.

 I can’t understand why this happen, because on the database there
 aren’t so many connections.

 On the heap dump, another thing is strange: the ConnectionPool
 object variable “pool”, which as far I understand is the list of
 the connections managed by the pool, contains no element!


 The most likely explanation for this is that connections checked out
 from the pool are being abandoned by client threads - i.e., never
 returned via the close() method. The first thing to check is that on
 all code execution paths (including exceptions), the connections
 borrowed from the pool are being closed. You can turn on abandoned
 connection removal and logging to verify that this is not happening.
 If turning on abandoned connection removal makes the problem go
 away, you should still find and fix the code paths that abandon
 connections.

 Unless client threads are being interrupted, this will not likely
 fix anything, but you can try upgrading to version 1.5.7 of Commons
 Pool.

 Phil

 Bye,
 Andrea



 Andrea Bosio
 Manager

 Technology Reply
 Via Cardinal Massaia, 71
 10147 - Torino - ITALY
 phone: +39 011 29100
 mobile: +39 348 9504513
 a.bo...@reply.it
 www.reply.it

 Technology Reply


 

 --
 The information transmitted is intended for the person or entity
 to which it is addressed and may contain confidential and/or
 privileged material. Any review, retransmission, dissemination or
 other use of, or taking of any action in reliance upon, this
 information by persons or entities other than the intended
 recipient is prohibited. If you received this in error, please
 contact the sender and delete the material from any computer.


 -
 To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
 For additional commands, e-mail: user-h...@commons.apache.org


-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: commons pool benchmark issue

2013-09-29 Thread Daniel Wu
Hi Phil,

Thanks for your reply

1) CP Version: I tried both 1.5.5 and 1.6.0, same results. 
2) My machine is a 2010-mid iMac, 3.2GHz i3 with 4 cores, 16G RAM, jdk 1.7u40
3) I don't think StringBuilder is a problem, my profiler tool shows that GC is 
not frequent, there is no memory pressure. But the tool shows that most of the 
time are consumed at pool locking.

-- 
Daniel Wu
Sent with Sparrow (http://www.sparrowmailapp.com/?sig)


On Monday, September 30, 2013 at 12:25 AM, Phil Steitz wrote:

 On 9/28/13 11:50 PM, Daniel Wu wrote:
   Hi guys,
   
   I wrote a simple test for commons-pool. The result shows that the
   performance drops dramatically when concurrent threads increase.
   e.g, With 50 threads, the throughput is 603326 transactions per
   second, when threads increase to 600, the throughput drops to
   32797. The diagram below is the response time in milliseconds,
   you can see as the threads increase, the response time grows quickly.
   
   
   
   I guess my benchmark test code must have something wrong, could
   you guys help me review the test code below and figure out what's
   wrong with my test code?
   
   
   public class BenchmarkCommons {
   
   public BenchmarkCommons(int workerCount, int loop) throws
   Exception {
   double[] statsAvgRespTime = new double[workerCount];
   CountDownLatch latch = new CountDownLatch(workerCount);
   
   GenericObjectPool pool = new GenericObjectPool(new
   PoolableObjectFactory() {
   @Override
   public Object makeObject() throws Exception {
   return new StringBuilder();
   }
   @Override
   public void destroyObject(Object o) throws Exception {
   }
   @Override
   public boolean validateObject(Object o) {
   return true;
   }
   @Override
   public void activateObject(Object o) throws Exception {
   }
   @Override
   public void passivateObject(Object o) throws Exception {
   }
   });
   pool.setMinIdle(25);
   pool.setMaxIdle(50);
   pool.setMaxActive(50);
   
   Worker[] workers = new Worker[workerCount];
   for (int i = 0; i  workerCount; i++) {
   workers[i] = new Worker(i, pool, latch, loop,
   statsAvgRespTime);
   }
   long t1 = System.currentTimeMillis();
   for (int i = 0; i  workerCount; i++) {
   workers[i].start();
   }
   latch.await();
   long t2 = System.currentTimeMillis();
   double stats = 0;
   for (int i = 0; i  workerCount; i++) {
   stats += statsAvgRespTime[i];
   }
   System.out.println(Average Response Time: + new
   DecimalFormat(0).format(stats / workerCount));
   System.out.println(Average Througput Per Second: + new
   DecimalFormat(0).format(( (double) loop * workerCount * 1000 )
   / (t2 - t1) ));
   }
   
   private static class Worker extends Thread {
   
   private final int id;
   private final GenericObjectPool pool;
   private final CountDownLatch latch;
   private final int loop;
   private final double[] statsAvgRespTime;
   
   public Worker(int id, GenericObjectPool pool,
   CountDownLatch latch, int loop, double[] statsAvgRespTime) {
   this.id = id;
   this.pool = pool;
   this.latch = latch;
   this.loop = loop;
   this.statsAvgRespTime = statsAvgRespTime;
   }
   
   @Override public void run() {
   long t1 = System.currentTimeMillis();
   for (int i = 0; i  loop; i++) {
   StringBuilder obj = null;
   try {
   obj = (StringBuilder) pool.borrowObject();
   obj.append(x);
   } catch (Exception e) {
   e.printStackTrace();
   } finally {
   if (obj != null) {
   try {
   pool.returnObject(obj);
   } catch (Exception e) {
   e.printStackTrace();
   }
   }
   }
   }
   long t2 = System.currentTimeMillis();
   statsAvgRespTime[id] = ((double) (t2 - t1)) / loop;
   latch.countDown();
   }
   }
   
   public static void main(String[] args) throws Exception {
   System.out.println(---warm up);
   new BenchmarkCommons(50, 100);
   System.out.println(Apache commons pool
   test---);
   new BenchmarkCommons(50, 50);
   new BenchmarkCommons(100, 50);
   new BenchmarkCommons(150, 30);
   new BenchmarkCommons(200, 30);
   new BenchmarkCommons(250, 10);
   new BenchmarkCommons(300, 10);
   new BenchmarkCommons(350, 5);
   new BenchmarkCommons(400, 5);
   new BenchmarkCommons(450, 2);
   new BenchmarkCommons(500, 2);
   new BenchmarkCommons(550, 1);
   new BenchmarkCommons(600, 1);
   }
   
   }
 
 First some questions, then some observations.
 
 0) What version of Commons Pool are you running?
 1) How many physical CPU cores does the machine you are using to run
 the test have?
 
 Now some observations:
 
 2) To measure the performance of the pool itself, you should time
 the borrows and returns, not the full loop including the client action
 3) With a large number of threads, the StringBuilders are going to
 start to get big. You could be running into delays managing these
 buffers.
 
 If the answer to 1) above is only a few, you could be running into
 thread scheduling delays. That together with churn caused by 3)
 could be 

Re: commons pool benchmark issue

2013-09-29 Thread Phil Steitz
On 9/29/13 6:23 PM, Daniel Wu wrote:
 Hi Phil,

 Thanks for your reply

 1) CP Version: I tried both 1.5.5 and 1.6.0, same results. 
 2) My machine is a 2010-mid iMac, 3.2GHz i3 with 4 cores, 16G RAM, jdk 1.7u40
 3) I don't think StringBuilder is a problem, my profiler tool shows that GC 
 is not frequent, there is no memory pressure. But the tool shows that most of 
 the time are consumed at pool locking.

Did you try to run it without the pool?

Did you try timing just the pool operations?

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: commons pool benchmark issue

2013-09-29 Thread Daniel Wu
Without the pool, it's lightning fast. JProfiler shows most of the time is 
consumed on locking, thread dump also shows the pool always waits.
I tried to timing the pool operations, the results proved the JProfiler reports

e,g. with 50 threads, the log shows
Average Response Time:0.06
Average Borrow Time:0.04
Average Return Time:0.02

So, the time are consumed with StringBuilder and GC is negligible, most of the 
time are wasted in pool locking.

With 100 threads, the log shows
Average Response Time:1.24
Average Borrow Time:0.90
Average Return Time:0.34

The more threads try to content with the pool, the slower the pool is.

I kind of believe CP is just slow.

-- 
Daniel Wu
Sent with Sparrow (http://www.sparrowmailapp.com/?sig)


On Monday, September 30, 2013 at 10:02 AM, Phil Steitz wrote:

 On 9/29/13 6:23 PM, Daniel Wu wrote:
  Hi Phil,
  
  Thanks for your reply
  
  1) CP Version: I tried both 1.5.5 and 1.6.0, same results. 
  2) My machine is a 2010-mid iMac, 3.2GHz i3 with 4 cores, 16G RAM, jdk 
  1.7u40
  3) I don't think StringBuilder is a problem, my profiler tool shows that GC 
  is not frequent, there is no memory pressure. But the tool shows that most 
  of the time are consumed at pool locking.
  
 
 Did you try to run it without the pool?
 
 Did you try timing just the pool operations?
 
 -
 To unsubscribe, e-mail: user-unsubscr...@commons.apache.org 
 (mailto:user-unsubscr...@commons.apache.org)
 For additional commands, e-mail: user-h...@commons.apache.org 
 (mailto:user-h...@commons.apache.org)
 
 




Re: commons pool benchmark issue

2013-09-29 Thread Phil Steitz
On 9/29/13 7:35 PM, Daniel Wu wrote:
 Without the pool, it's lightning fast. JProfiler shows most of the time is 
 consumed on locking, thread dump also shows the pool always waits.
 I tried to timing the pool operations, the results proved the JProfiler 
 reports

 e,g. with 50 threads, the log shows
 Average Response Time:0.06
 Average Borrow Time:0.04
 Average Return Time:0.02

 So, the time are consumed with StringBuilder and GC is negligible, most of 
 the time are wasted in pool locking.

 With 100 threads, the log shows
 Average Response Time:1.24
 Average Borrow Time:0.90
 Average Return Time:0.34

 The more threads try to content with the pool, the slower the pool is.

 I kind of believe CP is just slow.

What happens when you replace the append with a no-op?

Phil

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: commons pool benchmark issue

2013-09-29 Thread Daniel Wu
I removed the line obj.append(x), so the worker threads simple borrow and 
return. 
Same result, StringBuilder and GC are negligible.

-- 
Daniel Wu
Sent with Sparrow (http://www.sparrowmailapp.com/?sig)


On Monday, September 30, 2013 at 12:04 PM, Phil Steitz wrote:

 On 9/29/13 7:35 PM, Daniel Wu wrote:
  Without the pool, it's lightning fast. JProfiler shows most of the time is 
  consumed on locking, thread dump also shows the pool always waits.
  I tried to timing the pool operations, the results proved the JProfiler 
  reports
  
  e,g. with 50 threads, the log shows
  Average Response Time:0.06
  Average Borrow Time:0.04
  Average Return Time:0.02
  
  So, the time are consumed with StringBuilder and GC is negligible, most of 
  the time are wasted in pool locking.
  
  With 100 threads, the log shows
  Average Response Time:1.24
  Average Borrow Time:0.90
  Average Return Time:0.34
  
  The more threads try to content with the pool, the slower the pool is.
  
  I kind of believe CP is just slow.
 What happens when you replace the append with a no-op?
 
 Phil
 
 -
 To unsubscribe, e-mail: user-unsubscr...@commons.apache.org 
 (mailto:user-unsubscr...@commons.apache.org)
 For additional commands, e-mail: user-h...@commons.apache.org 
 (mailto:user-h...@commons.apache.org)