Skip to content

Add option for stacktrace filling - #245

Closed
mad wants to merge 1 commit into
apache:masterfrom
mad:add-option-for-stacktrace-filling
Closed

Add option for stacktrace filling#245
mad wants to merge 1 commit into
apache:masterfrom
mad:add-option-for-stacktrace-filling

Conversation

@mad

@mad mad commented Sep 21, 2023

Copy link
Copy Markdown

Currently stacktrace filled by default but sometimes it is useless and affect on performance

@garydgregory

Copy link
Copy Markdown
Member

@mad
Thank for your PR. You'll need to add unit tests.

@psteitz Any thoughts?

@psteitz

psteitz commented Sep 21, 2023

Copy link
Copy Markdown
Contributor

I am not sure the added config complexity is worth it for this. Unless you are creating millions of pools, the performance impact of this is trivial. This code is run only once, when the pool is created. I am afraid that users would end up confused into thinking this was about pooled objects - basically needless cognitive load for 99.99% of users.

@garydgregory

garydgregory commented Sep 24, 2023

Copy link
Copy Markdown
Member

Closing, see above.

@mad

mad commented Sep 28, 2023

Copy link
Copy Markdown
Author

@garydgregory

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>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants