News for hackers. Stuff that matters.
Re:A lot of complex “scalable” systems can be done with a si... by kccqzy on Sunday December 29, 2019 @10:22PM (#21910558)
C++ shared_ptr unfortunately is artificially slowed down by multithreaded synchronizations. The count in the control block is always updated atomically. But I frequently need to use them not because my data is shared by multiple threads, but because the ownership situation isn't static. Consider for example implementing a single-threaded persistent tree.

This means people frequently need to reinvent their own reference counting mechanisms.

Rust does this right. Rc and Arc.

Re:A lot of complex “scalable” systems can be done with a si... by rumanator on Monday December 30, 2019 @03:20AM (#21911670)
To be fair, std::shared_ptr is just a high-level component that's a part of the STL. Although it's defined in the C++ standard, it's just a generic shared pointer implementation designed to be as robust and bullet-proof as possible.

As with everything in the C++ STL, if you care about bleeding edge performance then you should be prepared to use more perform any (and less generic) components, whether it's data structure implementations or shared pointers.