Article View: comp.lang.java.programmer
Article #3Re: Java can be faster than Rust
From: Ross Finlayson
Date: Thu, 26 Nov 2026 16:02
Date: Thu, 26 Nov 2026 16:02
145 lines
8672 bytes
8672 bytes
On 10/19/2026 02:25 PM, Mild Shock wrote: > Hi, > > Yeah interesting. Java the old lady of 20-30 years, > having features like maxMemory() that others lack? > > Bye > > BTW: In some corners people don't do PGO anymore > because GCC23 has become better or something. > > Stefan Ram schrieb: >> | The tech community is actively discussing the Campfire framework - a >> | project originally written in Rust that saw significant performance >> | gains after being ported to Java. While this outcome surprised many >> | given Rust's bare-metal execution model, it highlights Java's robust >> | runtime optimizations and sets the stage for the highly anticipated >> | JEP 544 (Ahead-of-Time Code Compilation). >> | >> | The Campfire Context: Why Java Can Beat Rust >> | >> | The performance advantage in the Java port of Campfire stems from >> | specific architectural realities rather than raw CPU processing speed: >> | >> | o Garbage Collection vs. Explicit Memory Management: Rust relies on >> | strict ownership and explicit allocation/deallocation. In highly >> | dynamic, short-lived object scenarios, Java's modern garbage >> | collectors (like ZGC or G1) can allocate memory incredibly fast via >> | thread-local allocation buffers (TLABs), deferring the cleanup cost. >> | >> | o Just-In-Time (JIT) Dynamic Optimization: Java's C2 compiler profiles >> | the application while it runs. It performs deoptimization, aggres- >> | sive inlining, and escape analysis based on real-world runtime be- >> | havior - optimizations that a static, ahead-of-time compiler like >> | Rust's rustc cannot always predict. >> | >> | JEP 544: Ahead-of-Time (AOT) Code Compilation >> | >> | JEP 544 introduces a formalized framework for Ahead-of-Time (AOT) >> | compilation into the standard OpenJDK pipeline. It builds heavily on >> | the groundwork laid by Project Leyden to address Java's historic >> | weaknesses without sacrificing its runtime strengths. >> | >> | To understand how JEP 544 shifts the paradigm, it is best evaluated >> | across key multi-attribute technical metrics: >> | >> | .--------------------------------------------------------------------. >> | | JEP 544 Architectural Comparison | >> | |--------------------------------------------------------------------| >> | |Architectural | Traditional JIT | JEP 544 (AOT | Impact on | >> | |Metric | (HotSpot C2) | Compilation) | Frameworks like | >> | | | | | Campfire | >> | |--------------------------------------------------------------------| >> | |Startup Time | Slow. The JVM | Instantaneous. | Crucial for | >> | |& "Warmup" | must interpret | Pre-compiled | cloud-native | >> | | | bytecode and | native machine | scaling and | >> | | | compile hot | code executes | microservices. | >> | | | methods | immediately | | >> | | | iteratively. | upon boot. | | >> | |--------------------------------------------------------------------| >> | |Memory | High. Requires | Low. Strips out | Lowers | >> | |Footprint | extra memory to | heavy runtime | infrastructure | >> | |(RSS) | store the JIT | compilation | costs | >> | | | compiler | machinery, | significantly. | >> | | | infrastructure. | reducing base | | >> | | | | memory usage. | | >> | |--------------------------------------------------------------------| >> | |Peak | Extremely High. | High to Very | Bridges the gap | >> | |Throughput | Optimized | High. Uses | between static | >> | | | continuously | stored | binaries and | >> | | | using live | profiling data | dynamic | >> | | | production | (PGO) to match | optimization. | >> | | | telemetry. | JIT performance | | >> | | | | closely. | | >> | '--------------------------------------------------------------------' >> | >> | Key Thoughts on JEP 544's Strategic Approach >> | >> | 1. It Avoids the "Closed-World" Trap >> | >> | Unlike GraalVM Native Image, which enforces a strict "closed-world >> | assumption" (restricting dynamic class loading and reflection), JEP >> | 544 aims for a flexible AOT model. It allows developers to compile >> | critical parts of the application ahead of time while maintaining >> | standard Java compatibility. >> | >> | 2. Profile-Guided Optimization (PGO) is Mandatory >> | >> | Static AOT code is inherently less optimized than dynamic JIT code >> | because it lacks runtime context. JEP 544 solves this by leaning into >> | Profile-Guided Optimization. By feeding training run data into the AOT >> | compiler, the resulting binary retains the aggressive optimizations >> | (like speculative inlining) that allowed the Campfire Java port to >> | outpace Rust. >> | >> | 3. The Future is Hybrid >> | >> | The ultimate goal of JEP 544 is not necessarily to replace JIT >> | entirely, but to create a hybrid deployment model. Applications can >> | boot instantly using AOT-compiled code, and as the application warms >> | up, the JIT compiler can selectively re-compile performance-critical >> | hot spots to achieve peak throughput. >> >> Lines marked with "| " come from my editing, where I start by writing >> prompts for the chatbot and then edit the generated texts and format >> them for Usenet. The chatbot might make mistakes and misrepresent >> or invent facts. >> >> > It's just an adaptive algorithm. Everybody knows that given the distribution of the input that an "ideal" algorithm/data-structure can be given, then also that things change, so, there's no perfect "adapative algorithm", with regards "profile-directed optimization" and its online cousin "feedback-directed optimization", from accounts of what's called "machine-learning" about expert-systems, statistical inference, neural nets & feedback, which anybody knows. The "adaptive algorithm" is what that's called, and brings all the machinery about the maintenance and particularly the re-organization into play. Then printing out a player-piano tune only plays one tune, though often it may be "vertically scaled" by adjusting the tempo. (I once had access to a "player-piano" like for "The Entertainer" from "The Sting".) Java can be faster than Java - ..., not much is faster to run and slower to change than hardware, or, "in silico", though with accounts these days to "optical" circuits besides, which can broadcast and scatter/gather in constant instead of log time. One may aver that having a small array of small content-associative-memory would be better than a giant tray of embarrassingly parallel simplistic units. The content-associative-memory is itself a very "adaptive" data-structure, naturally.
Technical Details
Message-ID:
<MMycnU36wIO9xZX2nZ2dnZfqnPWdnZ2d@giganews.com>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!weretis.net!feeder9.news.weretis.net!border-2.nntp.ord.giganews.com!nntp.giganews.com!Xl.tags.giganews.com!local-3.nntp.ord.giganews.com!news.giganews.com.POSTED!not-for-mailReferences:
<fast-20261019211151@ram.dialup.fu-berlin.de> <11b61sa$1q1t8$1@solani.org>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!weretis.net!feeder9.news.weretis.net!border-2.nntp.ord.giganews.com!nntp.giganews.com!Xl.tags.giganews.com!local-3.nntp.ord.giganews.com!news.giganews.com.POSTED!not-for-mail NNTP-Posting-Date: Thu, 26 Nov 2026 16:02:40 +0000 Subject: Re: Java can be faster than Rust Newsgroups: comp.lang.java.programmer References: <fast-20261019211151@ram.dialup.fu-berlin.de> <11b61sa$1q1t8$1@solani.org> From: Ross Finlayson <ross.a.finlayson@gmail.com> Date: Thu, 26 Nov 2026 08:02:09 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: <11b61sa$1q1t8$1@solani.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <MMycnU36wIO9xZX2nZ2dnZfqnPWdnZ2d@giganews.com> Lines: 145 X-Usenet-Provider: http://www.giganews.com X-Trace: sv3-kZLRyq9ty2EsaCqf0v4rgrL1VrhQ0dKk5IgWyh01Ssvw5AVgz8jUrl4aII2xLHQTqhnnfyh3hTSvPPW!SglnSDuJ325Ao7cncae5qWj9SR2R3XlhOL8iaNuFY39ZnmfLnDNxYUIfxi8FYylals55ZhcyVV5M X-Complaints-To: abuse@giganews.com X-DMCA-Notifications: http://www.giganews.com/info/dmca.html X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40