Posts

Note to self: when you next need to handle drag and drop events in javascript, just use jquery.event.drag from ThreeDubMedia. Simple jquery based API and automatically handles the most annoying part of javascript drag handlers – dealing with cases where the user starts dragging inside an element, drags right out of the element and then releases the mouse.
2013-07-24
1 min read
Thanks to Noah Cornwell for porting the Coalescing Ring Buffer to .Net and Jakub Stasiak for porting it to Python: .Net https://github.com/ncornwell/NCoalescingRingBuffer Python https://github.com/jstasiak/coalringbuf
2013-07-23
1 min read
You can now download the new coalescingRingBuffer-1.1.0.jar and coalescingRingBuffer-1.1.0-src.zip. Improvements: 4% performance improvement by using lazy sets where possible constructor now rounds up capacity to the nearest higher power of two instead of throwing an exception nextRead index has been renamed firstWrite for clarity
2013-07-16
1 min read
I’ve recently embarked on a fairly complex new application, a large part of which is a webapp written in JavaScript. The application uses require.js to handle modules and loading of dependencies and we want to be able to unit test our JavaScript. In order to test specific pieces of the application, we want to be able to inject stubs or mocks into the module being tested. For example, if we had a module: define(['dataSource', 'utils'], function(dataSource, utils) {.
2013-07-08
3 min read
I’ll be giving a lightening talk at JavaZone 2013 in Oslo on High Performance Design. Abstract: How to use TDD to create a thread-safe, lock-free, high-performance cache by using knowledge of how modern processors are designed. Hope to see you there!
2013-06-30
1 min read
Without even a mention of the ‘M’ word! One of the things that attracted me to SPA 2013 was the Neural Net workshop on the Sunday. It turned out to be even better than I hoped; although we didn’t get quite as far as we could have done. The first thing we wanted to do was implement a Neuron. In this particular case, a neuron took two inputs (let’s say they are doubles, for the time being) and then performs a computation on those inputs to determine a single output.
2013-06-24
6 min read
I’ve helped out a friend with their website recently, and it made me realise how difficult technology can still be for people who don’t do this on a daily basis. Even smart people - she has a background as a professional scientist, artist and now successful businesswoman - can still require help with what on the surface appears to be the simple task of moving a website created on her mac using MAMP to the hosting company.
2013-06-15
9 min read
A quick post. We have some home made cheapy frankenstorage, thats based around a low end celeron class desktop CPU. This is fine for moderate raid work, but recently I had to shovel a few terabytes between them, over the network. Making that run quickly enough led to a bit of experimentation with the speeds of the different ciphers. Normally I’d reach for nc at this point and run something like this on the sender
2013-06-15
2 min read
According to the ant documentation: It is possible to include the same file more than once by using different prefixes, it is not possible to import the same file more than once. Unfortunately, it turns out this isn’t quitetrue. In most cases, ant will indeed ignore a request to import a file for the second time, so: <import> <file name="utils.xml"/> <file name="utils.xml"/> </import> will only import utils.xml once. This is true even if there’s a chain of files being imported (so A imports B and C, then B imports C as well, C will only be imported once).
2013-06-11
2 min read
So, this week on Distilled Derivatives, some more laziness. And also, exceptions. Everyone loves them, really useful things for letting you move error handling into a single location that they are. Now and again though, their misuse can really get in the way of getting something done. Retrieve the content of the first functioning url Given n urls in some ordered collection, get the content of the first “working” url, where working is defined to mean “has http code 200 and non empty response content”.
2013-06-09
9 min read
Thanks to everyone who came to my talk last night and to Skills Matter and the LJC for organizing! Video: http://skillsmatter.com/podcast/java-jee/high-performance-design Code Examples: https://github.com/nickzeeb/LmaxTeachingCollections Slides: https://docs.google.com/presentation/d/1Yxw-9ZFM_maRORk_qGkdt9vqKKQNLjDSSd9DIOtbrIE/pub?start=false&loop=false&delayms=3000#slide=id.gb9e7834b_05
2013-05-15
1 min read
Most people believe that ant will only ever execute a target once per execution of ant. So if we have targets A, B, C and D, where A depends on B and C and C and D both depend on D. <target name="A" dependencies="B, C"/> <target name="B" dependencies="D"/> <target name="C" dependencies="D"/> <target name="D"/> When we run ‘ant A’, we expect each task to execute once, D first, then B and C, ending with A. Since there is no dependency between B and C, they may execute in any order, so we might also get D, C, B, A.
2013-05-10
2 min read
This information is all covered in much more detail elsewhere on the web but for my own future reference, here’s a primer on doctypes, compatibility modes, charsets and fonts which was required to explain why certain Chinese characters weren’t showing up in IE8. Of course the best answer is that you need to have the East Asian Font pack installed and then it just works (usually) but this tends to be useful background and saves “server side” folks from a number of gotchas.
2013-04-26
3 min read
I’m giving a talk at the London Java Community on the 14th of May about the Coalescing Ring Buffer design process. http://www.meetup.com/Londonjavacommunity/events/114964652/ Hope you can make it!
2013-04-19
1 min read
Some times its hard to find a way of explaining to the technically less literate the power that the Unix shell hands you. The original ideas behing the combination wordprocessor and programmers work bench combined with the power of pipes make text processing easy. So to today’s problem - analysing GC logs for latency spikes. As we run the jvm with the following properties; -XX:+PrintGCDateStamps -XX:+PrintGCDetails -XX:+PrintGCApplicationStoppedTime -XX:+PrintTenuringDistribution -Xloggc:/path/to/gc.logfile The output looks like this;
2013-04-18
3 min read
I’ve decided that I’m a bit bored of the whole putting a beta tag on various versions of the Disruptor so I’ve decide to send forth Disruptor 3.0.0 into the world. The big challenges of this release were to clean up the code and come up with a better algorithm for handling multiple producers. If I was lucky, make it even faster. I went down a couple of dark alleys initially with this release, but have come up again for air with a version that is less different to the 2.
2013-04-14
1 min read
The Coalescing Ring Buffer is the first component of the LMAX Collections Library we are open-sourcing today. It is a component that we have written in Java to efficiently buffer messages between a producer and a consumer thread where only the latest value for a given topic is of interest. All other messages can be discarded immediately. The Problem of Market Data Let’s imagine we are trying to write an automated trading system that listens to all stock price updates on an exchange in order to find under-valued stocks.
2013-03-07
4 min read
I settled on piwigo for a web photo gallery, after the demise of ZangZing. I looked at the others and I’m aware that most people use twitbook for sharing family photos, but I don’t really trust them with my data in the long term. Plus I’m just too much of a DIY dinosaur to use any of the modern trendy sites like candygram or whatever. So here’s a short list of pitfalls I encountered whilst getting piwigo up and running, including video.
2013-02-24
3 min read
I recently went to hear the LSO perform at their residence within the Barbican centre. The full complement of 91 people performed 3 classical pieces and 3 more “movie soundtrack” kind of pieces as a friend called them. Half way into the first piece I started thinking of an analogy between the musical system that was the orchestra and a run of the mill system. First question that came to mind was how would you go about testing something as complex as this.
2013-02-03
2 min read
Recently at LMAX Exchange, we’ve started using more and more of what we call integration tests which prompted a post on how we use integration tests and how we differentiate them from acceptance tests. To start off, a few definitions are in order: we define an acceptance test as an external client that encompasses enough information on how to drive the system under test (SUT) in order to bring it to the point of asserting something.
2013-01-30
3 min read
Ah Apple maps, ever the source of a good sensationalist headline. This time the Victorian police have warned people not to use Apple Maps to get to Mildura. This is definitely a bug with Apple maps, no question it should be and has been fixed. What’s interesting though is that the Victorian police thought it would be easier to attempt to notify every iOS 6 user about the problem via the media and get them to use an alternate mapping application than it would be to call Apple and get them to fix the source data.
2012-12-10
2 min read
I’m happy to announce that I will speaking at Tech Mesh in December. I’ll be speaking about the Disruptor from two perspectives, firstly looking briefly back at some of the history and motivations behind the Disruptor. Then spending some time explaining at the challenges of building high performance concurrent systems (like the Disruptor) and delving into how the JVM and hardware could change to support the development of these systems.
2012-11-08
1 min read
Last week I gave a talk on non-blocking concurrency at JAX London. Here are the slides:
2012-10-19
1 min read
The Open/Closed Principle (OCP) “Software entities (classes, modules, functions, etc.) should be open for extension but closed for modification.” [APPP] When the requirements of an application changes, if the application confirms to OCP, we can extend the existing modules with new behaviours to satisfy the changes (Open for extension). Extending the behaviour of the existing modules does not result in changes to the source code of the existing modules (Closed for modification). Other modules that depends on the extended modules are not affected by the extension.
2012-09-24
5 min read
The Abstract Factory pattern is an important building block for Domain Modelling. It hides the complexity of creating a domain object from the caller of the factory. It also enables us to create domain objects those have complex dependencies without worrying about when and how to inject its dependencies. It is easier to explain the idea with a concrete example. I used to work on a project to build a simple online booking system for a heath club.
2012-09-05
6 min read
From Straights Times: A flier aboard Sunday’s Swiss airline flight – a 57-year-old Chinese man […] felt disturbed during his meal when the passenger in front of him reclined his chair.[…] “The older of the two felt disturbed during his dinner. When the younger did not respond to his protests, he hit him on the head with the flat of his hand. It was a real slap,” said the guide, Ms Valerie Sprenger. A fight then broke out between the two men, who rolled in the plane’s aisle.
2012-09-05
1 min read
During a recent conversation on the LJC mailing list around a proposal for adding a library to the JDK that would add support for handling integer overflow a question arose. Would the JVM be able to optimise this code to make efficient use of the hardware support for overflow detection if this functionality was implemented as a library. I made the comment that this is problem is probably one best solved using intrinsics, but in the course of writing an explanation I thought it would be better explained in a blog post, so here goes…
2012-09-01
5 min read
Of all the data types, double is probably one of the most misunderstood. A huge amount of folk lore has been built up around it to help protect developers from falling into its many pitfalls. Lately I’ve done a lot of work replacing usage of BigDecimal with double and learnt a lot about where those pitfalls are and how the folk lore can be misleading. The great challenge with double is that it has a degree of inaccuracy because of the way the number is actually stored.
2012-08-29
3 min read
Data Access Object (DAO) is a commonly used pattern to persist domain objects into a database. The most common form of a DAO pattern is a class that contains CRUD methods for a particular domain entity type. Assumes that I have a domain entity class “Account”: package com.thinkinginobjects.domainobject; public class Account { private String userName; private String firstName; private String lastName; private String email; private int age; public boolean hasUseName(String desiredUserName) { return this.userName.equals(desiredUserName); } public boolean ageBetween(int minAge, int maxAge) { return age >= minAge && age <= maxAge; } } Follow the common DAO approach, I create a DAO interface:
2012-08-26
7 min read
Farnam Street Blog holds up a coding competition as evidence that: If you want to make your computer programmers and engineers more effective give them “privacy, personal space, control over their physical environments, and freedom from interruption.” The only trouble is, the coding competition is fatally flawed as a measure of normal developer productivity. It’s setup such that developers work on their own: Each participant was also assigned a partner from the same company.
2012-08-14
3 min read