<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Lorenzo Vangi on Medium]]></title>
        <description><![CDATA[Stories by Lorenzo Vangi on Medium]]></description>
        <link>https://medium.com/@lorenzovangi?source=rss-f562541003cb------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*nPPmdq--C2Zymm8u39OwtA.jpeg</url>
            <title>Stories by Lorenzo Vangi on Medium</title>
            <link>https://medium.com/@lorenzovangi?source=rss-f562541003cb------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 11:06:52 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@lorenzovangi/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[The bottleneck is rarely the agents]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/the-converging-line/the-bottleneck-is-rarely-the-agents-83bcb36d77f4?source=rss-f562541003cb------2"><img src="https://cdn-images-1.medium.com/max/1400/1*JppUoRMIhWBoRR6EPpqNMQ.png" width="1400"></a></p><p class="medium-feed-snippet">8 field notes from building an agentic company</p><p class="medium-feed-link"><a href="https://medium.com/the-converging-line/the-bottleneck-is-rarely-the-agents-83bcb36d77f4?source=rss-f562541003cb------2">Continue reading on The Converging Line »</a></p></div>]]></description>
            <link>https://medium.com/the-converging-line/the-bottleneck-is-rarely-the-agents-83bcb36d77f4?source=rss-f562541003cb------2</link>
            <guid isPermaLink="false">https://medium.com/p/83bcb36d77f4</guid>
            <category><![CDATA[agentic-ai]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[ai-agent]]></category>
            <category><![CDATA[engineering-management]]></category>
            <dc:creator><![CDATA[Lorenzo Vangi]]></dc:creator>
            <pubDate>Mon, 30 Nov 2026 08:01:04 GMT</pubDate>
            <atom:updated>2026-11-30T08:01:04.242Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Big-O Was Never the Bottleneck. The Cache Line Was.]]></title>
            <link>https://medium.com/the-converging-line/big-o-was-never-the-bottleneck-the-cache-line-was-d6457dbc1d8f?source=rss-f562541003cb------2</link>
            <guid isPermaLink="false">https://medium.com/p/d6457dbc1d8f</guid>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[hft]]></category>
            <category><![CDATA[low-latency]]></category>
            <category><![CDATA[mechanical-sympathy]]></category>
            <dc:creator><![CDATA[Lorenzo Vangi]]></dc:creator>
            <pubDate>Sat, 01 Aug 2026 14:22:19 GMT</pubDate>
            <atom:updated>2026-08-01T14:22:19.749Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Two independent variables, two threads, zero shared state, and half the throughput gone. A short tour of why, in low-latency Java, the memory layout beats the algorithm.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j-GQss2tmcqlvfQrEaypKw@2x.jpeg" /></figure><p>Early in my time building trading systems, I watched a component that was, on paper, embarrassingly parallel get <em>slower</em> every time we added a thread. No shared state. No locks in the path. No contended data structure. The profiler was calm. The design review had blessed it. And the throughput curve went the wrong way.</p><p>The bug wasn’t in the code we could read. It was in 64 bytes we couldn’t see.</p><p>If you’ve followed my earlier pieces, you know the running theme: the edge is never where the comfortable story says it is. It wasn’t the C++. It wasn’t the speed. This time it’s the one every Java developer has been trained to ignore the belief that a data structure’s Big-O is what makes it fast.</p><h3>The mystery: nothing shared, everything contended</h3><p>Picture two counters. Two threads. Thread 1 only ever touches counter A. Thread 2 only ever touches counter B. They never read each other’s data. By every rule of concurrency you were taught, this should scale linearly.</p><p>It doesn’t. On real hardware the throughput can collapse by a factor of four or five, and nothing in your source code explains why.</p><p>The reason is that a CPU doesn’t move memory a byte or a variable at a time. It moves it a <strong>cache line</strong> at a time – 64 bytes on essentially every x86–64 machine you’ll deploy on. If counter A and counter B happen to land in the same 64-byte line – and two adjacent longs almost certainly will – the moment Thread 1 writes A, the cache-coherence protocol (MESI) marks that whole line invalid in Thread 2’s core. Thread 2’s next read of B (a variable Thread 1 never touched) now has to re-fetch the line. Then Thread 2 writes B, and the favor is returned. The line ping-pongs between the two cores, thousands of times a second, at the speed of the slowest thing in the machine.</p><p>This is <strong>false</strong> sharing, and it’s one of the purest examples in computing of code that looks parallel while the hardware quietly serializes it.</p><p>The numbers are brutal and reproducible. A clean benchmark of a padded counter versus a false-shared one: <strong>523 million ops/sec drops to 113 million</strong> (~ about 4.6x) with <em>no change to the logic</em>, only to where the two variables sit in memory. Add the padding back and the gap vanishes.</p><p>The fix is exactly as dumb as the problem: push the two variables onto separate cache lines. Historically you did it by hand: the LMAX Disruptor famously padded its sequence counter with seven longs on each side so nothing else could share its line. Modern Java gives you the <em>@Contended</em> annotation (run with <em>-XX:-RestrictContended</em> for your own classes), which pads for you. It pads by 128 bytes, not 64, because the prefetcher likes to grab two lines at a time. Even the fix has to know the hardware.</p><h3>But won’t a newer JVM just fix this for me?</h3><p>This is the reasonable question, and the answer is no. Understanding why is the whole point.</p><p>The JVM can’t fix false sharing in general, because it’s a property of runtime behaviour: which threads hammer which fields on which cores. That’s invisible at layout time, and padding every field onto its own cache line would blow up your memory footprint. So HotSpot doesn’t. In fact its field-layout algorithm does the opposite of what you’d hope. It packs your fields closer together to eliminate gaps (and since JDK 15 it will even tuck a subclass’s fields into a superclass’s spare alignment slots), which if anything makes false sharing more likely, not less.</p><p>What the JDK does fix is false sharing inside its own concurrent classes. <em>LongAdder</em>, <em>ConcurrentHashMap</em>‘s counters, <em>ForkJoinPool</em>, the RNG seeds in Thread, all annotated <em>@Contended</em> internally. Use those and you’re covered. For your hot fields, <em>@Contended</em> exists but ships inert on user classes: it does nothing unless you launch with <em>-XX:-RestrictContended</em>. The fix is in the box; the box is locked by default.</p><p>And the worst case is the one you can’t annotate at all: adjacent elements of a long[] written by different threads. <em>@Contended</em> doesn’t apply to array slots, so there the only fix is still manual index spacing which is exactly what the Disruptor did. The newer toys don’t rescue you either: compact object headers (JDK 24/25) pack objects tighter, and if Project Valhalla starts flattening value arrays, it can reintroduce array-level false sharing in a fresh coat of paint. One more detail to file away: that 64-byte line you padded against is 128 bytes on Apple Silicon under macOS; so even “the cache line is 64 bytes” is a hardware assumption, not a law.</p><p>The theme survives contact with every JVM version: the machine does not guess your access pattern. You have to tell it.</p><h3>Mechanical sympathy</h3><p><strong>There’s a name for this way of thinking</strong>, and it didn’t come from software. It came from Sir Jackie Stewart, the three-time Formula 1 champion, who said you don’t have to be an engineer to be a racing driver but you do need <strong><em>mechanical sympathy</em></strong>. You have to understand what the machine is doing underneath you to get the most out of it without breaking it.</p><p>Martin Thompson brought the phrase into our world, and it’s the cleanest one-line rebuttal to the idea that the JVM lets you forget about the metal. It doesn’t. It just lets you pretend to, right up until the tail latency arrives.</p><h3>The payoff: throwing away the “correct” data structure</h3><p>The best demonstration is the one Thompson’s team built. LMAX ran a retail exchange on the JVM, and when they profiled it, the bottleneck wasn’t their business logic, it was the humble queue passing events between threads. <em>ArrayBlockingQueue</em>, the textbook-correct choice, conflates producer, consumer, and storage on the same handful of variables, and the locks it needs drag the kernel into the hot path.</p><p>So they threw it out and built <strong>the Disruptor</strong>: a pre-allocated ring buffer that respects the cache line and obeys a single-writer rule, so no two cores ever fight to mutate the same thing. The result reads like a typo. Mean latency per hop fell from 32,757 nanoseconds for the queue to 52 nanoseconds for the ring (three orders of magnitude) with roughly eight times the throughput, sustaining over 25 million messages per second, which the paper notes is close to the physical limit of moving data between cores at all.</p><p>None of that came from a better algorithm. The queue and the ring are both, in the abstract, O(1). The ring wins because it’s laid out for the machine: contiguous memory the prefetcher can predict, entries reused so the garbage collector never sees them, and no shared mutable state to invalidate.</p><h3>Why layout beats Big-O</h3><p>Here’s the uncomfortable part for anyone who grinds algorithm interviews. Big-O is built on a RAM model of the computer that assumes every memory access costs the same. That assumption has been false for thirty years. An <strong>L1 cache hit costs about a nanosecond; a miss out to main memory costs around a hundred</strong>. That’s not a rounding error. That’s a 100x tax the notation cannot see.</p><p>So the “worse” structure that stays in cache routinely beats the “better” one that chases pointers across RAM. Bjarne Stroustrup has a famous talk showing a plain array (ArrayList) beating a linked list even on insert-and-delete workloads that theory says should favor the list, because walking scattered nodes is a parade of cache misses, and the array’s linear scan lives entirely in cache.</p><p>This is where idiomatic Java quietly hurts you. An <em>Object[] </em>isn’t your data; it’s an array of pointers to your data, scattered across the heap. A <em>HashMap&lt;Integer, Order&gt;</em> spreads a single logical entry across the map, its table, an entry object, a boxed key, and a boxed value – five separate hops for one lookup, most of them cache misses. Every object carries a 12-to-16-byte header before your first field. None of this shows up in Big-O, and all of it shows up in your p99.</p><p>The shops that run Java at the sharp end know this and build around it: contiguous primitive arrays and struct-of-arrays layouts instead of object graphs, primitive collections (Agrona, fastutil, Eclipse Collections) instead of boxed ones, off-heap memory-mapped storage (Chronicle) so terabytes of data live somewhere the garbage collector never looks.</p><h3>The JVM isn’t the enemy</h3><p>The usual reflex, the moment latency spikes, is “rewrite it in C++.” Sometimes that’s right. Often the real culprit is a stop-the-world GC pause landing exactly when the market moves, or a JIT that’s still running your hottest method in the interpreter because it hasn’t warmed up yet. Those are real problems but they’re problems of discipline, not of language. Zero-allocation steady state, object pooling, off-heap buffers, low-pause collectors, and a data layout that respects the cache line get you microsecond Java that holds its tail.</p><p>LMAX, Aeron, Agrona, and Chronicle are the existence proof. Jane Street reached for OCaml instead – a deliberate language choice, not a magic one, since OCaml is itself pointer-heavy. The lesson isn’t “Java wins” or “Java loses.” It’s that the winners, whatever language they picked, program against the hardware rather than pretending it isn’t there.</p><p>Which brings it back to the counter that got slower every time we added a thread. We didn’t fix it with a cleverer algorithm or a faster language. We fixed it by moving two variables 64 bytes apart.</p><p>Design for the cache line first. Optimize the Big-O second. In that order – because the machine was never going to read your asymptotic analysis.</p><p><em>This continues a series on where the real edge hides in trading systems – the earlier piece, </em><a href="https://medium.com/the-converging-line/your-hft-edge-was-never-c-its-the-cable-f963ea965782"><em>It was never the code. It’s the cable</em></a><em>, makes the same argument one layer down, in the physics of the wire. Disruptor figures are from the </em><a href="https://lmax-exchange.github.io/disruptor/disruptor.html"><em>LMAX technical paper</em></a><em> (Thompson, Farley, Barker, Gee, Stewart, 2011); false-sharing numbers are hardware-dependent – measure your own.</em></p><p>#LowLatency #JavaPerformance #MechanicalSympathy #HFT #TradingSystems #CPUCache</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d6457dbc1d8f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/the-converging-line/big-o-was-never-the-bottleneck-the-cache-line-was-d6457dbc1d8f">Big-O Was Never the Bottleneck. The Cache Line Was.</a> was originally published in <a href="https://medium.com/the-converging-line">The Converging Line</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Your HFT Edge Was Never C++. It's the Cable.]]></title>
            <link>https://medium.com/the-converging-line/your-hft-edge-was-never-c-its-the-cable-f963ea965782?source=rss-f562541003cb------2</link>
            <guid isPermaLink="false">https://medium.com/p/f963ea965782</guid>
            <category><![CDATA[finance]]></category>
            <category><![CDATA[fintech]]></category>
            <category><![CDATA[high-frequency-trading]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Lorenzo Vangi]]></dc:creator>
            <pubDate>Tue, 21 Jul 2026 09:01:03 GMT</pubDate>
            <atom:updated>2026-07-21T09:01:03.380Z</atom:updated>
            <content:encoded><![CDATA[<h4><em>A vendor cost guide told me the language was the moat. A CTO I deeply respect told me what it left out — and almost none of it is code.</em></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2-7MIioQ808LiQdny1ezvw.png" /></figure><p>Low-latency trading has a founder myth, and the myth goes like this: the fast firms are fast because they write better C++. I believed a gentler version of it for years (six of them at ION, elbow-deep in trading infrastructure) until I stopped confusing the thing I could control with the thing that actually won.</p><p>The reminder came from a cost guide. It’s a decent one, honestly: it lays out colocation fees, market-data feeds, FPGA budgets, and the exponential (not linear) way that cost scales as you chase the last microsecond. You can read it <a href="https://westernpips.com/hft-infrastructure-cost.html">here</a>. Its headline claim is the orthodox one: C and C++ are the standard, Python is categorically unsuitable, and the code is where the race is won.</p><p>I sent it to a CTO I deeply respect, someone who has actually built these systems at the sharp end. His reply was two lines of agreement and then a demolition of the emphasis. “I doubt C/C++ gives the advantage,” he wrote. Then he listed what the guide never mentions: the router, the firewall you rip out, the BIOS manual you actually read, the length of cable to the market, and microwave. That reply is the reason for this article.</p><h3>The HFT advantage is not the language you chose</h3><p>Here’s the uncomfortable reframe. Once you are already in a compiled, garbage-collector-free stack, the language is table stakes, not an edge. Everyone at the front of the queue is running tight C++ with no allocations in the hot path. Choosing C++ over Python is the price of a ticket, not a seat at the front.</p><p>The real gap opens somewhere else. A well-optimized software tick-to-trade path lives around 3 to 8 microseconds on a good day, and 10 to 50 in the wild. An FPGA doing the same parse-decide-fire in parallel logic lives at 100 to 500 nanoseconds. And the current record, set on an AMD Alveo UL3524 running Exegy’s stack in the STAC-T0 benchmark, is an actionable latency of 13.9 nanoseconds — a 49% cut on the prior 24.2 ns mark.</p><p>Sit with those numbers. The distance between “good C++” and “great C++” is measured in tens or hundreds of nanoseconds. The distance between software and silicon is two orders of magnitude. You cannot out-type that gap.</p><p>I learned this the expensive way. I once spent the better part of two weeks shaving a hot path (branch layout, cache lines, the works), proud of a couple of microseconds clawed back. A competitor beat us on the same signal anyway. Their edge wasn’t their code. It was a shorter cable and a better switch. I had optimized the one layer I understood and ignored the four that mattered more.</p><h3>Silicon and kernel bypass beat syntax</h3><p>So where do the nanoseconds actually get won? Start at the wire. In a normal server, an inbound packet crawls through the NIC, the driver, an interrupt, the kernel’s TCP/IP stack, and a copy into user space before your code ever sees it: tens of microseconds of latency and, worse, jitter. Kernel bypass deletes that journey. Solarflare’s Onload (now under AMD), the lower-level ef_vi ring API, TCPDirect: they map the NIC’s buffers straight into user space so the application reads packets directly. That alone drops network latency from the 20–50 µs range into the low single-digit microseconds.</p><p>The deeper move (the one the CTO pointed at with “FIX/FAST/binary decoders on Solarflare on load”) is to decode the market-data protocol in hardware, as the bytes arrive, before a CPU cache line even warms. FPGA feed handlers from the likes of NovaSparks and Enyx parse FIX, FAST, and binary book updates in the fabric itself, building the order book in sub-microsecond time. The CPU is no longer parsing; it’s reacting to a decision that’s already half-made.</p><p>This is why “C++ is dead in HFT” is the wrong conclusion to draw. FPGAs are miserable at complex, branchy strategy logic. The winning shops run hybrids: FPGA for the deterministic hot path, C++ (Rust / Go / Java) for strategy, risk, and orchestration. The language still matters. It just stopped being the moat.</p><h3>The network is the strategy: Arista, no firewall, and cable length</h3><p>The CTO’s next point was blunt: use a decent router like Arista, and run with no firewall. Both are correct, and both are about latency, not networking fashion.</p><p>Arista’s 7130 Layer-1 devices forward port-to-port in as little as 4–5 nanoseconds. Their MetaMux muxes orders from several servers up to the exchange in around 39 ns. A traditional stateful enterprise firewall, by contrast, sits in the hundreds of microseconds. When compliance forces the issue, you reach for a stateless FPGA filter like Arista’s MetaProtect (135 ns with filtering, 5 ns when a port-pair passes through), not a box that would erase your entire edge in one hop.</p><p>And then there’s the cable: the point that sounds like a joke until you do the arithmetic. Light in single-mode fiber travels at roughly 204,000 km/s, about 68% of its vacuum speed. That works out to about 5 nanoseconds per meter. Five nanoseconds. Per meter. This is why exchanges hand out equidistant cabling to every colocation tenant (for example, CME’s GLink is explicitly equidistant) so that no one wins on a shorter run of glass. It’s also why IEX did the opposite on purpose, coiling 38 miles of fiber into a box to manufacture a deliberate 350-microsecond speed bump. The cable isn’t plumbing. It’s part of the strategy.</p><h3>The BIOS is where the latency hides</h3><p>“Reading BIOS manuals to set power and CPU throttling,” the CTO wrote, almost in passing. This is the least glamorous discipline in the whole stack and one of the most decisive, because it kills jitter, the real silent tail-latency killer.</p><p>The recipe is well documented in Red Hat’s and Dell’s low-latency guides, and in practitioner writeups like Erik Rigtorp’s. Disable C-states so a core never drops into a deep sleep it takes microseconds to wake from. Disable Turbo Boost and frequency scaling so the clock is fixed and predictable rather than fast-but-variable. Disable hyperthreading so a core belongs to one thread. Kill System Management Interrupts, pin threads and IRQs, isolate cores, lock memory so nothing page-faults mid-trade. None of this makes your average case dramatically faster. All of it makes your worst case behave and in this game the worst case is the one that costs you the trade.</p><h3>When glass is too slow: microwave</h3><p>The last thing the guide never said is that on the long routes, fiber has already lost. Microwave through air travels about 50% faster than light through glass — air’s refractive index is close to 1, glass is around 1.5 — and it flies in a straighter line. On the Chicago-to-New-Jersey corridor that runs the whole US equity and futures complex, microwave gets one-way latency down to roughly 4 milliseconds against a hard speed-of-light floor of about 3.93 ms. Spread Networks’ famous straighter-than-straight fiber, reportedly a $300M build, was rendered a museum piece almost the moment the microwave towers went up.</p><p>This matters most, as the CTO noted, in fixed income. Fed economists Dobrev and Schaumburg found that CME Treasury futures in Aurora, Illinois lead the cash market on BrokerTec in New Jersey by a clean 5-millisecond offset, and not the other way around, almost exactly the light-travel time between the two. That’s the honest reading of his line about the market being “mostly inverted”: the derivative leads the underlying, and information flows Chicago to New Jersey, which is precisely why the basis trade lives or dies on the microwave link between Aurora and Carteret. CME is now collapsing that geography entirely, co-locating cash Treasuries next to the futures but the physics of who-knows-first is why the towers exist at all.</p><h3>What the guides are really selling</h3><p>Here’s what I keep coming back to. The cost guide isn’t wrong about the money. It’s wrong about the story. It sells the comforting idea that the edge is a thing you write, because that’s the thing a reader can imagine buying. The truth is that the edge is a stack of physical facts: a switch measured in nanoseconds, a cable measured in meters, a BIOS flag most engineers never touch, a tower pointed across three states.</p><p>What I am sure of is narrower, and it’s the thing I wish the guide had led with: if you want to understand where a trading firm’s speed comes from, don’t read only its code. Measure its cable.</p><p>#HFT #HighFrequencyTrading #LowLatency #TradingSystems #FPGA #Fintech #QuantitativeTrading #MarketMicrostructure #SoftwareEngineering #CapitalMarkets</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f963ea965782" width="1" height="1" alt=""><hr><p><a href="https://medium.com/the-converging-line/your-hft-edge-was-never-c-its-the-cable-f963ea965782">Your HFT Edge Was Never C++. It&#39;s the Cable.</a> was originally published in <a href="https://medium.com/the-converging-line">The Converging Line</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Python and Java Concurrency in 2026: Two Languages, Two Philosophies, One Problem]]></title>
            <link>https://medium.com/the-converging-line/python-and-java-concurrency-in-2026-two-languages-two-philosophies-one-problem-f638026772dc?source=rss-f562541003cb------2</link>
            <guid isPermaLink="false">https://medium.com/p/f638026772dc</guid>
            <category><![CDATA[performance-engineering]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[performance-optimization]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Lorenzo Vangi]]></dc:creator>
            <pubDate>Tue, 26 May 2026 10:01:02 GMT</pubDate>
            <atom:updated>2026-05-26T10:01:02.705Z</atom:updated>
            <content:encoded><![CDATA[<h4>The GIL is finally optional. Project Loom is stable. Here’s what concurrency actually looks like in both languages today. Real benchmarks and no religious wars.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xC9dHUYW-DQIPDWl2qM5ww.png" /><figcaption>Python vs Java: Concurrency in 2026</figcaption></figure><p>Every engineer hits the concurrency wall at some point.</p><p>The service is slow. The profiler says the code is fast. The CPU has sixteen cores. Twelve of them are idle.</p><p>At that point, the question isn’t <em>whether</em> to use concurrency. It’s <em>which model</em>, in which language, for which workload. And the honest answer is that it depends on what you’re actually trying to do.</p><p>Python and Java have both made significant moves recently. Python 3.13 shipped a <em>“free-threaded build”</em> that makes the GIL <em>“optional”</em> for the first time ever. Java 21 finalized virtual threads via Project Loom, eliminating the platform thread-per-request model without touching existing code. Both are real changes, not marketing.</p><p>This article walks through what concurrency looks like in both languages today, with code that runs, benchmarks grounded in published data, and a conclusion that doesn’t crown a winner.</p><h4>The Python Concurrency Model: then and now</h4><p>Python has four concurrency primitives. Understanding all four matters because no single one is correct in all situations.</p><blockquote>Threads: the lock that defined Python for 30 years</blockquote><p>Python threads are OS Threads, but they share a single interpreter lock: the <a href="https://it.wikipedia.org/wiki/Global_Interpreter_Lock">GIL (Global Interpreter Lock)</a>. The GIL ensures only one thread executes Python bytecode at any moment. For CPU-bound code, adding threads adds context-switching overhead without adding parallelism.</p><pre>import threading<br>import time<br><br>def cpu_bound(n):<br>    count = 0<br>    while count &lt; n:<br>        count += 1<br><br># 4 threads on CPU-bound work — actually slower than sequential on CPython 3.12<br>start = time.time()<br>threads = [threading.Thread(target=cpu_bound, args=(50_000_000,)) for _ in range(4)]<br>for t in threads: t.start()<br>for t in threads: t.join()<br>print(f&quot;4 threads: {time.time() - start:.2f}s&quot;)<br><br>start = time.time()<br>for _ in range(4): cpu_bound(50_000_000)<br>print(f&quot;Sequential: {time.time() - start:.2f}s&quot;)<br># Result: threads ~10.2s, sequential ~8.4s — the GIL makes it worse</pre><p>For I/O-bound work the picture reverses. The GIL is released during blocking I/O (network, disk, database). Threads genuinely overlap:</p><pre>import threading<br>import urllib.request<br>import time<br><br>urls = [&quot;https://httpbin.org/delay/1&quot;] * 4<br><br>def fetch(url):<br>    urllib.request.urlopen(url)<br><br>start = time.time()<br>threads = [threading.Thread(target=fetch, args=(url,)) for url in urls]<br>for t in threads: t.start()<br>for t in threads: t.join()<br>print(f&quot;4 threads, I/O bound: {time.time() - start:.2f}s&quot;)<br># ~1.1s instead of ~4s sequential — threads work here</pre><blockquote>Multiprocessing: true parallelism at a cost</blockquote><p>For CPU-bound parallel work on Python ≤3.12, multiprocessing is the answer. Each process has its own interpreter and its own GIL meaning a true parallel execution.</p><pre>from multiprocessing import Pool<br>import time<br><br>def cpu_bound(n):<br>    count = 0<br>    while count &lt; n:<br>        count += 1<br>    return count<br><br>if __name__ == &quot;__main__&quot;:<br>    start = time.time()<br>    with Pool(processes=4) as pool:<br>        pool.map(cpu_bound, [50_000_000] * 4)<br>    print(f&quot;4 processes: {time.time() - start:.2f}s&quot;)<br>    # ~2.3s — near-linear speedup vs sequential 8.4s</pre><p>The trade-off: spawning overhead, serialization between processes (pickle), and no shared memory by default. For coarse-grained parallelism, it wins cleanly. For fine-grained, shared-state workloads, the overhead dominates.</p><blockquote>asyncio: cooperative concurrency for I/O workflows</blockquote><p>asyncio is Python&#39;s cooperative concurrency model. A single thread runs an event loop. Tasks yield control when waiting on I/O. No parallelism but also no GIL contention, no threading overhead, and extremely low memory per concurrent operation.</p><pre>import asyncio<br>import aiohttp<br>import time<br><br>async def fetch(session, url):<br>    async with session.get(url) as response:<br>        return await response.text()<br><br>async def main():<br>    urls = [&quot;https://httpbin.org/delay/1&quot;] * 100<br>    start = time.time()<br>    async with aiohttp.ClientSession() as session:<br>        results = await asyncio.gather(*[fetch(session, url) for url in urls])<br>    print(f&quot;100 concurrent requests: {time.time() - start:.2f}s&quot;)<br>    # ~1.2s — 100 concurrent I/O operations, single thread<br><br>asyncio.run(main())</pre><p>For high-concurrency I/O, thousands of simultaneous connections, streaming APIs, WebSocket handlers, asyncio is Python’s strongest primitive.</p><h4>Python 3.13 and the optional GIL</h4><p>Python 3.13, released October 2024, ships with an <em>experimental </em>free-threaded build where the GIL is disabled. Python 3.14 removed the “experimental” label: free-threading is now a supported build option going forward.</p><pre># Install free-threaded build (macOS/Linux)<br>pyenv install 3.13t<br>python3.13t --version<br># Python 3.13.0 experimental free-threading build<br><br># Verify GIL status<br>python3.13t -c &quot;import sys; print(sys._is_gil_enabled())&quot;<br># False</pre><pre># Same CPU-bound code from above — now on 3.13t<br>import threading, time<br><br>def cpu_bound(n):<br>    count = 0<br>    while count &lt; n:<br>        count += 1<br><br>start = time.time()<br>threads = [threading.Thread(target=cpu_bound, args=(50_000_000,)) for _ in range(4)]<br>for t in threads: t.start()<br>for t in threads: t.join()<br>print(f&quot;4 threads, no GIL: {time.time() - start:.2f}s&quot;)<br># ~2.4s — near-linear speedup. Threads now actually run in parallel.</pre><p>The result: for CPU-bound workloads with four threads, Python 3.13t delivers roughly 2.8x speedup versus single-threaded compared to effectively no gain on 3.12. For I/O-bound workloads, the difference is marginal as the GIL was already released during blocking I/O calls.</p><p>One caveat: the free-threaded build carries a ~5–10% single-thread overhead due to per-object locking replacing the global lock. If you’re not using threads, the standard build is still faster for single-threaded workloads.</p><h4>The Java Concurrency Model: from platform threads to Project Loom</h4><p>Java’s concurrency model is older, more layered, and, as of Java 21, genuinely transformed.</p><blockquote>Platform Threads: the original model</blockquote><p>Java threads map 1:1 to OS threads. Each one maps to an OS thread with a default stack of roughly 256KB–512KB depending on platform and JVM version (configurable via -Xss, but rarely tuned). At 10,000 concurrent platform threads, you&#39;re looking at 2.5–5GB of stack alone (approx), before heap allocations, thread-local state, or OS-level bookkeeping. The ceiling is real and hits faster than most teams expect the first time they try to scale a thread-per-request service.</p><pre>import java.util.concurrent.ExecutorService;<br>import java.util.concurrent.Executors;<br><br>// Traditional pool — bounded by OS resources<br>ExecutorService executor = Executors.newFixedThreadPool(200);<br><br>for (int i = 0; i &lt; 10_000; i++) {<br>    executor.submit(() -&gt; {<br>        // blocking I/O here = platform thread is blocked<br>        processRequest();<br>    });<br>}<br>// 9,800 requests are queued. Throughput is capped at pool size.</pre><p>The fixed thread pool is the standard mitigation as you cap concurrency at a manageable number. The cost: requests queue when all threads are busy, and pool tuning becomes an art form rather than a science.</p><h4>Virtual Threads: Project Loom, stable since Java 21</h4><p>Virtual threads are managed by the JVM rather than the OS. They’re cheap to create and the JVM multiplexes them onto a small pool of carrier threads transparently. When a virtual thread blocks on I/O, the carrier thread is released immediately to run other virtual threads.</p><pre>import java.util.concurrent.Executors;<br><br>// Virtual thread per task — no pool size tuning needed<br>try (var executor = Executors.newVirtualThreadPerTaskExecutor()) {<br>    for (int i = 0; i &lt; 100_000; i++) {<br>        executor.submit(() -&gt; {<br>            // blocks on I/O — virtual thread yields,<br>            // carrier thread picks up the next task immediately<br>            processRequest();<br>        });<br>    }<br>}<br>// 100,000 concurrent tasks. No OOM. No queue buildup.<br>// Memory: ~few KB per virtual thread vs ~1MB per platform thread</pre><p>No async/await. No reactive operators. No architectural rewrite. The API is identical to the platform thread API. You change the executor, nothing else.</p><h4>Structured Concurrency: Java 25+</h4><p>Structured concurrency addresses a failure mode both threads and coroutines share: subtasks that outlive their parent scope on failure.</p><pre>import java.util.concurrent.StructuredTaskScope;<br><br>String fetchUserAndOrders(long userId) throws Exception {<br>    try (var scope = new StructuredTaskScope.ShutdownOnFailure()) {<br>        var user   = scope.fork(() -&gt; userService.fetch(userId));<br>        var orders = scope.fork(() -&gt; orderService.fetchByUser(userId));<br><br>        scope.join().throwIfFailed();<br>        // if userService throws, orderService is cancelled automatically<br>        // no orphaned threads, no resource leaks<br><br>        return user.get().name() + &quot;: &quot; + orders.get().size() + &quot; orders&quot;;<br>    }<br>}</pre><p>Virtual threads pin to their carrier thread inside synchronized blocks. A pinned virtual thread holds the carrier while blocked, negating scalability. The fix: replace synchronized with ReentrantLock on hot I/O paths.</p><pre>// Pins the carrier thread — avoid on I/O paths<br>synchronized(lock) {<br>    someBlockingIoCall(); // carrier blocked until this returns<br>}<br><br>// Releases the carrier — correct with virtual threads<br>lock.lock();<br>try {<br>    someBlockingIoCall(); // carrier freed during the I/O wait<br>} finally {<br>    lock.unlock();<br>}</pre><p>Most modern Java libraries have already addressed this. Older codebases may need review before migrating to virtual threads.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YR1vm7DmAtqicx91niIk4Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i2NGBLQdX3g1ERYylD3n_g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OUZarprjabWpyrzokaAlhg.png" /></figure><h4>The Benchmark Reality</h4><p>Raw numbers from published benchmarks on comparable hardware (4-core systems, CPU-bound task: prime sieve to 1,000,000):</p><p><strong>CPU-bound, 4 threads:</strong></p><ul><li><strong>Python 3.12 (GIL)</strong>: ~same as single-threaded or slightly slower</li><li><strong>Python 3.13t (no GIL)</strong>: ~3.0x faster than single-threaded</li><li><strong>Java platform threads</strong>: ~3.6x faster than single-threaded</li><li><strong>Java virtual threads</strong>: ~3.5x (virtual threads don’t help CPU-bound, carrier threads are still OS-bounded)</li></ul><p><strong>I/O-bound, 1000 concurrent requests:</strong></p><ul><li><strong>Python threading</strong>: limited by thread creation overhead, ~600–800 RPS practical ceiling</li><li><strong>Python asyncio</strong>: ~8,000–12,000 RPS on a single core</li><li><strong>Java platform threads (pool=200)</strong>: ~5,000 RPS, then queuing</li><li><strong>Java virtual threads</strong>: ~15,000–20,000 RPS, scales with I/O capacity, not thread count</li></ul><p><strong>Memory at 10,000 concurrent tasks:</strong></p><ul><li>Python asyncio coroutines: ~100MB</li><li>Python threads: ~80GB theoretical (upperbounded, OS limits kick in earlier)</li><li>Java virtual threads: ~300MB</li><li>Java platform threads: ~5GB (depending on platform and JVM)</li></ul><p>These are directional numbers. Your workload, your hardware, your I/O profile.</p><h4>Choosing the right tool: by context, not religion</h4><p>Here’s where most language comparison articles go wrong: they pick a winner. There isn’t one. There are contexts.</p><blockquote>When is Python concurrency the right answer?</blockquote><ol><li><strong>Data pipelines and ML preprocessing.</strong> Python’s ecosystem — NumPy, pandas, PyTorch, scikit-learn — is unmatched. Most of the heavy computation is already offloaded to C extensions that release the GIL. Multiprocessing handles the orchestration layer cleanly. Adding free-threading in 3.13t starts to close the remaining gaps.</li><li><strong>High-concurrency I/O services with rapid iteration.</strong> A scraper, an API aggregator, a notification service. asyncio with aiohttp or httpx handles thousands of concurrent connections on a single core. The development speed advantage of Python compounds here: the service is simpler to write, simpler to change, and the I/O concurrency is genuinely competitive.</li><li><strong>Scientific computing and simulation.</strong> Multiprocessing with worker pools maps naturally to embarrassingly parallel workloads. Python 3.13t makes shared-memory parallelism viable for the first time without the process-spawn overhead.</li><li><strong>Scripting and automation.</strong> Threads with I/O release. Fast to write, easy to reason about, good enough for the concurrency requirements of most automation workloads.</li></ol><blockquote>When is Java concurrency the right answer?</blockquote><ol><li><strong>High-throughput backend services under sustained load.</strong> Virtual threads make the thread-per-request model viable at a scale that was previously only achievable with reactive frameworks. A Spring Boot service that migrates its executor to virtual threads often sees 3–5x throughput improvement with no code changes beyond that swap.</li><li><strong>Trading infrastructure and financial systems.</strong> The JVM’s predictable GC behavior (especially ZGC on Java 21+), mature concurrency primitives, and the absence of a GIL equivalent make Java the standard choice for systems where latency outliers matter. Platform threads with explicit pool management give you full control over scheduling behavior.</li><li><strong>Long-running services with complex concurrent state.</strong> Java’s type system, structured concurrency and the java.util.concurrent toolkit (ConcurrentHashMap, CompletableFuture, StampedLock) provide primitives that scale to complex concurrent state machines without the sharp edges of Python&#39;s threading model.</li><li><strong>Microservices at scale.</strong> Virtual threads eliminate the reactive framework tax. You can write synchronous-looking code that handles hundreds of thousands of concurrent connections. The operational simplicity of that model is worth a great deal at scale.</li></ol><h4>The honest matrix</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/950/1*s4pUeCkZq6iSppFjeaoZFA.png" /><figcaption>Neither language wins all axes</figcaption></figure><h4>What’s Actually Changing</h4><p>The gap is narrowing from both sides.</p><p>Python 3.13t is the most significant change to Python’s execution model since the language was created. The roadmap to GIL-disabled-by-default extends to 2028–2030, but the option exists today. For teams that have been hitting the GIL ceiling on CPU-bound Python code, this is worth testing NOW.</p><p>Java’s virtual threads close the last major concurrency argument that Node.js and Python’s asyncio had over the JVM. You no longer need a reactive framework to handle 100,000 concurrent connections. Blocking-style code scales. That simplifies a large class of Java microservices considerably.</p><p>Neither of these changes makes the other language obsolete. They make both languages more capable in their respective domains. And they shift the question from “which language handles concurrency better” to “which concurrency model fits this specific workload.”</p><p>That’s the question worth asking. The language is usually already decided by the time you’re tuning a concurrency model: by your team’s expertise, your ecosystem requirements, your operational constraints. Work with that reality, not against it.</p><p>The best concurrency code isn’t the fastest. It’s the one your team can reason about, debug at 2am, and change six months later without introducing a race condition in the process.</p><p><em>The patterns described here reflect direct experience building concurrent systems in both Java and Python. Benchmark numbers are directional — always profile against your own workload before making architectural decisions.</em></p><p><em>If you’re building trading infrastructure on the JVM, the previous articles in this series cover </em><a href="https://medium.com/the-converging-line/building-a-fix-4-4-lp-integration-with-quickfix-j-every-decision-that-actually-mattered-3448a0f79767"><em>FIX 4.4 LP integration with QuickFIX/J</em></a><em> and </em><a href="https://medium.com/the-converging-line/project-panama-the-end-of-jni-and-the-beginning-of-real-native-java-757849584fe4"><em>Project Panama: the end of JNI</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f638026772dc" width="1" height="1" alt=""><hr><p><a href="https://medium.com/the-converging-line/python-and-java-concurrency-in-2026-two-languages-two-philosophies-one-problem-f638026772dc">Python and Java Concurrency in 2026: Two Languages, Two Philosophies, One Problem</a> was originally published in <a href="https://medium.com/the-converging-line">The Converging Line</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Project Panama: The End of JNI and the Beginning of Real Native Java]]></title>
            <link>https://medium.com/the-converging-line/project-panama-the-end-of-jni-and-the-beginning-of-real-native-java-757849584fe4?source=rss-f562541003cb------2</link>
            <guid isPermaLink="false">https://medium.com/p/757849584fe4</guid>
            <category><![CDATA[performance-engineering]]></category>
            <category><![CDATA[ffm]]></category>
            <category><![CDATA[jvm]]></category>
            <category><![CDATA[project-panama]]></category>
            <category><![CDATA[low-latency]]></category>
            <dc:creator><![CDATA[Lorenzo Vangi]]></dc:creator>
            <pubDate>Mon, 18 May 2026 07:01:00 GMT</pubDate>
            <atom:updated>2026-05-18T07:57:57.902Z</atom:updated>
            <content:encoded><![CDATA[<h4>Java has had a native interop story since 1.1. It was always broken. FFM API, finalized in Java 22, finally fixes it without a single line of C glue code.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*UtGscGFypccIC4Oz.png" /></figure><p>If you’ve ever needed to call a C library from Java, you know exactly how the afternoon goes.</p><p>You write a Java class with a native method declaration. You run javac -h to generate a C header. You write a C wrapper function with JNIEnv* threading through every signature. You compile it into a shared library with platform-specific flags you half-remember from a Stack Overflow answer from 2014. You load it with System.loadLibrary. You run it, and either it works or the JVM segfaults with no useful output.</p><p>Then you change one parameter type and do it all again.</p><p>JNI has been the official mechanism for Java-native interop since Java 1.1. It works. It also hasn’t fundamentally changed in thirty years, which is not a compliment. The boilerplate is significant, the error surface is large, and the debugging experience when something goes wrong is painful in a way that’s hard to overstate.</p><p>Project Panama is the OpenJDK initiative that replaces this entire model. Its core deliverable — the Foreign Function &amp; Memory API — was finalized in Java 22 under <a href="https://openjdk.org/jeps/454">JEP 454</a> in March 2024. The implementation effort compared to JNI has been reduced by roughly 90%, and the FFM API benchmarks are equal to or faster than JNI for equivalent operations. This is not a wrapper around JNI. It’s a replacement built from different first principles.</p><p>This article walks through what that replacement looks like in practice — the abstractions, the mechanics, and the code that actually runs.</p><h3>Why JNI Was Always the Wrong Answer</h3><p>JNI didn’t fail because it was poorly designed. It failed because the design constraints of 1996 don’t match what production Java systems look like in 2025.</p><p>The model is this: you declare a native method in Java, compile it, generate a C header from the bytecode, implement that header in C, compile the C into a shared library, and load the library at runtime. Every step is manual. Every step is platform-specific. Every step is disconnected from the others.</p><p>The consequences are predictable:</p><p><strong>Type unsafety across the boundary.</strong> JNI passes JNIEnv* into every C function call. That pointer is untyped from Java’s perspective. If you get the signature wrong — wrong number of arguments, wrong types, wrong return type — you get a JVM crash, not a ClassCastException. The VM has no way to validate the mismatch.</p><p><strong>Memory that JVM doesn’t own.</strong> If you allocate native memory inside a JNI call and forget to free it, the garbage collector doesn’t know and doesn’t help. You leak silently. This is a class of bug that’s genuinely hard to detect in production because it doesn’t produce errors — it just slowly exhausts off-heap memory.</p><p><strong>Build complexity.</strong> A JNI project is actually two projects: a Java project and a C project, with a shared contract that’s expressed in generated header files. Any refactoring that touches the boundary requires coordination between both sides, and the compiler won’t tell you when they’re out of sync.</p><p><strong>Performance overhead.</strong> Every JNI call crosses a boundary that the JIT cannot see through. The call has overhead: thread state transitions, argument marshalling, the JNIEnv* machinery. For high-frequency calls — which is exactly when you’d want native performance — this overhead is non-trivial.</p><p>Panama’s FFM API eliminates all of these at the design level, not by patching JNI but by replacing the entire model.</p><h3>The Three Abstractions That Matter</h3><p>The FFM API lives in java.lang.foreign. Before writing code, you need to understand three things: MemorySegment, Arena, and Linker. Everything else is built on these.</p><h4>MemorySegment — Memory That Knows Its Bounds</h4><p>MemorySegment represents a contiguous region of memory. It can be on-heap or off-heap. What distinguishes it from a raw pointer or a ByteBuffer is that it carries explicit spatial bounds.</p><pre>// allocate 1024 bytes of off-heap memory<br>try (Arena arena = Arena.ofConfined()) {<br>    MemorySegment buffer = arena.allocate(1024);<br>    buffer.set(ValueLayout.JAVA_INT, 0, 42);         // write int at offset 0<br>    int value = buffer.get(ValueLayout.JAVA_INT, 0); // read it back<br>}</pre><p>If you try to access offset 1025 on a 1024-byte segment, you get an IndexOutOfBoundsException. In JNI, the same mistake produces a segfault. This is the entire difference, and it matters enormously for debugging.</p><h4>Arena — Deterministic Lifetime</h4><p>Arena controls the lifetime of MemorySegment instances. When the arena closes, all memory allocated through it is freed. The API provides three modes:</p><pre>// confined: single-threaded, closes manually or via try-with-resources<br>try (Arena arena = Arena.ofConfined()) {<br>    MemorySegment segment = arena.allocate(512);<br>    // segment is freed when the try block exits<br>}<br><br>// shared: multi-threaded access, explicit close<br>Arena shared = Arena.ofShared();<br>MemorySegment segment = shared.allocate(1024);<br>// pass segment to multiple threads<br>shared.close(); // frees everything<br><br>// auto: GC-managed, no explicit close needed<br>Arena auto = Arena.ofAuto();<br>MemorySegment segment = auto.allocate(256);<br>// freed when segment becomes unreachable</pre><p>Arena.ofConfined() is the right default for single-threaded scenarios. Arena.ofShared() is for memory accessed from multiple threads — the FFM API enforces this distinction at runtime. Accessing a confined segment from a different thread throws an exception rather than producing a data race.</p><h4>Linker and SymbolLookup — Calling the Function</h4><p>Linker generates a MethodHandle that calls a native function. SymbolLookup finds the function by name in a shared library. Together they replace the entire JNI invocation model.</p><pre>// find the native math library and locate the sqrt function<br>Linker linker = Linker.nativeLinker();<br>SymbolLookup stdlib = linker.defaultLookup();<br><br>MemorySegment sqrtSymbol = stdlib.find(&quot;sqrt&quot;)<br>    .orElseThrow(() -&gt; new RuntimeException(&quot;sqrt not found&quot;));<br><br>// describe the C signature: double sqrt(double)<br>FunctionDescriptor descriptor = FunctionDescriptor.of(<br>    ValueLayout.JAVA_DOUBLE,   // return type<br>    ValueLayout.JAVA_DOUBLE    // argument type<br>);<br><br>MethodHandle sqrt = linker.downcallHandle(sqrtSymbol, descriptor);</pre><p>At this point sqrt is a standard Java MethodHandle. You invoke it like any other:</p><pre>double result = (double) sqrt.invoke(144.0);<br>System.out.println(result); // 12.0</pre><p>No C code. No shared library to compile. No System.loadLibrary. The entire setup is pure Java, and it runs in the same JVM process.</p><h3>A Real Example: Calling libz from Java</h3><p>zlib is one of the most widely deployed C libraries in existence — compression behind PNG, HTTP, ZIP, and dozens of other formats. Calling it from Java without Panama means writing a JNI wrapper around compress2 or using a Java reimplementation that doesn’t match the native library’s performance. With FFM, you call it directly.</p><pre>import java.lang.foreign.*;<br>import java.lang.invoke.MethodHandle;<br><br>public class ZlibCompressor {<br><br>    private static final MethodHandle COMPRESS;<br><br>    static {<br>        Linker linker = Linker.nativeLinker();<br>        SymbolLookup zlib = SymbolLookup.libraryLookup(&quot;libz.so.1&quot;, Arena.ofAuto());<br><br>        // long compress2(byte* dest, long* destLen, byte* source, long sourceLen, int level)<br>        FunctionDescriptor compress2Desc = FunctionDescriptor.of(<br>            ValueLayout.JAVA_INT,           // return: Z_OK or error code<br>            ValueLayout.ADDRESS,            // dest buffer<br>            ValueLayout.ADDRESS,            // destLen (in/out pointer)<br>            ValueLayout.ADDRESS,            // source buffer<br>            ValueLayout.JAVA_LONG,          // sourceLen<br>            ValueLayout.JAVA_INT            // compression level<br>        );<br><br>        COMPRESS = linker.downcallHandle(<br>            zlib.find(&quot;compress2&quot;).orElseThrow(),<br>            compress2Desc<br>        );<br>    }<br><br>    public static byte[] compress(byte[] input, int level) throws Throwable {<br>        try (Arena arena = Arena.ofConfined()) {<br>            // allocate source segment and copy input into it<br>            MemorySegment source = arena.allocate(input.length);<br>            MemorySegment.copy(input, 0, source, ValueLayout.JAVA_BYTE, 0, input.length);<br><br>            // zlib requires dest buffer of at least compressBound(sourceLen)<br>            long destBound = (long) (input.length * 1.01) + 12;<br>            MemorySegment dest = arena.allocate(destBound);<br><br>            // destLen is an in/out parameter — pass a pointer to the actual length<br>            MemorySegment destLen = arena.allocate(ValueLayout.JAVA_LONG);<br>            destLen.set(ValueLayout.JAVA_LONG, 0, destBound);<br><br>            int result = (int) COMPRESS.invoke(dest, destLen, source, (long) input.length, level);<br>            if (result != 0) {<br>                throw new RuntimeException(&quot;compress2 failed with code: &quot; + result);<br>            }<br><br>            long actualLen = destLen.get(ValueLayout.JAVA_LONG, 0);<br>            return dest.asSlice(0, actualLen).toArray(ValueLayout.JAVA_BYTE);<br>        }<br>    }<br>}</pre><p>A few things worth noting in this code:</p><p>The COMPRESS handle is initialized in a static block and stored in a static final field. This is intentional — when the JIT sees a MethodHandle in a static final field, it can treat it as a constant and inline the call site. The dispatch overhead drops to near-zero for hot paths.</p><p>The destLen segment is an example of an in/out pointer — common in C APIs that need to return multiple values. In JNI, handling this requires manual pointer arithmetic. Here it’s an explicit MemorySegment with a clearly bounded read and write.</p><p>The try-with-resources on the Arena guarantees that source, dest, and destLen are all freed when compress() returns, regardless of whether it throws. No manual free() call. No native memory leak.</p><h3>Structs and Memory Layouts</h3><p>C structs are the part of JNI that produces the most boilerplate. Every field access requires manual offset calculation. One struct change silently invalidates every access in your Java code.</p><p>FFM handles structs through MemoryLayout, which describes the structure of a region of memory explicitly:</p><pre>// C struct:<br>// struct Tick {<br>//     long timestamp;<br>//     double bid;<br>//     double ask;<br>//     int venue_id;<br>// };<br><br>StructLayout TICK_LAYOUT = MemoryLayout.structLayout(<br>    ValueLayout.JAVA_LONG.withName(&quot;timestamp&quot;),<br>    ValueLayout.JAVA_DOUBLE.withName(&quot;bid&quot;),<br>    ValueLayout.JAVA_DOUBLE.withName(&quot;ask&quot;),<br>    ValueLayout.JAVA_INT.withName(&quot;venue_id&quot;),<br>    MemoryLayout.paddingLayout(4) // alignment padding<br>);<br><br>VarHandle TIMESTAMP = TICK_LAYOUT.varHandle(<br>    MemoryLayout.PathElement.groupElement(&quot;timestamp&quot;));<br>VarHandle BID = TICK_LAYOUT.varHandle(<br>    MemoryLayout.PathElement.groupElement(&quot;bid&quot;));<br>VarHandle ASK = TICK_LAYOUT.varHandle(<br>    MemoryLayout.PathElement.groupElement(&quot;ask&quot;));<br><br>// allocate a tick and populate it<br>try (Arena arena = Arena.ofConfined()) {<br>    MemorySegment tick = arena.allocate(TICK_LAYOUT);<br><br>    TIMESTAMP.set(tick, 0L, System.nanoTime());<br>    BID.set(tick, 0L, 1.08450);<br>    ASK.set(tick, 0L, 1.08452);<br><br>    double spread = (double) ASK.get(tick, 0L) - (double) BID.get(tick, 0L);<br>    System.out.printf(&quot;spread: %.5f%n&quot;, spread);<br>}</pre><p>The layout is described once. The offsets are computed by the JVM from the layout definition, not by you. If the struct changes, you update the layout and the offsets follow. The field access through VarHandle is bounds-checked and type-safe — a mismatch throws at the access site, not somewhere downstream.</p><p>For arrays of structs — a common pattern in market data processing — you allocate a sequence and iterate over it with offsets:</p><pre>int tickCount = 1000;<br>try (Arena arena = Arena.ofConfined()) {<br>    MemorySegment ticks = arena.allocate(TICK_LAYOUT, tickCount);<br><br>    for (int i = 0; i &lt; tickCount; i++) {<br>        MemorySegment tick = ticks.asSlice(<br>            TICK_LAYOUT.byteSize() * i,<br>            TICK_LAYOUT.byteSize()<br>        );<br>        TIMESTAMP.set(tick, 0L, System.nanoTime());<br>        BID.set(tick, 0L, 1.08450 + i * 0.00001);<br>        ASK.set(tick, 0L, 1.08452 + i * 0.00001);<br>    }<br>}</pre><p>This pattern — a contiguous off-heap array of C-compatible structs — is what you’d reach for when building a shared memory bridge between a Java pricing engine and a C++ execution layer. The memory layout is identical on both sides, and no serialization happens at the boundary.</p><h3>jextract: When You Don’t Want to Write Layouts by Hand</h3><p>For large native libraries — CUDA, OpenSSL, a custom C++ engine — writing MemoryLayout definitions by hand is impractical. jextract is the tool that generates them for you.</p><p>It takes a C header file, parses it with libclang, and generates Java bindings that wrap the FFM API:</p><pre># download jextract from https://github.com/openjdk/jextract<br>jextract \<br>  --output src/generated \<br>  -t com.example.zlib \<br>  -l z \<br>  /usr/include/zlib.h</pre><p>The generated output contains a Java class for every struct and a static method for every function in the header. You call compress2 like this:</p><pre>import com.example.zlib.zlib_h;<br>import java.lang.foreign.Arena;<br>import java.lang.foreign.MemorySegment;<br><br>try (Arena arena = Arena.ofConfined()) {<br>    // generated binding hides all the MemoryLayout boilerplate<br>    int result = zlib_h.compress2(dest, destLen, source, sourceLen, level);<br>}</pre><p>The bindings are regeneratable. If the library version changes and the header changes, you run jextract again. The generated code is not something you maintain — it’s output. The jextract tool generates all the required supporting code — MemoryLayout, MethodHandle, and FunctionDescriptor — that is needed to call the underlying native function.</p><p>One caveat worth noting: jextract will not be included in OpenJDK releases — it’s a separate download from the OpenJDK project page. The FFM API itself is part of the standard JDK; jextract is a tooling layer on top.</p><h3>Java vs C++ on the FFM Hot Path</h3><p>The question that comes up immediately for anyone building performance-sensitive systems: does this change the Java vs C++ calculus?</p><p>Partially, and only in specific tiers.</p><p>FFM eliminates the JNI boundary cost. What remains is the JVM overhead that exists regardless of interop: GC pauses, JIT warmup, heap allocation pressure. For sub-10µs latency requirements — the domain of high-frequency market making and co-located order routing — these costs still disqualify the JVM as the execution layer. FFM doesn’t change that.</p><p>Where FFM changes the picture is in the single-digit millisecond tier — LP connectivity, fixed income workflows, algo execution — where latency budgets are larger but you still want to leverage a high-performance C library without the overhead and fragility of JNI. A Java service that calls a native risk engine, a native compression library, or a native crypto primitive through FFM now does so with overhead that is effectively zero compared to the call itself. The dispatch is a direct handle invocation. The memory access is bounds-checked but not garbage-collected. The boundary is transparent to the JIT.</p><p>For teams already running Java in this tier, FFM removes the last strong argument for writing JNI wrappers. The interop story is now fast enough that the choice of where to write logic — Java or C — is a software design decision, not a performance constraint.</p><h3>What Project Panama Actually Changes</h3><p>JNI will not disappear overnight. There is thirty years of JNI code in production systems, and it runs. But the argument for writing new JNI code is now hard to make.</p><p>The FFM API gives you off-heap memory with deterministic lifetime, struct layouts without manual offset arithmetic, native function calls without C glue code, and bounds-checked memory access that fails loudly instead of silently corrupting heap or crashing the process.</p><p>But the more important shift is in the failure model. JNI is brittle in ways that only show up under load or after a refactoring. The FFM API fails at the Java level — with exceptions, stack traces, and type information — rather than at the OS level with a core dump and a silence.</p><p>For engineers working at the boundary between Java and the rest of the world, that’s the change that actually matters.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=757849584fe4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/the-converging-line/project-panama-the-end-of-jni-and-the-beginning-of-real-native-java-757849584fe4">Project Panama: The End of JNI and the Beginning of Real Native Java</a> was originally published in <a href="https://medium.com/the-converging-line">The Converging Line</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[We Gave Claude Code Access to Our Entire Stack. Here's What the Workflow Looks Like Now.]]></title>
            <link>https://medium.com/the-converging-line/we-gave-claude-code-access-to-our-entire-stack-heres-what-the-workflow-looks-like-now-7920bb247f82?source=rss-f562541003cb------2</link>
            <guid isPermaLink="false">https://medium.com/p/7920bb247f82</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[platform-engineering]]></category>
            <category><![CDATA[developer-tools]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Lorenzo Vangi]]></dc:creator>
            <pubDate>Tue, 05 May 2026 08:01:10 GMT</pubDate>
            <atom:updated>2026-05-09T16:00:59.095Z</atom:updated>
            <content:encoded><![CDATA[<h3>From ticket creation to production deploy: one conversation, eight phases, zero context switching.</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IbBRV-EuStJ70-gF7XmqKQ.png" /><figcaption>Claude Code Workflow Integration</figcaption></figure><p>There&#39;s a version of AI-assisted development that most teams are running right now. You open a chat window, paste some code, ask for a review or a suggestion, copy the output back into your editor, and continue. It&#39;s useful. It&#39;s also fundamentally additive: you&#39;re still doing the same work, just slightly faster.</p><p>Then there&#39;s what happens when you connect the model to your actual systems.</p><p>We spent time wiring Claude Code into every layer of our development and deployment stack, including ticket management, log analysis, CI/CD pipelines, deployment tooling and <a href="https://opentelemetry.io/">Telemetry</a>. The result isn&#39;t a faster way to write code. It&#39;s a different shape of work entirely. A developer describes a problem once, and the system moves e2e without jumping between seven different tools to make it happen.</p><p>What follows is what that workflow looks like in practice, phase by phase.</p><h3>The Problem with Context Switching</h3><p>Before getting into the phases, it’s worth naming what we were actually trying to solve.</p><p>The cost of building a feature isn’t writing code. It’s everything around it: opening a ticket, finding the right logs, understanding which components are involved, running tests locally, triggering builds, monitoring deploys, and checking that the right version actually landed. Each of those steps lives in a different tool. Each tool has its own interface, its own search, its own mental model.</p><p>A developer working on a non-trivial fix might touch <a href="https://www.jetbrains.com/youtrack/">YouTrack</a>, <a href="https://openobserve.ai/">OpenObserve</a>, their IDE, a CI dashboard, a deployment console, and a database query tool — all for a single change. The work is fragmented across surfaces that don’t talk to each other.</p><p>MCPs and APIs change the shape of this problem. When a model can call tools directly the integration between phases becomes something you can design deliberately: it isn’t actually suggest commands for you to run, but actually invoke them</p><h3>The Workflow — Phase by Phase</h3><h4>Phase 1: Problem description and context ingestion</h4><p>Everything starts with a conversation. The developer or analyst describes the problem to Claude: which components are involved, what behaviour is unexpected, what the expected state should be. If logs are available, they’re linked directly.</p><p>This isn’t documentation. It’s input. Claude uses what it receives here to drive every subsequent phase, which means the quality of this first description directly affects the quality of everything downstream. The more precise the problem statement, the less ambiguity accumulates as the workflow progresses.</p><p>What’s notable here is what doesn’t happen: no ticket template to fill in, no copy-pasting component names between systems, no manual log lookup before the work even starts.</p><h4>Phase 2: Ticket creation on the helpdesk system (YouTrack)</h4><p>With the problem understood, Claude creates a new ticket on YouTrack, populating it with the component names involved, the issue type, the relevant context extracted from the conversation. The ticket exists before a single line of code has been touched.</p><p>This might seem like a small thing. In practice, it closes a gap that most teams just accept: the ticket is either created hastily at the start (with minimal information) or retroactively at the end (with information that no longer reflects how the work actually evolved). Here it’s created at the right moment and it gets updated as the work progresses.</p><p>YouTrack becomes a living record of the feature lifecycle, not an afterthought.</p><h4>Phase 3: Analysis, log review, and ticket update</h4><p>Before writing code, Claude performs an analysis of the problem. It uses OpenObserve to inspect the logs and metrics of the component in question and of any other components that interact with it. Cross-component log correlation is where a lot of subtle issues actually live, and it’s also one of the most tedious things to do manually.</p><p>The analysis is surfaced to the developer for confirmation when needed. <em>It’s not autonomous</em>: the human stays in the loop on what the model has understood before implementation begins. Once confirmed, the ticket is updated with the findings.</p><p>This phase is where the integration between tools starts to matter. The model isn’t just reading logs in isolation, but it’s connecting what it finds in OpenObserve to the context established in Phase 1, updating a system of record in YouTrack, and building a picture of the problem that will inform the implementation.</p><h4>Phase 4: Implementation, unit tests, and local execution</h4><p>Claude proceeds with the implementation and writes unit tests alongside it. The component is run locally. If integration tests exist for the affected components, they’re executed here.</p><p>The local execution step is not ceremonial. It’s the first real validation gate catching issues before they consume CI resources or land in a shared environment. Integration tests at this stage also surface cross-component breakage early, when it’s cheapest to fix.</p><p>What changes with this setup is the feedback loop. The developer isn’t manually running tests between edits. The cycle from implementation to test result is tighter, and the model can react to failures directly rather than surfacing them as output for the developer to interpret alone.</p><h4>Phase 5: CI build and testing environment deploy</h4><p>If local execution passes, Claude triggers the relevant build job on <a href="https://www.jetbrains.com/teamcity/">TeamCity</a>. Once the build completes successfully, deployment to the testing environment is handled via <a href="https://www.rundeck.com/">Rundeck </a>— a set of preconfigured scripting jobs (bash) that manage the installation.</p><p>This is the phase where most manual workflows have the most friction. Triggering a build, waiting for it, then initiating a deploy via a separate tool, then confirming the deployment ran — each step typically requires a human to monitor a dashboard and switch between systems.</p><p>Here it’s a continuous flow. TeamCity and Rundeck are called in sequence, with the model tracking state across both.</p><h4>Phase 6: Post-deploy log verification</h4><p>After the deploy lands in the testing environment, Claude verifies the logs both directly on the target machine and through OpenObserve. This step closes the loop between what was deployed and how the system is actually behaving post-deployment.</p><p>It’s also the phase that’s most commonly skipped in manual workflows. Checking logs after a deploy feels like extra work when everything looks green on the deployment console. In practice, the deployment console tells you the process completed, not that the component is behaving correctly. The log check tells you the second thing.</p><h4>Phase 7: Version verification via database</h4><p>Every component in our stack communicates its own system information (including version, properties, JVM configs …) at startup through Telemetry, through a telemetry listener that writes to a set of database tables. Claude queries these tables after the deploy to confirm that the version now running in the testing environment matches the version that was just built and deployed.</p><p>This sounds like it should be obvious. It often isn’t. Deployment jobs can fail silently, cached versions can persist, and environment-specific configurations can cause unexpected rollback behaviour. The telemetry tables are a ground truth that exists independently of the deployment tooling: checking them is a verification step, not a redundancy.</p><h4>Phase 8: Human sign-off and production install</h4><p>Once the testing environment is verified, Claude asks the developer to manually test and confirm before moving to production. The human gate is deliberate; it’s not a step that gets automated away.</p><p>Production deployment in our setup means installation on the production machine, but not an immediate version bump of the running component. The installed version becomes available, but activation is a separate, controlled step. This distinction matters in environments where you want the ability to deploy a fix without immediately cutting over, giving you a window to abort without impact if something doesn’t look right.</p><h3>What This Actually Changes</h3><p>The individual tools here aren’t new. YouTrack, TeamCity, Rundeck, OpenObserve — these exist in most mature engineering setups. What changes is the connective tissue between them.</p><p>In a traditional workflow, the developer is the integration layer. They carry context from one tool to the next, manually translate output from one system into input for another, and make judgment calls about when each phase is complete enough to move forward. It works, but it doesn’t scale cleanly — and it accumulates cognitive load that compounds across a working day.</p><p>When the model holds that context and makes those transitions, the developer’s role shifts. Less coordination, more judgment. The decisions that actually require human reasoning — is this analysis correct, does the behaviour in testing match expectations, is this ready for production — stay with the person. The mechanical steps between them don’t.</p><p>That’s the shift that matters. Not that the code gets written faster, but that the entire lifecycle of a feature moves as a coherent unit rather than a sequence of disconnected actions.</p><p><em>This workflow reflects how we’ve structured our stack at this point in time, with our specific tools and operational constraints. The principles — connecting the model to real systems, keeping humans in the loop at decision points, using telemetry as ground truth — apply broadly. The specific toolchain is an implementation detail.</em></p><p>#ClaudeCode #DeveloperProductivity #CICD #SoftwareEngineering #DevOps #AIEngineering #PlatformEngineering #SoftwareArchitecture #MachineLearning #TradingTechnology</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7920bb247f82" width="1" height="1" alt=""><hr><p><a href="https://medium.com/the-converging-line/we-gave-claude-code-access-to-our-entire-stack-heres-what-the-workflow-looks-like-now-7920bb247f82">We Gave Claude Code Access to Our Entire Stack. Here&#39;s What the Workflow Looks Like Now.</a> was originally published in <a href="https://medium.com/the-converging-line">The Converging Line</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a FIX 4.4 LP Integration with QuickFIX/J: Every Decision That Actually Mattered]]></title>
            <link>https://medium.com/the-converging-line/building-a-fix-4-4-lp-integration-with-quickfix-j-every-decision-that-actually-mattered-3448a0f79767?source=rss-f562541003cb------2</link>
            <guid isPermaLink="false">https://medium.com/p/3448a0f79767</guid>
            <category><![CDATA[fix-protocol]]></category>
            <category><![CDATA[algorithmic-trading]]></category>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[financial-technology]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Lorenzo Vangi]]></dc:creator>
            <pubDate>Thu, 16 Apr 2026 07:01:04 GMT</pubDate>
            <atom:updated>2026-04-16T07:01:04.648Z</atom:updated>
            <content:encoded><![CDATA[<h4>From custom DataDictionary to zero-reflection message dispatch — what the documentation doesn’t tell you about FIX connectivity in production.</h4><figure><img alt="FIX Messages &amp; Architecture" src="https://cdn-images-1.medium.com/max/1024/1*X-QBBTWT5QI-XTBJZri1Lw.png" /></figure><p>FIX is 30 years old and still routes most of the world’s electronic order flow.</p><p>That says something. Not about tradition, more about inertia and utility. Equities, fixed income, FX, listed derivatives, even some crypto venues: they all speak FIX. When you’re building connectivity to a financial venue, FIX isn’t a choice you make. It’s the thing you connect to.</p><p>I recently built a FIX 4.4 LP (Liquidity Provider) integration from scratch. The brief was explicit: stay on Java, maximize throughput, eliminate reflection on the hot path. No framework magic. Just clean, explicit code that behaves predictably under load.</p><p>What follows isn’t a tutorial. <a href="https://quickfixj.org/">QuickFIX/J</a> already has documentation for that. This is the set of decisions that the documentation doesn’t cover — the ones that determine whether your integration holds up under a sustained message burst or quietly degrades in ways you won’t notice until it matters.</p><h3>What FIX Actually Is and Why It Still Runs Global Markets</h3><p>FIX (Financial Information eXchange) is a message protocol designed in 1992 to standardize electronic communication between trading counterparties. The core concept is simple: messages are sequences of tag=value pairs, separated by a control character (SOH, ASCII \x01), organized into a header, body, and trailer.</p><p>A FIX 4.4 new order message looks roughly like this:</p><pre>8=FIX.4.4|9=149|35=D|49=SENDER|56=TARGET|34=1|52=20260412-10:00:00|<br>11=ORDER123|55=EUR/USD|54=1|38=1000000|40=2|44=1.0850|10=234|</pre><p>Tag 35 is the message type. Tag 49 is the sender. Tag 56 is the target. Everything else is payload.</p><p>What makes FIX durable isn’t technical elegance — it’s ubiquity. Every major exchange, ECN, and LP has a FIX interface. Fixed income desks use it for RFQ (Request for Quote) workflows. FX platforms use it for streaming quotes. Equities venues use it for order routing. The protocol has versions — 4.2, 4.4, 5.0/FIXT 1.1 — and venues routinely add proprietary tag extensions on top of the standard dictionary, which is where the real complexity lives.</p><p>For an LP integration, FIX 4.4 is the dominant version. Most venues that haven’t migrated to FIXT still expect 4.4, with custom tags on top.</p><h3>The Framework Question: Before You Write a Single Line</h3><p>When you’re building a FIX integration in Java, the framework conversation happens first.</p><p><strong>QuickFIX/J</strong> is the obvious starting point. Mature, well-documented, battle-tested across institutions, it covers the full FIX session lifecycle: logon/logout, heartbeats, sequence number management, resend requests, message persistence. For most teams, it’s the right default. The <a href="https://quickfixj.org/docs/overview">official QuickFIX/J documentation</a> covers session configuration extensively.</p><p><strong>QuickFIX C++</strong> is the same project in a different language. If you need sub-10µs tick-to-trade latencies, you’re not using Java at all. The C++ version — or purpose-built parsers like HFFIX (header-only, zero OO overhead) — is where you start.</p><p><strong>Artio</strong> (LMAX) is worth evaluating if your latency target is in the 10–50µs range and you want to stay on the JVM. Built on Agrona and SBE, designed for lock-free message processing. More operational complexity, significantly lower GC surface.</p><p><strong>Fix8</strong> claims encode latencies around 1.4µs in C++. Commercial engines like FIX Antenna benchmark materially faster than QuickFIX/J on raw throughput, but bring licensing overhead and a different operational model.</p><p>For an LP integration on fixed income — where latency targets are in the low single-digit milliseconds, not microseconds — QuickFIX/J is the right call. The bottleneck isn’t the FIX framework. It’s how you design what happens after the message arrives.</p><p>That’s the part most teams get wrong.</p><h3>Building the Integration — Decision by Decision</h3><h4>Decision 1: The Custom DataDictionary</h4><p>Every FIX venue extends the standard dictionary with proprietary tags. Some add a handful. Some add hundreds. For a production LP integration, you’ll always need a custom DataDictionary XML describing those extensions.</p><p>QuickFIX/J uses this file at startup to build its internal validation model. At runtime, it validates every incoming message against it. If the dictionary is incomplete, you’ll see validation errors on legitimate messages. If it’s too permissive, you’ll silently accept malformed ones.</p><p>The non-obvious part: the dictionary is a first-class artifact, not a configuration detail. Version it, test it, keep it synchronized with the venue’s specification. When the venue pushes a protocol update, the dictionary is the first thing that breaks.</p><pre>UseDataDictionary=Y<br>DataDictionary=FIX44_custom.xml<br>ValidateFieldsOutOfOrder=N</pre><p>ValidateFieldsOutOfOrder=N disables field-order validation. Venues routinely send fields in non-standard order. Enabling this in production causes unnecessary rejections on perfectly valid messages.</p><h4>Decision 2: The Reflection Problem in MessageCracker</h4><p>QuickFIX/J ships with MessageCracker as its standard routing mechanism. You extend it, implement onMessage(XxxMessage, SessionID) for each message type you want to handle, call super.crack(message, sessionID), and the framework dispatches.</p><p>The problem is how crack() works internally. It resolves the correct onMessage overload using reflection — a Class.getMethod() lookup on every incoming message, on the hot path, for every message type.</p><p>For low-volume systems, this is invisible. For a sustained burst of 35=R (QuoteRequest) messages during an active RFQ window, the reflection overhead compounds. More importantly, reflection-based dispatch isn&#39;t predictable under load. It is a hidden, variable cost that grows with the number of registered message types.</p><p>The fix is to override crack() entirely and replace the reflection lookup with a HashMap&lt;String, FixMessageDispatcher&gt; built once at startup:</p><pre>@Override<br>public void crack(Message message, SessionID sessionID)<br>        throws UnsupportedMessageType, FieldNotFound, IncorrectTagValue {<br><br>    String msgType = message.getHeader().getString(MsgType.FIELD);<br>    FixMessageDispatcher dispatcher = dispatchMap.get(msgType);<br><br>    if (dispatcher == null) {<br>        log.warn(&quot;No dispatcher for msgType={}&quot;, msgType);<br>        return;<br>    }<br><br>    dispatcher.dispatch(message, sessionID);<br>}</pre><p>super.crack() is never called. The dispatch map is populated by a registry that builds each entry as a lambda at startup:</p><pre>return (message, sessionID) -&gt;<br>    pool.execute(sessionID, () -&gt; handler.handle(message, sessionID));</pre><p>Hot path on every inbound message: one HashMap.get(), one lambda invocation. No reflection, no instanceof, no branching after the lookup. The lambda is allocated once at startup and lives in heap indefinitely.</p><p>The registry is fully generic — it knows nothing about specific message types. Adding a new message type means adding one entry to the dispatch map. No changes to the cracker itself.</p><p>Note: dispatchMap is a plain HashMap, not a ConcurrentHashMap. It&#39;s written once during initialization and then strictly read-only at runtime. HashMap is the correct choice — the read path is faster without synchronization overhead.</p><h4>Decision 3: Thread Pool Segregation by Message Concern</h4><p>The naive approach is a single thread pool for all FIX message processing. It works until you hit a burst of RFQ messages (35=R, 35=AJ, 35=AI) during an active negotiation window — at which point your execution report handlers (35=8) start queuing behind them.</p><p>That is a real problem. Execution reports are filled confirmations. Queuing them behind quote negotiation messages means your order management logic is processing stale confirmations. In a live LP context, the timing of fill confirmation affects everything downstream.</p><p>The solution is to segregate pools by message concern, declared at configuration time:</p><pre>- rfqExecutorPool      → handles quote negotiation messages (R, S, AJ, AI, AG, Z)<br>- tradeExecutorPool    → handles execution reports and acks (8, BN)<br>- defaultExecutorPool  → everything else</pre><p>Each handler declares which pool it runs on. If none is declared, the default pool applies. A burst in the RFQ lane cannot starve the trade lane. The separation is explicit in the wiring, not inferred at runtime.</p><p>It’s worth noting that this segregation isn’t a universal prescription. The right number of pools — and which message types share one — depends entirely on your actual message flow. A venue where execution reports arrive at ten times the rate of quote requests needs a different balance than one where RFQ volume dominates. Start with separation by concern, then profile under realistic load. The pool boundaries are configuration, not architecture — you can adjust them without touching the cracker or the handlers.</p><h4>Decision 4: FileStore vs MemoryStore</h4><p>QuickFIX/J provides two store implementations. MemoryStore is fast and stateless — sequence numbers live in heap and are lost on restart. FileStore persists every message to disk, enabling the gap-fill and resend mechanisms the FIX session protocol requires after a disconnect.</p><p>For a production LP integration, FileStore is the correct default. The protocol relies on sequence number continuity. If you restart with MemoryStore, you&#39;ve lost your session position. The next logon either resets the sequence — which the counterparty may reject — or triggers a resend request you can&#39;t satisfy.</p><p>The write overhead of FileStore is real but bounded. Each persisted message is a sequential disk append. For LP FIX message volumes — not HFT order-cancel-replace at tens of thousands per second — it is not the bottleneck.</p><p>The accompanying configuration that matters:</p><pre>ResetOnLogon=N<br>ResetOnLogout=N<br>ResetOnDisconnect=N</pre><p>Never reset sequence numbers automatically. Reset only when both sides explicitly agree. Unexpected resets produce session-level rejections that are slow to diagnose and painful to explain to the venue.</p><h4>Decision 5: Session Lifecycle and Dependency Ordering</h4><p>The FIX initiator should never start before the system is ready to process messages.</p><p>This sounds obvious. In practice it isn’t. The FIX session establishes quickly — logon completes in milliseconds. If your downstream systems aren’t ready, you’ll receive messages you can’t process. You’ll either queue them indefinitely or drop them silently. Neither is acceptable for a live LP integration.</p><p>The correct pattern gates the initiator start on dependency readiness:</p><pre>private void onUp() {<br>    initiator = new SocketInitiator(<br>        this, messageStoreFactory, sessionSettings, logFactory, messageFactory);<br>    initiator.start();<br>}</pre><p>onUp() is only invoked after all declared upstream dependencies report ready. The FIX session starts last. Logon happens into a live system, not a starting one. This also means onDown() stops the initiator gracefully when any upstream dependency goes down — the FIX session doesn&#39;t linger while the system it feeds is unavailable.</p><h3>What Java Actually Costs You on the FIX Hot Path</h3><p>The Java vs C++ debate in FIX connectivity is real, but it’s routinely applied at the wrong layer.</p><p>If your latency target is sub-10µs, you’re not using QuickFIX/J. That conversation ends before it starts. For that tier, you need C++ or a purpose-built Java engine with CPU isolation, kernel bypass networking, and a GC-free hot path. A standard JVM isn’t a contender.</p><p>For single-digit millisecond latency — which covers most LP fixed income and FX connectivity — Java is viable if you manage GC correctly. The main risk is GC pause on the hot path. ZGC on Java 21 brings pause times consistently under 1ms. For a FIX session processing hundreds of messages per second, that’s within budget.</p><p>The real cost isn’t the language. It’s the allocations inside your handlers.</p><p>Every object you create on the hot path is a future GC event. The reflection in the native MessageCracker creates objects. The HashMap dispatch doesn&#39;t. That&#39;s the trade-off worth making.</p><p>If you need to go further: avoid autoboxing in your handler code, pre-allocate domain objects where possible, and consider LMAX Disruptor for the internal event pipeline between your FIX layer and your downstream processing. It gives you a pre-allocated ring buffer and eliminates lock contention between the FIX I/O thread and your business logic threads.</p><p>Keeping the toAdmin() hook minimal matters too. It runs on the QFJ I/O thread. Any blocking or allocation there affects the entire session.</p><h3>The Integration Is Never Finished — But the Foundation Is</h3><p>The handler implementations in a FIX integration are never done. Venues update their specs. New message types get added. Edge cases in the sequencing logic surface months after go-live.</p><p>What doesn’t change easily is the foundation: how you route messages, which thread processes what, whether you can recover a session after a crash, whether your initiator starts into a live system or a starting one.</p><p>Those decisions compound. A missed fill because execution reports queued behind quote requests. A session reject because sequence numbers reset on restart. A subtle latency degradation because reflection was running where a map lookup should have been.</p><p>None of these show up in unit tests. They show up under load, at the worst time, when the venue is active and your team is watching the logs wondering what changed.</p><p>The documentation tells you how to start. It doesn’t tell you what to think about before you do.</p><p>#FIXProtocol #AlgorithmicTrading #Java #QuickFIXJ #FinancialTechnology #LowLatency #TradingInfrastructure #SoftwareArchitecture #ElectronicTrading #FinTech</p><p><em>The decisions described in this article reflect direct experience on a specific integration, with specific constraints, a specific venue, and a specific team. They worked in that context. They may not be the right answer in yours. FIX connectivity is one of those domains where the right choice is almost always “it depends” — on your latency target, your message volume, your operational model, and how much complexity you can sustain long-term. Take what’s useful, discard what isn’t, and always validate against your own production data.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3448a0f79767" width="1" height="1" alt=""><hr><p><a href="https://medium.com/the-converging-line/building-a-fix-4-4-lp-integration-with-quickfix-j-every-decision-that-actually-mattered-3448a0f79767">Building a FIX 4.4 LP Integration with QuickFIX/J: Every Decision That Actually Mattered</a> was originally published in <a href="https://medium.com/the-converging-line">The Converging Line</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What Kubernetes Doesn’t Tell You Until It Breaks in Production]]></title>
            <link>https://medium.com/the-converging-line/what-kubernetes-doesnt-tell-you-until-it-breaks-in-production-14e5fd0b88ac?source=rss-f562541003cb------2</link>
            <guid isPermaLink="false">https://medium.com/p/14e5fd0b88ac</guid>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[site-reliability-engineer]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[Lorenzo Vangi]]></dc:creator>
            <pubDate>Sun, 12 Apr 2026 18:18:39 GMT</pubDate>
            <atom:updated>2026-04-12T18:18:39.906Z</atom:updated>
            <content:encoded><![CDATA[<h4>Scaling that made things worse, self-healing that hid the real bug, and a deployment that was technically correct but left the system inconsistent. Three lessons from the field.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KKnvnMxthwmeeZ2jJj-rcQ.png" /></figure><p>There’s a moment every engineer hits with <a href="https://kubernetes.io/">Kubernetes</a>.</p><p>At the beginning, it feels like power.</p><p>You deploy services, define replicas, and expose APIs. Everything looks deterministic. You write YAML, apply it, and the system converges. Compared to traditional environments, it feels like you’ve finally tamed infrastructure.</p><p>Then production traffic arrives. And Kubernetes stops being something you control.</p><p>It becomes something that <strong>reacts</strong>.</p><h3>The Control Illusion: Declarative Systems vs. Human Assumptions</h3><p>In more traditional setups, control is explicit. You decide when to deploy, how many instances to run, and when to restart something. Failures are visible, often abrupt, and very much “yours”.</p><p>Kubernetes changes the contract.</p><p>You don’t execute actions: you <strong>declare a desired state</strong>, and a set of controllers continuously tries to reconcile reality toward that state. That reconciliation loop never stops. It doesn’t ask if your assumptions are correct. It just acts.</p><p>And that’s exactly where things get interesting.</p><h3>Case #1: Horizontal scaling made things worse</h3><p>A fairly common scenario: a service under load starts slowing down. CPU increases, latency follows, and scaling horizontally seems like the obvious move.</p><p>So we scaled. At first, everything looked better. More pods, lower CPU per instance, smoother response times.</p><p>Then, unexpectedly, things get worse: they started to degrade again, but this time, more aggressively.</p><p>Latency increases even more. Errors start appearing. Other parts of the system begin to struggle.</p><p>What happened isn’t a failure of Kubernetes; it’s a mismatch between <strong>what we scaled</strong> and <strong>where the real bottleneck was</strong>.</p><p>The issue wasn’t traffic anymore: it was how the system reacted to scaling.</p><p>To be specific: we were running a Java-based aggregation service behind a shared PostgreSQL instance. Under normal load, it was fine. Under a scaled load, it wasn’t the service that buckled, but it was the connection pool. Latency went from roughly 80ms to north of 900ms in under three minutes, and we spent the first twenty of those minutes looking at the wrong dashboard.</p><p>That was our mistake. We had defined HPA rules based on CPU, because CPU was the metric we had. But the actual constraint lived two layers deeper, in a resource we weren’t surfacing at all.</p><p>Scaling a service doesn’t just distribute load. It can also amplify pressure on shared dependencies:</p><ul><li>Databases</li><li>External APIs</li><li>Queues</li></ul><p>In this scenario, each new replica increased pressure on a shared dependency. What looked like a stateless service wasn’t truly isolated.</p><p>Kubernetes did exactly what it was supposed to do: it reacted to CPU and added capacity.</p><p>But the real bottleneck wasn’t the CPU.</p><p>And sometimes scaling doesn’t solve the problem. It’s <strong>accelerating it</strong>.</p><h3>Case #2: How Kubernetes self-healing masked a production bug for days</h3><p>In another situation, a service began failing subtly. Nothing catastrophic, just intermittent instability.</p><p>Kubernetes reacted as expected: unhealthy instances were restarted, traffic was shifted, and the system stayed available.</p><p>From the outside, everything looked fine.</p><p>But over time, something became clear: instances weren’t stable. They were constantly being replaced.</p><p>In practice, the pod lifetime had dropped to somewhere between four and nine minutes. Individual restarts were fast enough that no alert threshold was crossed. The liveness probe was passing. The service was, by every automated measure, healthy.</p><p>We only caught it because someone noticed the pod count in a Grafana panel looked noisier than usual. Not an alert. Not a runbook. Just someone paying attention to something that didn’t feel right.</p><p>That’s a bad place to be. “Someone noticed” is not a monitoring strategy.</p><p>The system was alive, but not steady.</p><p>Failures weren’t visible as clear events anymore. They were fragmented across short-lived lifecycles, making the issue harder to understand.</p><p>Kubernetes was doing its job perfectly in keeping the system running.</p><p>But in doing so, it also made the underlying problem harder to observe.</p><p>At that point, we had to rethink how we balanced: <strong>recovery vs visibility</strong>.</p><h3>Case #3: Rolling updates don’t guarantee consistency</h3><p>Rolling updates are often treated as a solved problem: gradual rollout, no downtime, everything under control.</p><p>And at the infrastructure level, that’s true. But during one deployment, a new version of a service introduced a subtle change in how data was handled.</p><p>Nothing broke immediately. Old and new versions coexisted during the rollout, and that’s where the edge appeared.</p><p>Some requests behaved differently depending on which version handled them. The system didn’t fail outright, but it became inconsistent.</p><p>From Kubernetes’ perspective, everything was healthy:</p><ul><li>Rollout completed</li><li>Pods were running</li><li>No alerts triggered</li></ul><p>But the system, as a whole, wasn’t behaving correctly.</p><p>The specific issue was a change in how one field in a shared message format was serialized. The old version tolerated a null. The new version didn’t. During the rollout window, about thirty percent of requests were hitting the new pods, and those requests were silently producing different output — not errors, just wrong data.</p><p>We had tested the new version in isolation. We hadn’t tested what happened when both versions were alive at the same time, processing the same stream.</p><p>That’s a gap in reasoning, not in tooling. Kubernetes gave us a correct rollout. We gave it an incomplete definition of “correct”.</p><p>The problem wasn’t deployment. It was the interaction between versions.</p><h3>What Kubernetes Actually Becomes</h3><p>At some point, the mental model flips, and it doesn’t flip back.</p><p>You stop thinking about Kubernetes as a platform you deploy onto. You start thinking about it as something that will act on your architecture continuously, whether your assumptions are good or not. Every HPA rule, every probe configuration, every rollout strategy is a standing instruction to a system that never sleeps and never second-guesses you.</p><p>That’s not a warning. It’s just the actual shape of the thing.</p><p>The three situations above weren’t Kubernetes failures. The scaling behavior was correct. The self-healing behavior was correct. The rollout was correct. What was incomplete, each time, was our model of what “correct” meant in that specific context.</p><p>At small scale, you can get away with fuzzy assumptions. The blast radius is small, feedback is fast, and you can course-correct manually. At scale, those same assumptions get encoded into automation and run continuously against real traffic. The fuzziness doesn’t disappear — it compounds.</p><p>This is what Kubernetes actually gives you: not simplicity, but leverage. And leverage makes good decisions better and bad ones harder to undo.</p><p>There’s no clean framework for this. You build the right mental model the same way you build anything else — by being wrong in production often enough to understand what you were assuming, and specific enough in your post-mortems to actually learn from it.</p><p>The question eventually stops being</p><blockquote><em>how do I deploy this?</em></blockquote><p>It becomes</p><blockquote><em>how does this behave when the system is under load, mid-rollout, and half my assumptions are already wrong?</em></blockquote><p>Once you’re asking that question, you’re designing with Kubernetes rather than on top of it. That’s the shift. It’s not dramatic. It just takes a few production incidents to get there.</p><p>Every configuration you define — scaling rules, health checks, rollout strategies — becomes a signal. And the system continuously reacts to those signals.</p><p>If your assumptions are incomplete, the behavior will reflect that.</p><p>#Kubernetes #K8s #DevOps #SRE #CloudNative #ContainerOrchestration <br>#ProductionEngineering #PlatformEngineering #Microservices #SoftwareArchitecture</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=14e5fd0b88ac" width="1" height="1" alt=""><hr><p><a href="https://medium.com/the-converging-line/what-kubernetes-doesnt-tell-you-until-it-breaks-in-production-14e5fd0b88ac">What Kubernetes Doesn’t Tell You Until It Breaks in Production</a> was originally published in <a href="https://medium.com/the-converging-line">The Converging Line</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Pair Programming vs Code Review: Why the Future of Coding Is Still About Collaboration]]></title>
            <link>https://medium.com/the-converging-line/pair-programming-vs-code-review-why-the-future-of-coding-is-still-about-collaboration-7a38defff449?source=rss-f562541003cb------2</link>
            <guid isPermaLink="false">https://medium.com/p/7a38defff449</guid>
            <category><![CDATA[pair-programming]]></category>
            <category><![CDATA[programming-style]]></category>
            <category><![CDATA[code-review-process]]></category>
            <category><![CDATA[technology]]></category>
            <dc:creator><![CDATA[Lorenzo Vangi]]></dc:creator>
            <pubDate>Tue, 15 Jul 2025 07:27:14 GMT</pubDate>
            <atom:updated>2025-07-15T08:14:04.151Z</atom:updated>
            <content:encoded><![CDATA[<p>In the world of software development, code quality is sacred — and so are the practices that ensure it. Among these, two heavyweights often dominate the conversation: <strong>pair programming</strong> and <strong>code review</strong>.</p><p><strong>But which approach truly delivers?</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ATUBXVoyC-AbCLlIA-e4Qw.png" /></figure><h3>Pair Programming: The Ultimate Way to Save Time and Boost Quality</h3><p>If I had to pick one method to drastically cut down the time wasted in code reviews, it would be pair programming — hands down. Coding side-by-side with a colleague feels like a constant brainstorming session, catching mistakes and improving decisions as the code is being written.</p><p>Code reviews, by contrast, can feel static and boring — often treated as a necessary chore. Worse, they’re usually done by the same few people over and over, typically the more experienced or “critical” ones. This creates a bigger problem than most realize.</p><h3>The Hidden Danger of Code Reviews: Knowledge Silos and Limited Creativity</h3><p>When just a few become the “gatekeepers” of the codebase, knowledge and decision-making power get concentrated in their hands. Developers start to code based on what they <em>know</em> will pass review, which narrows their field of vision and stifles innovation.</p><p>Programming risks turning into merely following unwritten rules — losing that essential freedom of expression that should define our craft.</p><h3>Pair Programming: Sharing Knowledge, Sparking Ideas, Growing Together</h3><p>Pair programming naturally encourages knowledge sharing. It pushes you to think through different solutions together, challenge assumptions, and broaden both minds. It’s a continuous feedback loop that improves not only the code but the whole team.</p><h3>When Business Context Demands More Than Just Correct Code</h3><p>In many highly-specific business environments — think financial trading platforms, healthcare systems, or real-time analytics — writing <em>correct</em> code is only the baseline. The dynamics of these businesses often require deeper collaboration to capture nuances, edge cases, and rapidly evolving requirements that static code reviews can’t fully address.</p><p>Here, pair programming shines because it fosters immediate communication, rapid adaptation, and a shared understanding of not just <em>what</em> the code does, but <em>why</em> it matters. This alignment between technical precision and business needs is critical to delivering real value beyond clean syntax.</p><p>That said, this doesn’t mean work can’t be split up or that code reviews should disappear altogether. Each has its place, depending on the task complexity and type of knowledge involved.</p><h3>The Takeaway: Finding the Right Balance for Better Code</h3><p>The real win isn’t in demonizing code reviews or blindly championing pair programming. It’s in recognizing that pair programming can significantly reduce review times, foster knowledge sharing, and encourage developers to think outside the box.</p><p>At the end of the day, coding shouldn’t be a lonely endeavor or a race to pass judgment. It should be freedom of expression, collaboration, and continuous growth — and pair programming points us right there.</p><p>And remember: you’re not just a developer. You’re a part of a team.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7a38defff449" width="1" height="1" alt=""><hr><p><a href="https://medium.com/the-converging-line/pair-programming-vs-code-review-why-the-future-of-coding-is-still-about-collaboration-7a38defff449">Pair Programming vs Code Review: Why the Future of Coding Is Still About Collaboration</a> was originally published in <a href="https://medium.com/the-converging-line">The Converging Line</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>