The Mythical Modulo Mask
It is an optimisation well known to those who know it well that % of power of 2 numbers can be replaced by a much cheaper AND operator to the same power of 2 - 1. E.g:x % 8 == x & (8 - 1)[4/11/2014...
View ArticleThe Escape of ArrayList.iterator()
{This post assumes some familiarity with JMH. For more JMH related content start at the new and improved JMH Resources Page and branch out from there!}Escape Analysis was a much celebrated optimisation...
View ArticleMPMC: The Multi Multi Queue vs. CLQ
JCTools, which is my spandex side project for lock-free queues and other animals, contains a lovely gem of a queue called the MpmcArrayQueue. It is a port of an algorithm put forward by D. Vyukov (the...
View ArticleHdrHistogram: A better latency capture method
Some years back I was working on a latency sensitive application, and since latency was sensitive it was a requirement that we somehow capture latency both on a transaction/event level and in summary...
View ArticleCorrecting YCSB's Coordinated Omission problem
YCSB is the Yahoo Cloud Serving Benchmark(also on wiki): a generic set of benchmarks setting out The Nimbus Cloud Serving Boardto compare different key-value store providers under a set of loads:The...
View ArticleOn Arrays.fill, Intrinsics, SuperWord and SIMD instructions
{This post turned rather long, if you get lazy feel free to skip to the summary}Let's start at the very beginning, a very good place to start... My very first post on this blog was a short rant on...
View ArticlePorting Pitfalls: Turning D.Vyukov MPSC Wait-free queue into a j.u.Queue
{This post is part of a long running series on lock free queues, checkout the full index to get more context here}D. Vyukov is an awesome lock-free dude, and I often refer to his instructive and...
View ArticleDegrees Of (Lock/Wait) Freedom
Yo, Check the diagonal, three brothers gone...I've been throwing around the terms lock-free and wait-free in the context of the queues I've been writing, perhaps too casually. The definition I was...
View ArticleObject.equals, primitive '==', and Arrays.equals ain't equal
It is a fact well known to those who know it well that "==" != "equals()" the example usually going something like: String a = "Tom"; String b = new String(a); -> a != b but a.equals(b)It also...
View ArticleJMH perfasm explained: Looking at False Sharing on Conditional Inlining
There is an edge that JMH (read the jmh resources page for other posts and related nuggets) has over other frameworks. That edge is so sharp you may well cut yourself using it, but given an infinite...
View ArticleAn extended Queue interface
In my work on JCTools I have implemented a fair number of concurrent access queues. The Queue interface is part of the java.util package and offers a larger API surface area than I found core to...
View ArticleExpanding The Queue interface: Relaxed Queue Access
Continuing from previous post on the expansion of the Queue interface to support new ways of interacting with queues I have gone ahead and implemented relaxedOffer/Poll/Peek for the JCTools queues....
View ArticleSafepoints: Meaning, Side Effects and Overheads
I've been giving a couple of talks in the last year about profiling and about the JVM runtime/execution and in both I found myself coming up against the topic of Safepoints. Most people are blissfully...
View ArticleWait For It: Counted/Uncounted loops, Safepoints and OSR Compilation
In this previous post about Safepoints I claimed that this here piece of code:Will get your JVM to hang and will not exit after 5 seconds, as one might expect from reading the code. The reason this...
View ArticleWhy (Most) Sampling Java Profilers Are Fucking Terrible
This post builds on the basis of a previous post on safepoints. If you've not read it you might feel lost and confused. If you have read it, and still feel lost and confused, and you are certain this...
View ArticleGC 'Nepotism' And Linked Queues
I've just run into this issue this week, and it's very cute, so this here is a summary. Akka has their own MPSC linked queue implementation, and this week in was suggested they'd swap to using JCTools....
View ArticleThe Pros and Cons of AsyncGetCallTrace Profilers
So, going on from my whingy post on safepoint bias, where does one go to get their profiling kicks? One option would be to use an OpenJDK internal API call AsyncGetCallTrace to facilitate non-safepoint...
View ArticleFixing Coordinated Omission in Cassandra Stress
Copyright © 2016 Apache Software FoundationI have it from reliable sources that incorrectly measuring latency can lead to losing ones job, loved ones, will to live and control of bowel movements. Out...
View Article4 Years Blog Anniversary
This has been a very slow year blogging wise... too much work, travel, and family. 4 years ago I aimed for 2 posts a month. I nearly hit it in 2013, failed by a little in 2014, and went on to not...
View ArticleLinked Array Queues, part 1: SPSC
When considering concurrent queues people often go for either:An array backed queue (circular array/ring buffer etc.)A linked list queueThe trade off in the Java world seems to be that array backed...
View ArticleLinked Array Queues, part 2: SPSC Benchmarks
JCTools has a bunch of benchmarks we use to stress test the queues and evaluate optimizations. These are of course not 'real' workloads, but serve to highlight imperfections and opportunities. While it...
View ArticleWhat do Atomic*::lazySet/Atomic*FieldUpdater::lazySet/Unsafe::putOrdered*...
Paved with well intended definitions it is.lazySet/putOrdered (or an ordered store) was added as a bit of a rushed/non-commital afterthought after the JMM was done, so it's description is subject to...
View ArticleJava Flame Graphs Introduction: Fire For Everyone!
FlameGraphs are superawesome. If you've never heard of FlameGraphs and want to dive straight in the deep end, you should run off and check out the many many good resources provided by Brendan Greg in...
View ArticleWhat a difference a JVM makes?
JDK 9 is out! But as a library writer, this means change, and change can go either way... Once we've satisfied that JCTools works with JDK9, what other observations can we make? Well, one of the main...
View ArticleHow Inlined Code Makes For Confusing Profiles
Inlining is a powerful and common optimization technique used by compilers. But inlining combines with other optimizations to transform your code to such an extent that other tooling becomes confused,...
View Article