Rust question: let x = T::new() let r = Rc::new(x) My mental model: x lives on stack, inner value of r on heap. But unsure where copied?
-
-
-
Replying to @steveklabnik
Is the memcpy onto heap at `box` struct instantiation in Rc::new's code? Or the moment we call Rc::new (regardless of what it does)?
4 replies 0 retweets 0 likes -
Replying to @jo_liss
It's then moved into the RcBox here https://github.com/rust-lang/rust/blob/master/src/liballoc/rc.rs#L312 … so that'd be two moves
1 reply 0 retweets 0 likes -
Replying to @steveklabnik
Ah, so now I understand, in principle every time we pass ownership there's a memcpy (= move, or Copy if trait implemented).
3 replies 0 retweets 2 likes -
Replying to @jo_liss @steveklabnik
So my intuition was, ownership passing is free. This is sort-of correct as long the memcpy can be optimized away (usually but not always).
3 replies 0 retweets 1 like -
Replying to @jo_liss
move a vec? that's copying three words, so 24 bytes on a 64-bit system, 12 on 32. regardless of the vec's length.
2 replies 0 retweets 0 likes -
Replying to @steveklabnik
Just thought you might be interested in our data point: Looking at CPU flamegraphs, memcpy is taking >10%; might become more as we optimize.
1 reply 0 retweets 0 likes
My current thinking is that we should do these optimizations on MIR.
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.