News for hackers. Stuff that matters.
Re:Is Rust Stack-Efficient Yet? by adrian17 on Thursday November 17, 2022 @10:08AM (#33639866)
The simplest way to make quick experiments for me is with https://godbolt.org/ .

For my particular example: https://godbolt.org/z/8GvYzYj5h

You can see we're trying to put a 1kB object on heap, but the compiler generates two `memcpy` calls - first to copy it on stack to build the wrapper struct, second to actually copy the entire struct onto allocated memory.

In "real programs", you just need to look at the program's assembly. Or even more generally, I originally noticed this when observing the unusually high amount of time spent in some functions when profiling.

There are no comments on this comment yet.