Github user franz1981 commented on the issue:
https://github.com/apache/activemq-artemis/pull/1752
@michaelandrepearce @clebertsuconic
As promised I've provided a benchmark that can be run with ease directly
from the IDE:
https://github.com/franz1981/activemq-artemis/tree/jmh_interner_benchmarks
The benchmark is this one:
https://github.com/franz1981/activemq-artemis/blob/3e0b4b8152bed30ba747704a653d0c034ebe19d5/tests/performance-tests/src/test/java/org/apache/activemq/artemis/tests/performance/jmh/pool/SimpleStringInternerBenchmark.java
Some of results of my box:
```
Benchmark
Mode Cnt Score Error Units
SimpleStringInternerBenchmark.artemisIntern
thrpt 10 15509306.132 ± 568180.609 ops/s
SimpleStringInternerBenchmark.artemisIntern:·gc.alloc.rate
thrpt 10 â 10â»â´ MB/sec
SimpleStringInternerBenchmark.artemisIntern:·gc.alloc.rate.norm
thrpt 10 â 10â»âµ B/op
SimpleStringInternerBenchmark.artemisIntern:·gc.count
thrpt 10 â 0 counts
SimpleStringInternerBenchmark.artemisIntern3Threads
thrpt 10 44734165.507 ± 1868110.790 ops/s
SimpleStringInternerBenchmark.artemisIntern3Threads:·gc.alloc.rate
thrpt 10 0.006 ± 0.016 MB/sec
SimpleStringInternerBenchmark.artemisIntern3Threads:·gc.alloc.rate.norm
thrpt 10 â 10â»â´ B/op
SimpleStringInternerBenchmark.artemisIntern3Threads:·gc.count
thrpt 10 â 0 counts
SimpleStringInternerBenchmark.guavaInterner
thrpt 10 6231479.494 ± 313670.700 ops/s
SimpleStringInternerBenchmark.guavaInterner:·gc.alloc.rate
thrpt 10 443.572 ± 22.292 MB/sec
SimpleStringInternerBenchmark.guavaInterner:·gc.alloc.rate.norm
thrpt 10 112.000 ± 0.001 B/op
SimpleStringInternerBenchmark.guavaInterner:·gc.churn.PS_Eden_Space
thrpt 10 445.183 ± 80.501 MB/sec
SimpleStringInternerBenchmark.guavaInterner:·gc.churn.PS_Eden_Space.norm
thrpt 10 112.375 ± 18.859 B/op
SimpleStringInternerBenchmark.guavaInterner:·gc.churn.PS_Survivor_Space
thrpt 10 0.073 ± 0.076 MB/sec
SimpleStringInternerBenchmark.guavaInterner:·gc.churn.PS_Survivor_Space.norm
thrpt 10 0.019 ± 0.020 B/op
SimpleStringInternerBenchmark.guavaInterner:·gc.count
thrpt 10 44.000 counts
SimpleStringInternerBenchmark.guavaInterner:·gc.time
thrpt 10 56.000 ms
SimpleStringInternerBenchmark.guavaInterner3Threads
thrpt 10 18200947.459 ± 933389.842 ops/s
SimpleStringInternerBenchmark.guavaInterner3Threads:·gc.alloc.rate
thrpt 10 1295.337 ± 66.617 MB/sec
SimpleStringInternerBenchmark.guavaInterner3Threads:·gc.alloc.rate.norm
thrpt 10 112.000 ± 0.001 B/op
SimpleStringInternerBenchmark.guavaInterner3Threads:·gc.churn.PS_Eden_Space
thrpt 10 1323.335 ± 234.954 MB/sec
SimpleStringInternerBenchmark.guavaInterner3Threads:·gc.churn.PS_Eden_Space.norm
thrpt 10 114.500 ± 20.365 B/op
SimpleStringInternerBenchmark.guavaInterner3Threads:·gc.churn.PS_Survivor_Space
thrpt 10 0.081 ± 0.041 MB/sec
SimpleStringInternerBenchmark.guavaInterner3Threads:·gc.churn.PS_Survivor_Space.norm
thrpt 10 0.007 ± 0.003 B/op
SimpleStringInternerBenchmark.guavaInterner3Threads:·gc.count
thrpt 10 27.000 counts
SimpleStringInternerBenchmark.guavaInterner3Threads:·gc.time
thrpt 10 32.000 ms
```
Consider that It tests the case of temporal typed UUID-like SimpleString
interning/pooling, hence a pretty intensive case for the interner I've
implemented because it need to compute hashCode and equals of long strings (~
72 bytes).
Some explanation:
- score is the throughput in ops/sec
- `artemisIntern` is the one using `SimpleString.Interner`
- 'guavaInterner` is the one using the Guava Interner with weak References
(the strong one is not faster TBH, probably a little slower)
- the `3Threads` ones are testing 3 threads calling the interner
concurrently
The results are pretty clear: ~400 MB/sec of allocation rate vs 0 and a
much higher (~ x2,5) throughput (although most of the time is spent into
hashCode and equals computations).
I hope to have shown better why I've designed the interner in the way I've
done.
---