Hacker News new | ask | show | jobs
by cle 1802 days ago
I've found it to be mixed, depending on the nature of the workload. Sometimes having GC can be faster, since allocations can be cheaper. But it will generally trade off higher memory utilization, and the behavior is harder to predict under diverse workloads.
1 comments

I agree GC doesn't necessarily mean more CPU. Just more RAM. My reason for thinking Rust code generally uses less CPU is based on it using a more sophisticated compiler.

That said, when Rust code spends a lot of time on allocations, it's usually fixable:

* You can switch global allocators to jemalloc or, for short-lived programs with acceptable total allocation size, bumpalo.

* You can often restructure code to borrow/reuse buffers instead of having per-iteration allocations.

* You can use slabs or arena allocators.