🌐
Reddit
reddit.com › r/golang › go vs rust performance test: 30% faster exec time, while 60 times more ram usage!
r/golang on Reddit: Go vs Rust performance test: 30% faster exec time, while 60 times more RAM usage!
April 6, 2025 -

The test: https://github.com/curvednebula/perf-tests

So in the test we run 100'000 parallel tasks, in each task 10'000 small structs created, inserted into a map, and after that retrieved from the map by the key.

Go (goroutines):

  • finished in 46.32s, one task avg 23.59s, min 0.02s, max 46.32s

  • RAM: 1.5Gb - 4Gb

Rust (tokio tasks):

  • finished in 67.85s, one task avg 33.237s, min 0.007s, max 67.854s

  • RAM: 35Mb - 60Mb

[UPDATE]: After limiting number of goroutines running simultaneously to number of CPU threads, RAM usage decreased from 4Gb to 36Mb. Rust's tokio tasks handle the test gracefully out of the box - no optimization required - only mimalloc to reduce execution time was added.

First, I'm not an expert in those two languages. I'm evaluating them for my project. So my implementation is most likely not the most efficient one. While that's true for both Go and Rust, and I was impressed that Go could finish the task 33% faster. But the RAM usage...

I understand that golang's GC just can't keep up with 100'000 goroutines that keep allocating new structs. This explains huge memory usage compared to Rust.

Since I prefer Go's simplicity - I wanted to make it work. So I created another test in Go (func testWithPool(...)) - where instead of creating new structs every time, I'm using pool. So I return structs back to the pool when a goroutine finishes. Now goroutines could reuse structs from the pool instead of creating new ones. In this case GC doesn't need to do much at all. While this made things even worse and RAM usage went up to the max RAM available.

I'm wondering if Go's implementation could be improved so we could keep RAM usage under control.

-----------------

[UPDATE] After more testing and implementing some ideas from the comments, I came to the following conclusion:

Rust was 30% slower with the default malloc, but almost identical to Go with mimalloc. While the biggest difference was massive RAM usage by Go: 2-4Gb vs Rust only 30-60Mb. But why? Is that simply because GC can't keep up with so many goroutines allocating structs?

Notice that on average Rust finished a task in 0.006s (max in 0.053s), while Go's average task duration was 16s! A massive differrence! If both finished all tasks at roughtly the same time that could only mean that Go is execute thousands of tasks in parallel sharing limited amount of CPU threads available, but Rust is running only couple of them at once. This explains why Rust's average task duration is so short.

Since Go runs so many tasks in paralell it keeps thousands of hash maps filled with thousands of structs in the RAM. GC can't even free this memory because application is still using it. Rust on the other hand only creates couple of hash maps at once.

So to solve the problem I've created a simple utility: CPU workers. It limits number of parallel tasks executed to be not more than the number of CPU threads. With this optimization Go's memory usage dropped to 1000Mb at start and it drops down to 200Mb as test runs. This is at least 4 times better than before. And probably the initial burst is just the result of GC warming up.

[FINAL-UPDATE]: After limiting number of goroutines running simultaneously to number of CPU threads, RAM usage decreased from 4Gb to 36Mb. Rust's tokio tasks handle this test gracefully out of the box - no optimization required - only mimalloc to reduce execution time was added. But Go optimization was very simple, so I wouldn't call it a problem. Overall I'm impressed with Go's performance.

🌐
JetBrains
blog.jetbrains.com › rust › 2025 › 06 › 12 › rust-vs-go
Rust vs Go: Which One to Choose in 2025 | The RustRover Blog
February 17, 2026 - This is beneficial for systems programming where low latency and high throughput are crucial. For instance, a benchmark by benchmarks game shows that Rust implementations tend to have lower memory use and are often faster in computation-heavy ...
People also ask

Which language uses less memory, Rust or Go?
Rust uses significantly less memory — typically 2-4x less than equivalent Go programs. Rust web servers consume 50-80 MB of RAM for production workloads, while Go services typically use 100-320 MB. This difference is primarily due to Rust's ownership model versus Go's garbage collector, which requires memory headroom to operate efficiently.
🌐
tech-insider.org
tech-insider.org › home › software › rust vs go 2026: the definitive programming language comparison
Rust vs Go [2026]: 1 Clear Winner After 7 Tests - Tech Insider
Is Rust faster than Go?
Yes, Rust is significantly faster than Go in most benchmarks. In the Computer Language Benchmarks Game, Rust outperforms Go by 2-12x across CPU-bound tasks, with the largest gap in memory-intensive workloads like binary trees (12x). Rust's advantage comes from its lack of garbage collection overhead and zero-cost abstractions. However, for I/O-bound workloads like typical web services, the performance difference narrows considerably because the bottleneck is network latency rather than CPU compu
🌐
tech-insider.org
tech-insider.org › home › software › rust vs go 2026: 12x benchmark gap and a $25k salary divide [tested]
Rust vs Go 2026: 12x Benchmark Gap and $25K Salary Divide [Tested]
Can Rust replace Go?
Rust can technically replace Go for any workload, but it is not always practical to do so. Rust excels where Go struggles: real-time systems, embedded devices, and performance-critical infrastructure. However, Go's faster compilation, simpler syntax, and lower hiring costs make it the better choice for standard web services, microservices, and DevOps tooling. The two languages are better viewed as complementary rather than competitive, each optimized for different points on the performance-produ
🌐
tech-insider.org
tech-insider.org › home › software › rust vs go 2026: 12x benchmark gap and a $25k salary divide [tested]
Rust vs Go 2026: 12x Benchmark Gap and $25K Salary Divide [Tested]
🌐
Medium
medium.com › @ca.purshottam96 › go-vs-rust-memory-management-the-map-that-cost-us-500-month-539b4b8ae207
Go vs Rust Memory Management: The Map That Cost Us $500/Month 💸 | by Purshottam Aggarwal | Medium
July 3, 2025 - Go vs Rust Memory Management: The Map That Cost Us $500/Month 💸 The 3 AM Server Meltdown 🔥 So picture this — it’s 3 AM, your production servers are basically eating memory like there’s no …
🌐
vpoltora
poltora.dev › rust-vs-go-memory
Rust vs Go: Memory Management - vpoltora
November 12, 2025 - Objects are freed immediately when they go out of scope. In Rust, there is no background garbage collector, so we won’t see mark/sweep cycles or calls like gcBgMarkWorker. All memory management consists of explicit allocations, deallocations, and drop() calls.
🌐
DEV Community
dev.to › thatcoolguy › rust-vs-go-which-should-you-choose-in-2024-50k5
Rust vs Go? Which Should You Learn in 2025 - DEV Community
December 30, 2024 - Both Rust and Go are memory-safe languages although they achieve this in different ways. Rust by design favours fast execution while Go favours fast compilation. Rust's ownership and borrowing system prevent many common causes of memory leaks ...
🌐
Rookout
rookout.com › blog › go-vs-rust-debugging-memory-speed-more
Go vs. Rust: Debugging, Memory, Speed & More
July 11, 2023 - Rust takes the more traditional approach. To avoid adding overhead by using a runtime, Rust actually dropped native support for green threads and switched to operating system threads early in its history.
🌐
Bitfield Consulting
bitfieldconsulting.com › posts › rust-vs-go
Rust vs Go — Bitfield Consulting
February 15, 2026 - Rust’s clever compiler produces optimised code that runs as fast as the underlying hardware will allow, equalling the performance of C++ or assembly language programs without sacrificing memory safety. Control. To get the most out of modern CPUs, programmers need to get “close to the metal”, and Rust offers low-level control and excellent interoperability with C/C++ libraries. Go is an ideal language when the situation demands:
Find elsewhere
🌐
Tech Insider
tech-insider.org › home › software › rust vs go 2026: 12x benchmark gap and a $25k salary divide [tested]
Rust vs Go 2026: 12x Benchmark Gap and $25K Salary Divide [Tested]
1 day ago - Discord famously switched from Go to Rust for their Read States service and saw memory usage drop from 1 GB to just 128 MB, while eliminating the latency spikes caused by Go’s garbage collector during peak usage periods.
🌐
Tech Insider
tech-insider.org › home › software › rust vs go 2026: the definitive programming language comparison
Rust vs Go [2026]: 1 Clear Winner After 7 Tests - Tech Insider
2 weeks ago - Rust web servers typically consume 50-80 MB of RAM for production workloads, while equivalent Go services float at 100-320 MB — a 2-4x difference that translates directly to infrastructure cost at scale.
🌐
Medium
effective-programmer.com › rust-vs-go-battle-for-the-backend-368f775de9fc
Rust vs Go: Battle for the Backend | by Naveed Khan | Effective Programmer
March 10, 2025 - At the very least I am hoping not to get the hate mail I got for posting about PHP. Let’s dive into what makes each of these backend behemoths tick, and more importantly, why you might choose one over the other for your next server-side project. ... Alright, let’s talk performance — everyone’s favorite topic to argue about on Reddit! I had Claude pull some data for me comparing Rust and Go in a real-world scenario: a JSON-processing HTTP server (because let’s face it, that’s what most of us are building) and here is what it got:
🌐
Netguru
netguru.com › home page › blog › golang vs rust: which language wins for backend in 2025?
Golang vs Rust: Which Language Wins for Backend in 2025?
July 15, 2025 - Both languages demonstrate excellent ... Java or Python. The memory usage gap between Rust and Go remains relatively small for standard API workloads but widens significantly for memory-intensive operations....
🌐
Reddit
reddit.com › r/golang › why do you prefer go over rust ?
r/golang on Reddit: Why do you prefer Go over Rust ?
January 8, 2022 -

Please don’t say too simple answers like « I prefer it’s libraries » « it’s easier » or « it’s enough for me ».

Rust is regarded as a faster and safer language at the cost of productivity / complexity. Is it just that ?

Do you think Go is more a Java/python replacement or can be optimized as well to run very fast (close to Rust/C) ? Maybe is it as fast in I/O which would be the bottleneck in most scenarios ?

I’m doing my first Go program (for GCP) but I’m interested in Rust as well and I’d like pretty detailed opinions from both sides 🙂

(It can ofc be very well « it’s enough for me » btw, everyone has preferences but then some answers could just be a bit pointless if you see what I mean). I’m sure it’s a « yet another go vs rust » question and I apologize 😆

🌐
LogRocket
blog.logrocket.com › home › go vs. rust: when to use rust and when to use go
Go vs. Rust: When to use Rust and when to use Go - LogRocket Blog
December 3, 2024 - Rust doesn’t have garbage collection; the way it handles memory management means that, unlike Go, it doesn’t need a garbage collector, and references let objects easily get passed around without requiring copies to be made. Individual benchmarks can be game-able and tricky to interpret. To address this, the Benchmarks Game allows for multiple programs for each language, comparing each language’s runtime, memory usage, and code complexity to get a better sense of what the tradeoffs are between them.
🌐
Reddit
reddit.com › r/rust › speed of go vs rust in practice/real world experience?
r/rust on Reddit: Speed of Go vs Rust in practice/real world experience?
June 23, 2023 -

Hi!

I don't want to start another language war, so let me preface this by saying I love both Go and Rust like they are my own.

That out of the way: Do you have practical/real-world experience with the performance of Go, and the performance of Rust in the same setting?

How many people worked on the codebases? Which one is newer?

I'm asking because I've got a feeling that for smaller companies, Go would in practice (not in theory) outperform Rust because Rust's design encourages the use of inefficient patterns -- like cloning a bunch where you could theoretically pass a reference

🌐
WriterDock
writerdock.in › blog › go-vs-rust-for-microservices-a-2026-performance-benchmark
Go vs Rust for Microservices: 2026 Performance Benchmarks | WriterDock
January 19, 2026 - Memory Footprint: Rust services often run on 50% to 10% of the RAM required for an equivalent Go service. In a serverless environment (like AWS Lambda or Cloud Run), this directly translates to lower bills. Type System: The Rust compiler is strict.
🌐
Dasroot
dasroot.net › welcome to dasroot! tada › posts › backend › rust vs go for backend services performance and use case comparison 2025
Rust vs Go for Backend Services: Performance and Use Case Comparison 2025 · Technical news about AI, coding and all
February 8, 2026 - The test used 1 million JSON documents with 100 fields each, under high concurrency (1000 concurrent users). Rust achieved 1.5x faster throughput and 20% lower memory usage than Go.
🌐
Medium
medium.com › @shyamsundarb › c-vs-rust-vs-go-a-performance-benchmarking-in-kubernetes-c303b67b84b5
C# vs Rust vs Go. A performance benchmarking in Kubernetes | by B Shyam Sundar | Medium
February 19, 2023 - In idle state rust’s CPU usage is slightly higher than C#’s and C#’s is slightly higher than Go. C#’s memory usage when idle is slightly higher than Go, and Go’s memory usage is slightly higher than Rust.
🌐
Medium
medium.com › @dexwritescode › comparison-between-java-go-and-rust-fdb21bd5fb7c
Comparison between Java, Go, and Rust | by Dex | Medium
July 2, 2023 - Here Java uses two orders of magnitudes more memory than the Go and Rust counterparts, just sitting in memory doing nothing. That is a huge waste of resources. Lets hit the API with requests using wrk and observe the memory and CPU usages, and the number of requests per second achieved on my machine for each endpoint of the three versions of the program.