Don't Just Assume Array Will Be Faster When Implementing Object Pooling

Don't Just Assume Array Will Be Faster When Implementing Object Pooling

By Tom McKee

To ensure customers receive the best service possible from TransFICC, we need to make sure that our systems have robust latency and throughput figures. A key part of avoiding latency spikes (in Java anyway) is to attempt to keep the Garbage Collector at bay. One way we attempt to do this is with the use of object pooling pattern to allow us to re-use objects.

We weren't sure what data structure would be best to back our object pool implementation, so we decided to write a few benchmarks that utilise various data structures: stack, dequeue based stack, queue, and an array. The goal of these benchmarks was to see if any of the data structures allocate (e.g. if using a LinkedList, a node would be created every time you added an object to the pool), and to see what the latency and throughput values would be.

The benchmark results for measuring throughput show that both of the deque backed object pools perform at a similar level for both of the scenarios we are testing, with our stack implementation having similar throughput for the removing and adding several objects scenario.

What is more interesting are the latency figures.

Both object pools that are backed by a deque have very similar latency profiles, which I was surprised at as I expected the stack implementation to outperform on the remove one add one strategy, as it would only be using a single object (the queue implementation will always be taking a different object from the front of the queue). The stack object pool does perform slightly better in the remove several add several scenario at one data point, but the difference isn't significant compared to the queue implementation.

What I found most surprising is the high variance in the array backed object pool. I assumed using a simple array would yield the best throughput and latency numbers, however this is not the case. I'm not sure if it's because of my implementation of the array object pool so will try another version if I have time.

In the end we opted to use an object pool using a stack backed by a deque based on our findings. I should point out that all our object pools are accessed from a single thread so are not required to be thread safe.

For Tom's full blog post (including graphs and code) visit http://tomsmalls.blogspot.co.uk/2016/06/object-pooling-in-java.html


Share
Filter by section
Most popular stories
TransFICC Confirms Intention to Bid for Fixed Income Consolidated Tapes

TransFICC Confirms Intention to Bid for Fixed Income Consolidated Tapes

TransFICC will bid to be the Consolidated Tape Provider (CTP) for the new UK and EU Consolidated Tapes. The FCA is expected to begin its tender process and criteria for the UK CTP in the next few weeks, and ESMA for the EU CTP in January 2025.


Read More Twitter LinkedIn
TransFICC Named "Best Workplace for Technologists"

TransFICC Named "Best Workplace for Technologists"

Having been shortlisted for two previous years, TransFICC has now been recognised at the "Top 1% Workplace Awards 2024"


Read More Twitter LinkedIn
New Report - Corporate Bond Dealers Focus on Trade Automation

New Report - Corporate Bond Dealers Focus on Trade Automation

Coalition Greenwich spoke with 26 bond dealers about the US corporate bond market. Sponsored by TransFICC, the report highlights key technology priorities for 2024


Read More Twitter LinkedIn
TransFICC Secures New Investment of $17 million Led by AlbionVC

TransFICC Secures New Investment of $17 million Led by AlbionVC

TransFICC has closed a Series A extension for $17 million. Led by AlbionVC, all existing institutional shareholders took part in this investment round, which follows the original Series A for $7.8 million, announced in April 2020.


Read More Twitter LinkedIn
TransFICC Named One of The Most Influential FinTech Firms of 2022

TransFICC Named One of The Most Influential FinTech Firms of 2022

Now in its 5th year, the Financial Technologist showcases leading Capital Markets FinTechs


Read More Twitter LinkedIn
TransFICC Launches Consolidated Tape Pilot For EU Fixed Income Using The AFM Regulatory Sandbox

TransFICC Launches Consolidated Tape Pilot For EU Fixed Income Using The AFM Regulatory Sandbox

Press Release - TransFICC has announced a new initiative to develop a Consolidated Tape (CT) for Fixed Income. As part of this initiative, TransFICC has developed a production ready pilot, for Banks, Asset Managers and Regulators to test.


Read More Twitter LinkedIn
Talking with The Trade about the Consolidated Tape for Fixed Income

Talking with The Trade about the Consolidated Tape for Fixed Income

Steve speaks with Kiays Khalil from The TRADE News about the need for a Consolidated Tape in Fixed Income.


Read More Twitter LinkedIn
Speaking with The Desk about Managing Fragmentation in Fixed Income

Speaking with The Desk about Managing Fragmentation in Fixed Income

A smart application of hardware, cloud and open source technology makes for efficient trading systems and reduces the inefficiency that complexity creates


Read More Twitter LinkedIn
Mob Rules - Moving to Virtual Pair Programming

Mob Rules - Moving to Virtual Pair Programming

Like all companies, lockdown has impacted the way we work at TransFICC. We have always championed Extreme Programming as our methodology of choice, so when we decided to close the office at the start of March, this raised some issues around how we would operate with everyone working remotely.


Read More Twitter LinkedIn
All Change - Technology & Efficiency Are The (Old) New Buzzwords in Fixed Income

All Change - Technology & Efficiency Are The (Old) New Buzzwords in Fixed Income

Steve writes for The Financial Technologist - published by Harrington Starr


Read More Twitter LinkedIn
Press Release - TransFICC Secures New Investment From AlbionVC, ING Ventures and HSBC

Press Release - TransFICC Secures New Investment From AlbionVC, ING Ventures and HSBC

TransFICC has closed its Series A investment round for £5.75 million. Led by AlbionVC, it included new strategic investments from ING Ventures and HSBC. The new investors join existing shareholders, Citi, Illuminate Financial, Main Incubator (the R&D unit of Commerzbank Group) and The FinLab.


Read More Twitter LinkedIn
Twitter Feed