Remix.run Logo
The Cost of Indirection in Rust(blog.sebastiansastre.co)
34 points by sebastianconcpt 3 days ago | 8 comments
bombela 42 minutes ago | parent | next [-]

I think this long post is saying that if you are afraid that moving code behind a function call will slow it down, you can look at the machine code and run a benchmark to convince yourself that it is fine?

ekidd 14 minutes ago | parent | prev | next [-]

We have been able to automatically inline functions for a few decades now. You can even override inlining decisions manually, though that's usually a bad idea unless you're carefully profiling.

Also, it's pointer indirection in data structures that kills you, because uncached memory is brutally slow. Function calls to functions in the cache are normally a much smaller concern except for tiny functions in very hot loops.

Sytten 12 minutes ago | parent | prev | next [-]

Also to note that the inline directive is optional and the compiler can decide to ignore it (even if you put always if I remember)

cat-whisperer an hour ago | parent | prev | next [-]

I wouldn't have agreed with you a year ago. async traits that were built with boxes had real implications on the memory. But, by design the async abstraction that rust provides is pretty good!

Scubabear68 35 minutes ago | parent | prev | next [-]

A function call is not necessarily an indirection. Basic premise of the blog is wrong on its face.

alilleybrinker 23 minutes ago | parent [-]

Did you read the article? The author makes exactly that point.

slopinthebag 43 minutes ago | parent | prev [-]

Cool article but I got turned off by the obvious AI-isms which, because of my limited experience with Rust, has me wondering how true any of the article actually is.

ramon156 34 minutes ago | parent [-]

I don't see anything wrong code-wise, but it's definitely an odd way of making an accumulator. Maybe I'm pedantic