I have an unfounded conspiracy theory in #rustlang that heap allocations only look close in perf to stack allocations because Rust promotes return of large structs, but also lacks guaranteed [N]RVO, and if we had that, many stacky things would be much faster and memory friendly.
Oh that sounds interesting! For the uninitiated: what's (N)RVO? Should I read the issue to find out?
-
-
return value optimization, instead of doing a stack copy on returning something, the function knows that the returned value is supposed to be stored in <some stack location> and directs all reads/writes directly to it
-
(this is a better explanation of the optimization compared to the problem)
- 1 more reply
New conversation -
-
-
Named Return Value Optimization - basically when you return a struct today, it allocates stack space in the caller, and in the called function. When you return, the callee struct is memcpy'd to the caller's stack frame. This can take significant time and space
-
See https://github.com/rust-lang/rust/issues/32966#issuecomment-481659802 … for a current problematic example. This can be a big deal in embedded, where total memory space is very limited.
- 4 more replies
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.