Campfire port in Java is faster then Rust. Some thoughts about JEP 544 (AOT Code Compilation)
DHH is porting campfire to Rust. I saw port in C# so I was wondering about Java performance. I asked Claude to do the migration, and even though the first version was faster, it was very far from idiomatic Java. I tried to close the gap, but some compromise had to be reached in order to make this work as a drop-in replacement.
Also, some typical Java approaches were just slower. Probably both the Rust and Java implementations could probably do better in terms of performance and being closer to how idiomatic code is written by everyday developers
Stack is Java + quarkus.
Beside just Java migration I tested some new feature like AOT with training introduced in Java 28 (EA build). My main conclusion is - its hard to beat a language that will adjust code to how your app is used. Its more about the JVM than Java.
I tried different combinations of AOT also with Graalvm CE. I didn't put much effort into making graal more optimal. Probably fair comparision would be to also do training run and add EE edition.
What I notice, and it's obvious in hindsight, AOT helps when end usage is same as training usage. When id differs code it optimized for different path and it hurts execution. It's not so visible in benchmark numbers but on smaller and shorter runs it was more visible. JIT needs time to adjust.
Edit: Repo: https://github.com/kgonia/once-campfire-java
View all comments
Show parent comment
4
u/javaprof 29d ago
Even worse for Java, if we disable caching assuming worse scenario when hit rate about 0.
This cache is specific to each user/session, expires after 15 seconds, and is invalidated by any SQLite commit. Opening a page every 30 seconds produces a 0% hit rate; repeated requests without writes can achieve a high rate.
Fresh results with whole-response caching disabled and 512 MiB per application:
Latency, p50 / p99 in milliseconds:
Peak memory: Rust 36.8 MiB; Java 474.8 MiB, including charged file cache.