Article View: comp.lang.java.programmer
Article #1Re: Java can be faster than Rust
From: Mild Shock
Date: Mon, 19 Oct 2026 21:25
Date: Mon, 19 Oct 2026 21:25
109 lines
6899 bytes
6899 bytes
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. > >
Technical Details
Message-ID:
<11b61sa$1q1t8$1@solani.org>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!weretis.net!feeder8.news.weretis.net!reader5.news.weretis.net!news.solani.org!.POSTED!not-for-mailReferences:
<fast-20261019211151@ram.dialup.fu-berlin.de>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!weretis.net!feeder8.news.weretis.net!reader5.news.weretis.net!news.solani.org!.POSTED!not-for-mail From: Mild Shock <janburse@fastmail.fm> Newsgroups: comp.lang.java.programmer Subject: Re: Java can be faster than Rust Date: Mon, 19 Oct 2026 23:25:31 +0200 Message-ID: <11b61sa$1q1t8$1@solani.org> References: <fast-20261019211151@ram.dialup.fu-berlin.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Mon, 19 Oct 2026 21:25:30 -0000 (UTC) Injection-Info: solani.org; logging-data="1902504"; mail-complaints-to="abuse@news.solani.org" User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:140.0) Gecko/20100101 Firefox/140.0 SeaMonkey/2.53.24 Cancel-Lock: sha1:rAtFDfo5NeB2Crz2lMYkzWyZMVQ= In-Reply-To: <fast-20261019211151@ram.dialup.fu-berlin.de> X-User-ID: eJwNy8kBwCAIBMCWAHc5ylGR/ktI5j9crn4DTgeHYx6JNchELmhFPD0Q2d1M8L7eNLMzuFOvptseTfqfW7TOBy7cFTs=