You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is a performance regression with shorthand array initialization that causes temporary stack allocation and copy. It appears to have been introduced between Rust 1.11.0 and 1.12.0 and exists all the way up to current beta.
It appears that in this case, a temporary is allocated on stack, initialized and then copied.
This could cause performance issues with large array initialization.
The text was updated successfully, but these errors were encountered:
isegal
changed the title
Unneccessary memcpy when using array initialization shorthand
Unnecessary memcpy when using array initialization shorthand
Dec 16, 2018
There is a performance regression with shorthand array initialization that causes temporary stack allocation and copy. It appears to have been introduced between Rust 1.11.0 and 1.12.0 and exists all the way up to current beta.
(All examples henceforth are with -C opt-level=3)
Example:
It appears that in this case, a temporary is allocated on stack, initialized and then copied.
This could cause performance issues with large array initialization.
Without shorthand, there is no temporary allocation:
Rust 1.11.0 when using shorthand, there is no extra allocation:
Source: https://rust.godbolt.org/z/isxu3Y
The text was updated successfully, but these errors were encountered: