Re:Std::string half of all allocations in the Chrome browser...
by zl4000 on Friday December 05, 2014 @10:27AM
(#8704949)
Copy on write is not at all helpful in a language like C++ where concurrency can be concerned.
[ Parent
| on HN ]
Re:Std::string half of all allocations in the Chrome browser...
by TazeTSchnitzel on Friday December 05, 2014 @10:29AM
(#8704964)
...how so?
Re:Std::string half of all allocations in the Chrome browser...
by bodyfour on Friday December 05, 2014 @01:06PM
(#8705846)
If you have a single-threaded runtime then reference counts are cheap and easy. Once you need to support multithreading you need to use CPU atomic instructions to maintain the reference count safely. As the number of CPU cores increases the relative cost of this operation goes up.
COW strings were a very common optimization when 1-2 CPUs were standard. That's why it's there in GNU's libstdc++ for example. On a modern server with 24 cores it's pretty dubious. It'd only make sense if you were copying (and then not mutating) a lot of your strings.