mad commented on PR #245:
URL: https://github.com/apache/commons-pool/pull/245#issuecomment-1739285348

   I'll try to explain why this is required.
   
   Some database have transactions; in transactions, entities are created that 
can be reused in case of multithreading (cursors). To minimize the number of 
cursors (and their creation), a pool of objects is used
   
   In the case of a large number of transactions, the cost of initializing the 
stack trace becomes noticeable. The external pool is not convenient to hold, 
because its lifetime is equal to the transaction lifetime
   
   Benchmark result 
(https://gist.github.com/mad/91e7b587cd7677ef04139d805219e318)
   
   ```
   Benchmark               (withStackTrace)   Mode  Cnt       Score   Error  
Units
   PoolBench.bench                     true  thrpt        87312.389          
ops/s
   PoolBench.bench:·stack              true  thrpt              NaN            
---
   PoolBench.bench                    false  thrpt       350373.113          
ops/s
   PoolBench.bench:·stack             false  thrpt              NaN            
---
   ```
   
   Profiling
   
   ```
   w/ stacktrace
   ....[Thread state: 
RUNNABLE]........................................................................
    25.0%  33.3% <stack is empty, everything is filtered?>
    25.0%  33.3% com.intellij.rt.execution.application.AppMainV2$1.run
    15.6%  20.9% 
org.apache.commons.pool3.impl.BaseGenericObjectPool.getStackTrace
     5.1%   6.8% 
org.apache.commons.pool3.impl.BaseGenericObjectPool$StatsStore.<init>
     2.8%   3.7% org.apache.commons.pool3.impl.BaseGenericObjectPool.<init>
     1.2%   1.6% 
org.apache.commons.pool3.impl.BaseGenericObjectPool.setEvictionPolicy
     0.1%   0.1% 
org.apache.commons.pool3.impl.LinkedBlockingDeque.interuptTakeWaiters
     0.0%   0.1% 
org.apache.commons.pool3.impl.BaseGenericObjectPool.setEvictionPolicyClassName
     0.0%   0.1% 
org.apache.commons.pool3.impl.BaseGenericObjectPool$StatsStore.lambda$new$0
     0.0%   0.0% com.bic.jmh.PoolBench.bench
     0.1%   0.1% <other>
   
   
   w/o stacktrace
   ....[Thread state: 
RUNNABLE]........................................................................
    25.0%  33.3% <stack is empty, everything is filtered?>
    25.0%  33.3% com.intellij.rt.execution.application.AppMainV2$1.run
    19.9%  26.5% 
org.apache.commons.pool3.impl.BaseGenericObjectPool$StatsStore.<init>
     4.0%   5.4% 
org.apache.commons.pool3.impl.BaseGenericObjectPool.setEvictionPolicy
     0.6%   0.9% com.bic.jmh.PoolBench.bench
     0.2%   0.3% 
org.apache.commons.pool3.impl.BaseGenericObjectPool.setEvictionPolicyClassName
     0.2%   0.2% 
org.apache.commons.pool3.impl.BaseGenericObjectPool$StatsStore.lambda$new$0
     0.0%   0.0% 
com.bic.jmh.generated.PoolBench_bench_jmhTest.bench_thrpt_jmhStub
     0.0%   0.0% org.apache.commons.pool3.impl.GenericObjectPoolConfig.<init>
     0.0%   0.0% org.apache.commons.pool3.impl.GenericObjectPool.<init>
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to