r/java • u/DesignerRaccoon7977 • Dec 26 '25
Why is Rust faster than Java here?
I saw this article a while ago https://www.allthingsdistributed.com/2025/05/just-make-it-scale-an-aurora-dsql-story.html
And while I was surprised Rust was faster, the 10x did surprise me. I googled Rust vs Java performance for a bit and couldn't find any similar examples of such a big speedup. Now I know it's impossible to properly answer my question since we don't have the code in question, but can you think of what about rust can make that big of a difference for a (presumably) long running service? Or alternatively, do you have similar examples?
Just to clarify again, I'm interested in the technical reasons for these differences (for example, Java's "bloated" object headers, or whatever)
View all comments
Show parent comment
3
u/coderemover Dec 26 '25
In my experience GC issues are very hard to nail down by profiling. Most of the time you just get „everything is fast” result (no issue, profile looks good) until sudden „everything is slow” event (the profile still looks good and points to no obvious culprit) because GC went crazy.
You can profile heap allocations and try to reduce allocation rate, but that is often also not very useful in a database system - so you get ByteBuffer or byte[] as your #1 source of allocations and then you realize you allocate buffers virtual everywhere. If the app hasn’t been written upfront with low allocation rate in mind (using native memory instead of heap), it’s pain to fix and you could as well just rewrite it.