<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Peter Lawrey on foojay.io - Friends of OpenJDK</title><link>https://foojayio.github.io/website/today/author/peter-lawrey/</link><description>Articles written by Peter Lawrey on foojay.io - Friends of OpenJDK</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Wed, 26 Jul 2023 13:00:04 +0000</lastBuildDate><atom:link href="https://foojayio.github.io/website/today/author/peter-lawrey/index.xml" rel="self" type="application/rss+xml"/><item><title>The IKEA Effect</title><link>https://foojayio.github.io/website/today/the-ikea-effect/</link><pubDate>Wed, 26 Jul 2023 13:00:04 +0000</pubDate><guid>https://foojayio.github.io/website/today/the-ikea-effect/</guid><description>&lt;p&gt;&lt;strong&gt;The &lt;a href="https://theconversation.com/the-ikea-effect-how-we-value-the-fruits-of-our-labour-over-instant-gratification-113647" title="IKEA effect" target="_blank" rel="noopener noreferrer"&gt;IKEA effect&lt;/a&gt;
 is a fascinating phenomenon whereby consumers place a (sometimes disproportionately) higher value on things that they have either made themselves, or to which they&amp;rsquo;ve contributed towards making.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;This can have a significant influence on perceived value &amp;ndash; to the extent that people might value imperfect things they&amp;rsquo;ve helped create, more than they would value the equivalent, perfect, but ready-made, product. Those who have pained memories of tussling with Allan keys and occasionally incomprehensible schematics for self-assembly furniture will no doubt have raised eyebrows. Of course, the effect only applies to items that are successfully assembled, of course. If people fail to build an item using the instructions provided, or it takes too long or is too difficult, due either to the complexity of the instructions or the inexperience of the user, then they do not ascribe the same value to the item.&lt;/p&gt;</description></item><item><title>Optimise CPU Performance Through Isolation and System Tuning</title><link>https://foojayio.github.io/website/today/how-to-optimise-cpu-performance-through-isolation-and-system-tuning/</link><pubDate>Thu, 29 Jun 2023 06:36:39 +0000</pubDate><guid>https://foojayio.github.io/website/today/how-to-optimise-cpu-performance-through-isolation-and-system-tuning/</guid><description>&lt;h4 id="what-are-the-challenges-of-tuning-your-cpu-and-system-for-optimal-performance-with-linux-and-how-does-chronicle-tune-address-them"&gt;What are the challenges of tuning your CPU and system for optimal performance with Linux, and how does Chronicle Tune address them?&lt;/h4&gt;
&lt;p&gt;CPU isolation and efficient system management are critical for any application which requires low-latency and high-performance computing. These measures are especially important for high-frequency trading systems, where split-second decisions on buying and selling stocks must be made.&lt;/p&gt;
&lt;p&gt;To achieve this level of performance, such systems require dedicated CPU cores that are free from interruptions by other processes, together with wider system tuning.&lt;/p&gt;</description></item><item><title>Unique Identifiers Based on Timestamps in Distributed Applications</title><link>https://foojayio.github.io/website/today/unique-identifiers-based-on-timestamps-in-distributed-applications/</link><pubDate>Wed, 14 Jun 2023 11:22:03 +0000</pubDate><guid>https://foojayio.github.io/website/today/unique-identifiers-based-on-timestamps-in-distributed-applications/</guid><description>&lt;p&gt;At &lt;a href="https://chronicle.software/?utm_source=website&amp;amp;amp;utm_medium=foojay&amp;amp;amp;utm_campaign=unique-identifiers" title="Chronicle" target="_blank" rel="noopener noreferrer"&gt;Chronicle&lt;/a&gt;
 we build applications that must process very high numbers of events with minimum latency. Generating unique IDs for these events using the traditional method of UUIDs introduces an unacceptable time overhead into our applications, so an alternative approach is needed.&lt;/p&gt;
&lt;p&gt;I recently wrote &lt;a href="http://blog.vanillajava.blog/2021/12/system-wide-unique-nanosecond-timestamps.html" title="an article" target="_blank" rel="noopener noreferrer"&gt;an article&lt;/a&gt;
 on how timestamps can be used as unique identifiers, as they are much cheaper to generate than other methods of generating unique identifiers, taking a fraction of a microsecond.&lt;/p&gt;</description></item><item><title>Java is Very Fast, If You Don’t Create Many Objects</title><link>https://foojayio.github.io/website/today/java-is-very-fast/</link><pubDate>Thu, 01 Jun 2023 04:45:56 +0000</pubDate><guid>https://foojayio.github.io/website/today/java-is-very-fast/</guid><description>&lt;p&gt;This article looks at a benchmark passing events over TCP/IP at 4 billion events per minute using the net.openhft.chronicle.wire.channel package in &lt;a href="https://chronicle.software/wire/?utm_source=article&amp;amp;amp;utm_medium=foojay&amp;amp;amp;utm_campaign=java-is-fast" title="Chronicle Wire" target="_blank" rel="noopener noreferrer"&gt;Chronicle Wire&lt;/a&gt;
 and why we aim to avoid object allocations.&lt;/p&gt;
&lt;p&gt;One of the key optimisations is creating almost no garbage. Allocation is supposed to be a very cheap operation and garbage collection of very short lived objects is also very cheap.&lt;/p&gt;
&lt;p&gt;Does not allocating really make such a difference? What difference does one small object per event (44 bytes) make to the performance in a throughput test where GC pauses are amortised?&lt;/p&gt;</description></item><item><title>Using Pausers in Event Loops</title><link>https://foojayio.github.io/website/today/using-pausers-in-event-loops/</link><pubDate>Wed, 17 May 2023 09:25:23 +0000</pubDate><guid>https://foojayio.github.io/website/today/using-pausers-in-event-loops/</guid><description>&lt;p&gt;Typically in low-latency development, a trade-off must be made between minimising latency and avoiding excessive CPU utilisation.&lt;/p&gt;
&lt;p&gt;This article explores how Chronicle&amp;rsquo;s Pausers can be used to automatically apply a back-off strategy when there is no data to be processed, providing an excellent balance between resource usage and responsive, low-latency, low-jitter applications.&lt;/p&gt;
&lt;h3 id="h3-0-description-of-the-problem"&gt;Description of the Problem&lt;/h3&gt;
&lt;p&gt;In a typical application stack multiple threads are used for servicing events, processing data, pipelining etc.&lt;/p&gt;</description></item><item><title>Approaches to Durability in Low Latency Messaging Queues</title><link>https://foojayio.github.io/website/today/comparing-approaches-to-durability-in-low-latency-messaging-queues/</link><pubDate>Wed, 26 Apr 2023 13:17:59 +0000</pubDate><guid>https://foojayio.github.io/website/today/comparing-approaches-to-durability-in-low-latency-messaging-queues/</guid><description>&lt;p&gt;A significant feature of &lt;a href="https://chronicle.software/queue-enterprise/?utm_source=foojay&amp;amp;amp;utm_medium=article&amp;amp;amp;utm_campaign=comparing-approaches" title="Chronicle Queue Enterprise" target="_blank" rel="noopener noreferrer"&gt;Chronicle Queue Enterprise&lt;/a&gt;
 is support for TCP replication across multiple servers to ensure high availability of application infrastructure.&lt;/p&gt;
&lt;p&gt;I have generally held the view that replicating data to a secondary system is faster than sync-ing to disk, assuming the round trip network delay wasn&amp;rsquo;t high due to quality networks and co-located redundant servers.&lt;/p&gt;
&lt;p&gt;This is the first time I have benchmarked it with a realistic example.&lt;/p&gt;</description></item><item><title>Event-Driven Order Processing Program</title><link>https://foojayio.github.io/website/today/event-driven-order-processing-program/</link><pubDate>Thu, 23 Mar 2023 09:27:37 +0000</pubDate><guid>https://foojayio.github.io/website/today/event-driven-order-processing-program/</guid><description>&lt;p&gt;Following the &lt;a href="https://foojayio.github.io/website/today/event-driven-hello-world-program/" title="Hello World example"&gt;Hello World example&lt;/a&gt;
 of a simple, independently deployable real-time Event-Driven Microservice, this article looks at a more realistic example of an Order Processor with a New Order Single in and an Execution Report out.&lt;/p&gt;
&lt;p&gt;A &lt;a href="https://www.onixs.biz/fix-dictionary/4.4/msgtype_d_68.html" title="New Order Single" target="_blank" rel="noopener noreferrer"&gt;New Order Single&lt;/a&gt;
 is a standard message type for the order of one asset in the FIX protocol used widely by financial institutions such as banks.&lt;/p&gt;
&lt;p&gt;The reply is typically one or more &lt;a href="https://www.onixs.biz/fix-dictionary/4.2/msgtype_8_8.html" title="Execution Reports" target="_blank" rel="noopener noreferrer"&gt;Execution Reports&lt;/a&gt;
 updating the status of that order.&lt;/p&gt;</description></item><item><title>Efficient Memory Mapping for Terabyte Sparse Files in Java</title><link>https://foojayio.github.io/website/today/efficient-memory-mapping-for-terabyte-sparse-files-in-java/</link><pubDate>Wed, 15 Mar 2023 11:50:41 +0000</pubDate><guid>https://foojayio.github.io/website/today/efficient-memory-mapping-for-terabyte-sparse-files-in-java/</guid><description>&lt;p&gt;On Linux, you can create &lt;a href="https://en.wikipedia.org/wiki/Sparse_file" title="sparse files" target="_blank" rel="noopener noreferrer"&gt;sparse files&lt;/a&gt;
, where only the pages (of 4 KiB) that are touched utilise either memory or disk space.&lt;/p&gt;
&lt;p&gt;This allows you to memory map large virtual regions without worrying about wasted memory or disk&lt;/p&gt;
&lt;p&gt;In this program, you can see it reserves 8 TiB (8,192 GiB)&lt;/p&gt;
&lt;p&gt;&lt;img src="https://foojayio.github.io/website/today/efficient-memory-mapping-for-terabyte-sparse-files-in-java/Screen-Shot-2023-03-06-at-11.11.24-AM-1024x480.png" alt="" loading="lazy"&gt;
&lt;br&gt;
&lt;em&gt;Figure 1. Test 1: Sparse file&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Tip: x &amp;lt;&amp;lt; y means x × 2y therefore:&lt;/p&gt;
&lt;pre class="EnlighterJSRAW" data-enlighter-language="generic"&gt;1L &amp;lt;&amp;lt; 10 = 1 KiB (1024 bytes),
1L &amp;lt;&amp;lt; 20 = 1 MiB (10242 bytes),
1L &amp;lt;&amp;lt; 30 = 1 GiB (10243 bytes),
1L &amp;lt;&amp;lt; 40 = 1 TiB etc&lt;/pre&gt;
&lt;p&gt;Using multiples of 10 for the shift makes them easier to read.&lt;/p&gt;</description></item><item><title>Event Driven Hello World Program</title><link>https://foojayio.github.io/website/today/event-driven-hello-world-program/</link><pubDate>Thu, 02 Mar 2023 16:34:35 +0000</pubDate><guid>https://foojayio.github.io/website/today/event-driven-hello-world-program/</guid><description>&lt;p&gt;&lt;strong&gt;Event-driven microservices&lt;/strong&gt; can be straightforward to describe before they are implemented, tested and maintained.&lt;/p&gt;
&lt;p&gt;They are also highly responsive to new information in real time, with latencies in Java of below 10 microseconds 99.99% of the time depending on the functionality of the small independently deployable microservice.&lt;/p&gt;
&lt;p&gt;In this introductory article, we use an example &lt;a href="https://chronicle.software/how-to-develop-event-driven-architectures/" title="event-driven" target="_blank" rel="noopener noreferrer"&gt;event-driven&lt;/a&gt;
&lt;a href="https://en.wikipedia.org/wiki/%22Hello,_World!%22_program" title=" Hello World" target="_blank" rel="noopener noreferrer"&gt;Hello World&lt;/a&gt;
 program (a programming paradigm where the program flow is determined by events) to step through &lt;a href="https://chronicle.software/how-bdd-works-well-with-eda/" title="behaviour-driven development" target="_blank" rel="noopener noreferrer"&gt;behaviour-driven development&lt;/a&gt;
, where we describe the behaviour the business needs first as test data, and writing a very simple &lt;a href="https://en.wikipedia.org/wiki/Microservices" title="microservice" target="_blank" rel="noopener noreferrer"&gt;microservice&lt;/a&gt;
 which turns input events like this:&lt;/p&gt;</description></item><item><title>Behaviour Driven Development with Event Driven Architectures</title><link>https://foojayio.github.io/website/today/how-behaviour-driven-development-works-well-with-event-driven-architectures/</link><pubDate>Wed, 15 Feb 2023 07:57:18 +0000</pubDate><guid>https://foojayio.github.io/website/today/how-behaviour-driven-development-works-well-with-event-driven-architectures/</guid><description>&lt;p&gt;Behaviour Driven Development (BDD) and Event Driven Architecture (EDA) work well together as they complement each other&amp;rsquo;s strengths and weaknesses.&lt;/p&gt;
&lt;p&gt;Using both can result in a shorter time to market for new functionality and a more maintainable system.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Behaviour Driven Development (BDD)&lt;/strong&gt; encourages a common language between users and developers in describing requirements in a form the users can understand but can also automatically be checked as the application is developed and maintained.&lt;/p&gt;</description></item><item><title>"The More You Say, the Less People Remember...</title><link>https://foojayio.github.io/website/today/the-more-you-say-the-less-people-remember/</link><pubDate>Wed, 25 Jan 2023 07:56:39 +0000</pubDate><guid>https://foojayio.github.io/website/today/the-more-you-say-the-less-people-remember/</guid><description>&lt;h2 id="h2-0-the-fewer-the-words-the-greater-the-profit"&gt;&amp;hellip;The Fewer the Words, the Greater the Profit.&amp;quot;&lt;/h2&gt;
&lt;p&gt;These wise words were written by François Fénelon, a writer and theologian living during the 17th century.&lt;/p&gt;
&lt;p&gt;This is an article summarising different approaches to the development of IT solutions. Learn why the above quote is very relevant for developers in the 21st century.&lt;/p&gt;
&lt;h3 id="h3-1-business-driven-development"&gt;Business Driven Development&lt;/h3&gt;
&lt;p&gt;&lt;a href="https://en.wikipedia.org/wiki/Business-driven_development" title="Business-driven development " target="_blank" rel="noopener noreferrer"&gt;Business-driven development&lt;/a&gt;
is a meta-methodology for developing IT solutions that directly satisfy &lt;a href="https://en.wikipedia.org/wiki/Requirement" title="business requirements" target="_blank" rel="noopener noreferrer"&gt;business requirements&lt;/a&gt;
. This leads to increased flexibility and shorter turnaround times when changing the business and adapting the IT systems.&lt;/p&gt;</description></item><item><title>How Does Kafka Perform When You Need Low Latency?</title><link>https://foojayio.github.io/website/today/how-does-kafka-perform-when-you-need-low-latency/</link><pubDate>Wed, 18 Jan 2023 10:12:24 +0000</pubDate><guid>https://foojayio.github.io/website/today/how-does-kafka-perform-when-you-need-low-latency/</guid><description>&lt;p&gt;Most Apache Kafka benchmarks appear to test high throughput but not low latency.&lt;/p&gt;
&lt;p&gt;Kafka was traditionally used for high throughput rather than latency-sensitive messaging, but it does have a low-latency configuration. (Mostly setting linger.ms=0 and reducing buffer sizes).&lt;/p&gt;
&lt;p&gt;In this configuration, you can get below 1-millisecond latency a good percentage of the time for modest throughputs.&lt;/p&gt;
&lt;p&gt;Benchmarks tend to focus on clustering Kafka, in a high-throughput configuration.&lt;/p&gt;
&lt;p&gt;While this is perhaps the most common use case, how does it perform if you need lower latencies?&lt;/p&gt;</description></item><item><title>Kafka vs. Chronicle for Microservices: Which is 750 Times Faster?</title><link>https://foojayio.github.io/website/today/kafka-vs-chronicle-for-microservices-which-is-750-times-faster/</link><pubDate>Wed, 30 Nov 2022 08:15:40 +0000</pubDate><guid>https://foojayio.github.io/website/today/kafka-vs-chronicle-for-microservices-which-is-750-times-faster/</guid><description>&lt;p&gt;Apache Kafka is a common choice for inter-service communication.&lt;/p&gt;
&lt;p&gt;Kafka facilitates the parallel processing of messages and is a good choice for log aggregation. Kafka &lt;a href="https://www.confluent.io/blog/kafka-fastest-messaging-system/" title="claims to be low latency, high throughput" target="_blank" rel="noopener noreferrer"&gt;claims to be low latency, high throughput&lt;/a&gt;
. However, is Kafka fast enough for many microservices applications in the cloud?&lt;/p&gt;
&lt;p&gt;When I wrote &lt;a href="https://chronicle.software/queue/" title="Open Source Chronicle Queue" target="_blank" rel="noopener noreferrer"&gt;Open Source Chronicle Queue&lt;/a&gt;
, my aim was to develop a messaging framework with microsecond latencies, and banks around the world have adopted it for use in their latency-sensitive trading systems and real-time streaming applications.&lt;/p&gt;</description></item><item><title>Unusual Java: StackTrace Extends Throwable</title><link>https://foojayio.github.io/website/today/unusual-java-stacktrace-extends-throwable/</link><pubDate>Wed, 23 Nov 2022 12:37:13 +0000</pubDate><guid>https://foojayio.github.io/website/today/unusual-java-stacktrace-extends-throwable/</guid><description>&lt;p&gt;There are things you can do in Java you rarely see, generally because there is no use for it.&lt;/p&gt;
&lt;p&gt;However, there are some unusual things in Java that could be surprisingly useful.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://chronicle.software/" title="Chronicle Software" target="_blank" rel="noopener noreferrer"&gt;Chronicle Software&lt;/a&gt;
 uses a number of different useful patterns in its low-level libraries most developers wouldn&amp;rsquo;t generally come across.&lt;/p&gt;
&lt;p&gt;One of them is a class that extends Throwable but isn&amp;rsquo;t an Error or an Exception.&lt;/p&gt;
&lt;h3 id="h3-0-stacktrace-extends-throwable"&gt;StackTrace Extends Throwable&lt;/h3&gt;
&lt;pre class="EnlighterJSRAW" data-enlighter-language="java"&gt;package net.openhft.chronicle.core;
/**
* Throwable created purely for the purposes of reporting a stack trace.
* This is not an Error or an Exception and is not expected to be thrown or caught.
*/
public class StackTrace extends Throwable {
 public StackTrace() { this("stack trace"); }
 public StackTrace(String message) { this(message, null); }
 public StackTrace(String message, Throwable cause) {
 super(message + " on " + Thread.currentThread().getName(), cause);
 }

 public static StackTrace forThread(Thread t) {
 if (t == null) return null;
 StackTrace st = new StackTrace(t.toString());
 StackTraceElement[] stackTrace = t.getStackTrace();
 int start = 0;
 if (stackTrace.length &amp;gt; 2) {
 if (stackTrace[0].isNativeMethod()) {
 start++;
 }
 }
 if (start &amp;gt; 0) {
 StackTraceElement[] ste2 = new StackTraceElement[stackTrace.length - start];
 System.arraycopy(stackTrace, start, ste2, 0, ste2.length);
 stackTrace = ste2;
 }

 st.setStackTrace(stackTrace);
 return st;
 }
}&lt;/pre&gt;
&lt;p&gt;Some important side notes to get out of the way first&lt;/p&gt;</description></item><item><title>Low Latency Microservices, A Retrospective</title><link>https://foojayio.github.io/website/today/low-latency-microservices-a-retrospective/</link><pubDate>Thu, 06 Oct 2022 06:25:56 +0000</pubDate><guid>https://foojayio.github.io/website/today/low-latency-microservices-a-retrospective/</guid><description>&lt;p&gt;I wrote an article on &lt;a href="https://vanilla-java.github.io/2016/03/22/Micro-services-for-performance.html" title="low latency microservices" target="_blank" rel="noopener noreferrer"&gt;low latency microservices&lt;/a&gt;
 almost five years ago now. Chronicle Software has worked with a number of tier one investment banks to implement and support those systems. What has changed in that time and what lessons have we learnt?&lt;/p&gt;
&lt;p&gt;Read this article and learn what we learned after five years of developing and supporting low latency microservices.&lt;/p&gt;
&lt;h3 id="h3-0-separation-of-concerns-gives-better-testability"&gt;Separation of Concerns Gives Better Testability&lt;/h3&gt;
&lt;p&gt;Microservices repeatedly demonstrated that testing and debugging business components were much easier with simple, stand-alone components with clear contracts between microservices.&lt;/p&gt;</description></item><item><title>Storing 1TB in Virtual Memory on a 128GB Machine</title><link>https://foojayio.github.io/website/today/chronicle-queue-storing-1tb-in-virtual-memory-on-a-128gb-machine/</link><pubDate>Tue, 27 Sep 2022 09:10:43 +0000</pubDate><guid>https://foojayio.github.io/website/today/chronicle-queue-storing-1tb-in-virtual-memory-on-a-128gb-machine/</guid><description>&lt;p&gt;If you use a standard JVM like the Oracle JVM or the OpenJDK, you might find that as the heap size grows the performance of your JVM can drop as GC pause time escalates.&lt;/p&gt;
&lt;p&gt;This tends to be a problem around 32 GB of heap, but it often depends on the application at which point the size of your heap becomes a problem.&lt;/p&gt;
&lt;p&gt;One way around this is to use an always concurrent collector such as &lt;a href="https://www.azul.com/products/prime/" target="_blank" rel="noopener noreferrer"&gt;Azul Platform Prime&lt;/a&gt;
 which is designed to both scale to much larger heap sizes and even reduces the GC pause times for smaller heap consistently.&lt;/p&gt;</description></item></channel></rss>