r/rust • u/TheProgrammar89 • Jul 26 '19
Is this comment about the reference counting performance in Rust accurate?
/r/ProgrammerHumor/comments/b274zp/oof/eirvecs?context=3
50
Upvotes
r/rust • u/TheProgrammar89 • Jul 26 '19
View all comments
Show parent comment
9
u/mdsherry Jul 26 '19
The Rust equivalent of
unique_ptrisBox.shared_ptrcan have some interesting optimizations where it doesn't bother using atomic counts until a new thread is started. That is, in a single-threaded program it behaves the same asRc; in a multi-threaded one,Arc. (Compare to Rust, where you can reserveArcfor values that will cross between threads, and useRcfor those that remain in a single thread.)