Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Which should be incredibly negligible unless you're counting literal millions of objects. Even then, I'm suspecting that refcounting will never be in the top spots of things that slow you down.


What I'm saying is that bumping atomic references inside a hot loop will be detrimental for performance, and since it invalidates a cache line and this can flush caches for lots of cores. It also shuts down ILP.


One really nice thing about Rust's use of Arc is that you don't need to bump atomic references in a hot loop, or much at all usually.

Once you have an Arc<T> you can `as_ref()` to get a &T. So maybe you need an Arc to share something with another thread, so you clone it once. Once you're in that thread though you can go back to just using `&` and never touch the atomic again.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: