My general policy for by-value vs by-ref arguments in Rust is to take anything bigger than one register on 64-bit by reference. It might not always be 100% optimal on every architecture, but LLVM usually optimizes it, and it’s an easy and consistent rule to remember.
-
-
Replying to @pcwalton
Doesn't LLVM optimise by-value arguments larger than 64-bit by turning them into by-ref arguments anyway?
2 replies 0 retweets 4 likes -
-
The llvm doc mentions a pass that does the opposite (turn some by-ref into by-value args) for some non-exported functions. All of this depends on whether the fn is a good inlining candidate and whether it is private to the crate.
1 reply 0 retweets 0 likes -
My rule of thumb is by ref for things that is larger than 128 bits. I don't have anything to back whether or not it's a good rule but at least I don't spend time pondering every time I add a function. We do have large things passed/returned by values generating ugly memcpys in WR
2 replies 0 retweets 2 likes -
Replying to @nicalsilva @pcwalton
That's an interesting data point. Do these memcpy's impact performance in WR in a significant way?
1 reply 0 retweets 0 likes -
I see these memcpys a lot in profiles, but it's hard to tell whether they all impact performance or if only a few of them contribute most samples.
1 reply 0 retweets 0 likes
Yeah, I see them too. Every time I’ve tried to fix them it has not moved the needle though. I’m not sure if that’s the “peanut butter cost” in action, or whether modern HW is just really good at making them fast.
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.