Home » Author Archives: Peter Lawrey (page 3)

Author Archives: Peter Lawrey

An Inconvenient Latency

software-development-2-logo

Overview Vendors typically publish numbers they are happy with, and avoid telling you about a product’s weaknesses.  However, behind the numbers is a dirty secret if you know where to look. Why don’t we use GPUs for everything? Finding problems which naturally scale to thousands of data points/tasks is easy for some problems, and very hard for others.   GPUs ...

Read More »

Try optimising the memory consumption first

software-development-2-logo

Overview You would think that if you wanted your application to go faster you would start with the CPU profiling.  However, when looking for quick wins, it’s the memory profiler I target first. Allocating memory is cheap Allocating memory has never been cheaper.  Memory is cheaper, you can get machines will thousands of GBs of memory. You can buy 16 ...

Read More »

Compounding double error

java-logo

Overview In a previous article, I outlined why BigDecimal is not the answer most of the time. While it is possible to construct situations where double produces an error, it is also just as easy to construct situations were BigDecimal get an error. BigDecimal is easier to get right, but easier to get wrong. The anecdotal evidence is that junior ...

Read More »

If BigDecimal is the answer, it must have been a strange question

java-logo

Overview Many developers have determined that BigDecimal is the only way to deal with money.  Often they site that by replacing double with BigDecimal, they fixed a bug or ten.  What I find unconvincing about this is that perhaps they could have fixed the bug in the handling of double and that the extra overhead of using BigDecimal. My comparison, ...

Read More »

Making operations on volatile fields atomic

java-logo

Overview The expected behaviour for volatile fields is that they should behave in a multi-threaded application the same as they do in a single threaded application.  They are not forbidden to behave the same way, but they are not guaranteed to behave the same way. The solution in Java 5.0+ is to use AtomicXxxx classes however these are relatively inefficient ...

Read More »

Adding @atomic operations to Java

java-logo

Overview How might atomic operations work in Java, and is there a current alternative in OpenJDK/Hotspot it could translate to. Feedback In my previous article on Making operations on volatile fields atomic. it was pointed out a few times that “fixing” previous behaviour is unlikely to go ahead regardless of good intentions.   An alternative to this is to add an @atomic annotation. ...

Read More »

MineCraft and off heap memory

java-logo

Overview MineCraft is a really good example of when off heap memory can really help. The key requirements are: The bulk of the retained data is a simple data structure (in minecraft’s case its lots of byte[]) The usage of off heap memory can be hidden in abstraction.     The test I used the following test for starting minecraft ...

Read More »

Making Unsafe safer

java-logo

Overview If you use Unsafe directly, you risk crashing the JVM.  This happens when you access a page of memory which hasn’t been mapped and the result on Unix is a SIGSEG (if you access page 0) or SIGBUS (if you access another page which is not mapped). Using MethodHandles Wrapping Unsafe method with a MethodHandle is a possible solution. ...

Read More »

SharedHashMap vs Redis

redis-logo

Overview This is a comparison between OpenHFT’s SharedHashMap and a popular key-value store Redis. Any vendor will tell you how great their product is, so I will start by outlining why you wouldn’t use SharedHashMap, before I tell you why it is a “must have” for performant applications.       Why you would use Redis? Redis is a more ...

Read More »

Chronicle and low latency in Java

java-logo

Overview I was watching this excellent presentation by Rolan Kuhn of Typesafe on Introducing Reactive Streams At first glance it appears that it has some similar goals to Chronicle, but as you dig into the details it was clear to me that there was a few key assumptions which were fundamentally different.   Key assumptions The key assumptions  in the design of ...

Read More »
Want to take your Java Skills to the next level?
Grab our programming books for FREE!
  • Save time by leveraging our field-tested solutions to common problems.
  • The books cover a wide range of topics, from JPA and JUnit, to JMeter and Android.
  • Each book comes as a standalone guide (with source code provided), so that you use it as reference.
Last Step ...

Where should we send the free eBooks?

Good Work!
To download the books, please verify your email address by following the instructions found on the email we just sent you.