Posts

Showing posts with the label jmh

Benchmarking Object Pools

Last year, I wanted to benchmark different object pool implementations and I started writing a JMH benchmark for Object Pools . However, it took some time for me to write the Python scripts to visualize the results. Few months ago, I started learning Python and I could finally write Python to scripts to analyze and visualize results from CSV files. This is a great achievement for me and I could finally publish the results in a medium story: Benchmarking Object Pools.

Benchmarking Java Locks with Counters

Image
These days I am analyzing some Java Flight Recordings from taken from WSO2 API Manager performance tests and I found out that main processing threads were in "BLOCKED" state in some situations. The threads were mainly blocked due to "synchronized" methods in Java. Synchronizing the methods in a critical section of request processing causes bottlenecks and it has an impact on the throughput and overall latency. Then I was thinking whether we could avoid synchronizing the whole method. The main problem with synchronized is that only one thread can run that critical section. When it comes to consumer/producer scenarios, we may need to give read access to data in some threads and write access to a thread to edit data exclusively. Java provides ReadWriteLock for these kinds of scenarios. Java 8 provides another kind of lock named StampedLock . The StampedLock provides an alternative way to the standard  ReadWriteLock  and it also supports optimistic...