A Java and Quarkus Campfire port reportedly ran faster than a Rust implementation in some tests. How should that result be interpreted, and what does JEP 544 change?
How can a Java Campfire port be faster than Rust, and where does AOT fit in?
Answers
First check that both versions do the same work. A benchmark result compares particular implementations and settings, not Java and Rust in isolation. If one port has been tuned for the benchmark, that matters too.
It would be useful to compare behavior, workload, concurrency, warmup and runtime configuration before drawing conclusions. Both implementations may have room for improvement, including changes that make them more idiomatic without sacrificing compatibility.
Reply to this answer
Java can be faster in some workloads without anything mysterious going on. The JVM compiles hot code to native instructions and can use information gathered while the application runs. Rust produces native code too, but it doesn't get the same runtime profiling through a JIT.
Memory management can also change the trade-off. A garbage collector may make allocating and reclaiming lots of small objects cheap on the request path, while introducing collection costs elsewhere. That doesn't mean Java will always win, or that a Rust implementation can't be improved for the same workload.
Reply to this answer
JEP 544's trained AOT code compilation is mainly about getting to optimized performance sooner. The training run gives the JVM compiled code and profile information it can use on later runs, rather than waiting for all that work to happen again during warmup.
The training workload matters. If it favors paths that differ from production traffic, the initial compiled code may be a poor fit. The JIT can adapt, but that takes time, so short runs may show the mismatch more clearly than a long throughput test. Don't assume AOT raises the eventual peak.
3v~marzipanlever_672:
So the useful comparison is both early performance and the warmed-up result, with training traffic close to the actual workload?
a.624~socketcaper:
Yes, and it's also worth trying a different workload to see how sensitive the trained result is to that choice.
Reply to this answer
Keep the different AOT options separate. A trained JVM run and a GraalVM native image aren't the same setup, and a quick test of one GraalVM configuration doesn't settle what a more carefully tuned comparison would show.
Reply to this answer
Add your answer
Answers are reviewed before publication.
_t46+drumwicket.9:
Startup time and peak memory deserve a look alongside throughput. A faster warmed-up service can still have a much larger footprint.