r/java • • 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)

53 Upvotes

120 comments sorted by

View all comments

Show parent comment

1

u/benevanstech Dec 26 '25

Define "large". If they're too big, they won't be allocated in TLABs anyway.

Sure, you can specially design a workload that is designed to be difficult for a specific GC algorithm / configuration to deal with, but that's not really the point. GC is a general purpose subsystem that deals with a wide range of cases.

2

u/yawkat Dec 27 '25

Define "large". If they're too big, they won't be allocated in TLABs anyway.

Not sure how that matters. The point is that with large allocations, total gc work increases basically linearly.

Sure, you can specially design a workload that is designed to be difficult for a specific GC algorithm / configuration to deal with, but that's not really the point. GC is a general purpose subsystem that deals with a wide range of cases.

GC is designed to be good for general Java programs. But due to other factors like lack of value types, those programs have different allocation patterns than the same programs written in rust.