Std::string half of all allocations in the Chrome browser process
51–60 of 170 posts
Re: Std::string half of all allocations in the Chrome browser process
#52I sure as hell believe it. I'm on an older, slightly creaky Macbook Pro, and typing in Chrome's box is frequently a nightmare if I'm running something like a VM. Keystrokes lag tremendously.
Re: Std::string half of all allocations in the Chrome browser process
#53I sure as hell believe it. I'm on an older, slightly creaky Macbook Pro, and typing in Chrome's box is frequently a nightmare if I'm running something like a VM. Keystrokes lag tremendously.
Same situation here... I have to clear my browser history every couple of months in order for it to perform adequately.
Re: Std::string half of all allocations in the Chrome browser process
#54Don't many std::string implementations have small string optimizations? This is actually the first time I have every heard of C++ strings being the bottleneck of an application (and it seems that is even still up for debate here).
Re: Std::string half of all allocations in the Chrome browser process
#55Don't get me started on the performance of using Chrome inside of a VM, that is a whole other world of hurt right there.
Re: Std::string half of all allocations in the Chrome browser process
#56Safe to say this turned out to be a disaster for performance since every time an animation or not had to be evaluated from a name (which we ended up doing a lot), a string had to be allocated on the heap.
Some people sadly underestimate how bad objects which rely on heap allocation can be in performance-critical code.
Re: Std::string half of all allocations in the Chrome browser process
#57Earlier quoted context omitted.
Interestingly, with Rust, the borrow checker makes it statically safe to know when you can stack alloc.
You can also do it in a more limited set of cases in other languages using escape analysis. You can't provide it in all cases, but in a subset of cases you can show that the allocation never escapes a certain stack context, and therefore it's safe to stack-allocate. I believe the JVM does that in many cases.
Re: Std::string half of all allocations in the Chrome browser process
#58Earlier quoted context omitted.
This is the problem with C++ (and in a certain part, with C) "Everybody" has their own C++ string (MFC, QT, several libraries, heck, even GObject library has their strings) Same with C Now, you won't see anybody reimplementing strings in Java. C#, Python, JS, etc Lessons learned, their strings work std:string is certainly a step forward and should be used for most projects today
"Lessons learned, their strings work" Except that they don't. Either they are 'complete' but massive and thus slow, or they start as 'array of byte' and then their designers spend 10 years implementing a more 'complete' string type that is still fast enough and end up as #1 anyway. Of course the C++ way where there is no string type that everyone uses sucks too, it's just that strings are almost impossible to get 'ri…
Speaking as a dynamic language programmer who's trying to break into systems programming, it took a long time for me to fully appreciate the difficulties around strings. And now that I do, I'm perpetually paranoid about how many allocations my Python programs are doing behind the scenes...
Re: Std::string half of all allocations in the Chrome browser process
#59The problem with std::string is that it's named wrong. It should be called std::string_buffer, because that is what it is. Its performance characteristics are closer to a std::vector than a std::array (now available since C++11). Many projects cannot copy around std::vector in good conscience. They really want a copy-on-write string, an immutable string, a rope, a reference-counted string, or an always-in-place strin…
Why on earth are they using C++ for a web browser anyway? That's about the worst possible choice of programming language for that problem domain.
Re: Std::string half of all allocations in the Chrome browser process
#60I literally started programming in C++ this week and I figured the over-use of std::string couldn't be a good thing hehe
No that's BS. `std::string` should be used where ever it is applicable. The whole issue that this post about chrome was talking about was dealing with a poor usage of `std::string`, such as passing c_str() to then go and construct another string instead of passing by const ref. Or building a set of `std::string` to simply check if a value exists. That's just shit code, not an issue with `std::string`.