DEV Community

Discussion on: Rust instead of Ruby: a case study

Collapse
 
lluismf profile image
Lluís Josep Martínez

Using less memory doesn't mean a performance improvement. It's just space optimization.

Thread Thread
 
rhymes profile image
rhymes

My definition of performance improvement doesn't only mean that a piece of code is going to be "faster", it also means that it's going to perform better than the one it replaces.

The Rust code according to the PDF performs better because it has a constant memory occupation, it doesn't crash and it's more "deterministic".

It uses less resource -> performs better -> performance improvement.

You don't agree?

Thread Thread
 
kspeakman profile image
Kasey Speakman • Edited

And I can't imagine reading and writing 8MB of memory has worse CPU usage than managing 100MB with a garbage collector also involved. The article doesn't directly mention CPU, but says that their Rust solution was the clear winner in "raw performance".

Thread Thread
 
lluismf profile image
Lluís Josep Martínez • Edited

In your particular case, using less memory performs better (I don't doubt it) but in general this is not true. For instance take any DBMS, if you give it not enough memory it will perform worse because the cache hits will be low (ideally it should be near 100%). Give it a lot of memory and it will fly because most of the pages will be retrieved from cache instead of disk.

ps: I don't know Ruby or Rust.

Thread Thread
 
rhymes profile image
rhymes

I understand your point but I think we are talking about two different things :)

Obviously if you restrict the available memory of a piece of code it's going to perform worse, because as you said it is not enough.