Switch to DoubleAdder for simpleclient, it's more performant. · feheraron/client_java@fa46c19 · GitHub
Skip to content

Commit fa46c19

Browse files
committed
Switch to DoubleAdder for simpleclient, it's more performant.
Add benchmarks for both of our java clients, and a comparison with codahale/yammer metrics. This is based on internal benchmarks by Will Fleury. Add caching of the Child when there's no labels. This is the most common use case, and makes it 4-5x faster than the naive approach. Performance comparison: Codehale(a popular java instrumention library) takes 12ns per increment of a counter uncontended, rising to 18ns with 4 threads The original client takes 126ns, rising to 245ns with 4 threads. Incrementing the child takes 13ns, rising to 382ns with 4 threads (odd - it should be <245ns). With theese changes the Simpleclient's performance goes from: - Uncontended labels() increment: 70ns -> 54ns - 2-thread labels() increment: 146ns -> 103ns - 4-thread labels() increment: 509ns -> 130ns - Uncontended Child increment: 29ns -> 13ns - 2-thread Child increment: 102ns -> 16ns - 4-thread Child increment: 215ns -> 19ns - Uncontended nolabels convenience increment: 50ns -> 13ns - 2-thread nolabels convenience increment: 172ns -> 17ns - 4-thread nolabels convenience increment: 434ns -> 20ns The new numbers are much faster, and comparable with codehale. ConcurrentHashMap doesn't seem great with lots of threads, avoiding that by caching the Child is advised where you have labels and a high rate of concurrent updates. I tested on a 2-core MacBook Pro with a 2.5GHz i5 processor, Oracle Java 64 1.7.0_51.
1 parent c650cad commit fa46c19

11 files changed

Lines changed: 985 additions & 36 deletions

File tree

benchmark/README.md

Lines changed: 150 additions & 0 deletions

benchmark/pom.xml

Lines changed: 106 additions & 0 deletions

0 commit comments

Comments
 (0)