When visualizing time series with more data points than available on-screen pixels we waste system resources and network bandwidth without adding any value. Therefore, various algorithms are available to reduce the data volume. One such algorithm is Largest-Triangle-Three-Buckets (LTTB) described by Sveinn Steinarsson in his master’s thesis . The key idea of the algorithm is to preserve the…
I currently work on the backend of Elastic Universal Profiling , which is a fleet-wide continuous profiler. In our benchmarks we have observed higher than desired latency in a query that retrieves data for flamegraphs. As this is a key aspect of our product we wanted to better understand the root cause. CPU Profiling We started to gather CPU profiles with async-profiler in Wall-clock profiling…
I currently work on the backend of Elastic Univeral Profiling , which is a fleet-wide continuous profiler. At Elastic we live the concept of space-time , which means that we regularly get to experiment in a little bit similar vein to Google’s 20% time . Mostly recently, I’ve experimented with possibilities to either store less profiling data or query data in a way that allows us to…
I work for more than two years at Elastic where I focus on benchmarking, performance analysis and performance tuning for Elasticsearch. In my daily work, I have to deal with many people: our users, various of our engineering teams, support, consulting, marketing, sales, product management and our developer relations team. As you might imagine, these are a lot of balls to juggle. Structuring Work…
Did you know that every HotSpot-based JVM includes a profiler? You can activate it on the command line with -Xprof and it dumps its output to stdout. The information about it is pretty sparse, so I decided to write a short blog post about it. Getting Started Let’s dive right in with an example: public class Fibonacci { private static long fib(long n) { if (n <= 0) { throw new…
I admit it: I use noscript , I block trackers like Google Analytics and all sorts of ads. If you browse the web this way, you see strange things: in the best case layouts are completely broken but in some cases pages even do not show up. And no, I am not talking about interactive pages like Google Maps. I am talking about pages that are content heavy. To me these people are just downright sloppy.
Image by USMC Archives ; license: CC The other day I had to analyze search latency spikes in Elasticsearch for a customer. When latency spikes are involved, one of the first things I want to know is the “noiseness” of the host where the problem occurs. A great tool that helps with this analysis is Gil Tene’s jHiccup . It records hiccups in the application and also in a control…
jcmd is one of those neat tools that only a few people seem to know about. It is a command line tool that is shipped with each Oracle JDK installation and provides basic information about a running Java process, which is practical for unobtrusively inspecting a running production instance. How to Use jcmd To use jcmd we need to specify the process id of a running Java process. When jcmd is invoked…
Image by Juan Antonio Capó Alonso ; license: CC InterruptedException is among the most misunderstood exceptions in the JDK. How often did we come across exception handlers like this one: public void enqueue ( Object value ) { try { queue . put ( value ); } catch ( InterruptedException e ) { // ignore } } Or even: public void enqueue ( Object value ) { try { queue . put ( value ); } catch (…
This is the fifth and last post in a series about microbenchmarking on the JVM with the Java Microbenchmarking Harness (JMH) . part 1: Microbenchmarking in Java with JMH: An Introduction part 2: Microbenchmarks and their environment part 3: Common Flaws of Handwritten Benchmarks part 4: Hello JMH In the previous post, I have introduced JMH with a Hello World benchmark. Now, let’s dig a bit…
I have recently stumbled across a nice idiom called the cheap read-write lock . It is intended for very frequent concurrent reads of a field where synchronization would lead to too much contention. I think that the idiom is a bit odd and begs for an explanation. Usage Scenario For the sake of demonstration consider the following situation: Our system has a globally available calendar that holds…
This is the fourth post in a series about microbenchmarking on the JVM with the Java Microbenchmarking Harness (JMH) . part 1: Microbenchmarking in Java with JMH: An Introduction part 2: Microbenchmarks and their environment part 3: Common Flaws of Handwritten Benchmarks part 5: Digging Deeper In the previous post I have shown different problems that we might miss when writing microbenchmarks from…
Image by Sarah ; license: CC This is the third post in a series about microbenchmarking on the JVM with the Java Microbenchmarking Harness (JMH) . part 1: Microbenchmarking in Java with JMH: An Introduction part 2: Microbenchmarks and their environment part 4: Hello JMH part 5: Digging Deeper In the previous post I have shown typical issues that have to be considered when executing…
Image by Eduardo Diez Viñuela ; license: CC This is the second post in a series about microbenchmarking on the JVM with the Java Microbenchmarking Harness (JMH) . part 1: Microbenchmarking in Java with JMH: An Introduction part 3: Common Flaws of Handwritten Benchmarks part 4: Hello JMH part 5: Digging Deeper In the previous post I have introduced microbenchmarking. In this blog post we’ll…
Normally, Java programmers are not too concerned about the hardware on which their beautiful software runs as long as provides loads of memory. Most of the time this is a good thing as software should solve a business problem rather than satisfying a machine. The JVM does a decent job hiding the underlying platform but as we know, abstractions are leaky. Sometimes we have to peek under hood,…
Image by Zach Dischner ; license: CC This is the first post in a series about microbenchmarking on the JVM with the Java Microbenchmarking Harness (JMH) . part 2: Microbenchmarks and their environment part 3: Common Flaws of Handwritten Benchmarks part 4: Hello JMH part 5: Digging Deeper In this post I’ll introduce benchmarking conceptually and describe the specific flavor microbenchmarking.…
Perlock - a simple Java path watching library I have written - is available in Maven Central since a few weeks now. I thought it would be nice to provide another demo application to show how it can be used with Spring. It is provided along with Perlock on Github in examples/perlock-spring-demo . Demo Scenario The demo application implements a XML file processing application. Clients put XML files…
Image by Sandra ; license: CC As I have written in my previous post the JDK 7 WatchService API is too low level to be used directly in an application. To my surprise, to this day no Java library has existed that abstracts the JDK 7 WatchService API and provides an easy high level API on top. A Simplified API: Perlock Therefore I created perlock (short for Path-Sherlock). It supports the standard…
Have you ever needed to watch the file system for changes in a Java application? Java 7 ships with the WatchService API that is suited exactly for this use case as you might know. My journey with the WatchService API began a few months ago when I stumbled across this code I have originally written a few years ago: //TODO: Update to JDK 7 and replace with native watcher FileSystemManager fsManager…