Archive for November, 2013

Avoiding monitor contention in Java’s Double parseDouble

Saturday, November 30th, 2013

Overview

You can call Double.parseDouble in Java to convert String representations of numbers like “1.234567” into a number representation.

I needed to do this, a lot of times, from a lot of threads. And it was horrendously slow.

In this post, I’ll explain why and what I did about it.

Background (skip this if you don’t care why I had this problem!)

I’ve mentioned UIMA before : an Apache framework for doing text analytics, that I use at work. One of the ways that it stores and moves around units of work is in XML files (called CAS files).

For a particular task at work, I will have a lot of these. Thousands of them. I need to deserialize these, and parse and process the contents. The contents includes scores from the various analytics operations that are done on the contents of the CAS:

<myElement
    myRawScore="1.2345678"
    myThisScore="2.46801357"
    myThatScore="1.35792468"
    ...

Thousands of XML files, each containing several thousand numbers in String form.

As part of the deserializing the CAS files, the UIMA library (specifically org.apache.uima.cas.impl.CASImpl) was calling Double.parseDouble 500,000,000 times or more.

I’ve got 64 processor cores and lots of memory, so I kicked off 64 threads – each one processing an XML CAS file at a time.

This took *ages*.

(more…)

Making handwritten notes on an iPad mini

Thursday, November 28th, 2013

I’ve had a Bamboo stylus for my iPad mini for a while now. I’ve used it for sketching and rough diagrams but only recently started using it for making handwritten notes.

It’s not immediately obvious that it’d really work. The iPad touchscreen is designed for use by pudgy human fingers, so that’s what the stylus mimics. You don’t get a fine point for precision drawing, you get a big fat rounded end. (As an aside, this is something that the Surface gets right – a proper active pressure-sensitive stylus is very cool. But anyway…) So your handwriting has to end up really big – like trying to make notes with a child’s chunky crayon.

And the iPad mini screen is so small that you don’t have much room to write.

I ended up carrying a Moleskine notebook and pen around as well – making handwritten in notes in that and then taking photos of it with the iPad. It’s a bit of a kludgy and time-consuming workaround.

I’ve started using Penultimate instead, and it’s pretty neat. It makes up for the limitations of handwriting by giving you a zoomed-in view of a bit of the screen, and scrolling that view around for you automatically as you write – matching the speed of your handwriting. And it’s reasonably good at knowing how how to ignore a wrist resting on the screen.


Camera work by Grace, book to copy provided by Faith 🙂

(more…)

Why do I keep moaning about my back?

Friday, November 15th, 2013

If you’ve spent any time in person with me in the last month or two, you’ll know that I’ve barely shut up about my back hurting.

If you follow me on twitter or facebook, you might have noticed the occasional moan, or at least mentions of physio, hospital trips and pain meds.

This post is my way of drawing a line under all of this. I’ll explain what’s wrong with me, and then shut up about it. Really. I promise.

I have degenerative disc disease.

(more…)