r/programming • u/henk53 • 8d ago
Campfire port in Java is faster than Rust. Some thoughts about JEP 544 (AOT Code Compilation)
/r/java/comments/1x9s75g/campfire_port_in_java_is_faster_then_rust_some/
55
Upvotes
7
u/colorfulchew 8d ago
It seems like more of a wholesale performance focused rewrite than a bones to bones comparison of Java run-times vs LLVM.
Might be interesting to ask an LLM to copy this implementation line for line with the same behaviors, like 10000 cached auth signatures, and tweaks to the SQL queries etc, it'd be a more interesting comparison. I think especially the benchmark-trained AOT would be interesting to compare to PGO+BOLT Rust code.
74
u/renatoathaydes 8d ago
So much BS in that thread. I've measured Java VS Rust before. My bias was towards making Java as fast as possible. I also started with Java being faster, but that's almost certainly because the Rust code was extremely sub-optimal. If you measure optimal Java VS optimal Rust, you'll get Rust at least 3x faster, if you don't it's a great sign you're doing something wrong in your Rust code. In some very rare, very simple cases, Java may be almost as fast as Rust since the JIT ends up finding a hot path that can essentially be compiled to the same Assembly as Rust gives you from the start. But cases where the JIT can actually do something so smart that it's consistently faster are basically a myth that people have, for some reason, kept saying exist for the last 20 years but it just never holds after scrutiny. Here, I will take a $100 bet with anyone that that's the case too.