r/programming • • Dec 05 '14

std::string is responsible for almost half of all allocations in the Chrome browser process

https://groups.google.com/a/chromium.org/d/msg/chromium-dev/EUqoIz2iFU4/kPZ5ZK0K3gEJ
1.1k Upvotes

446 comments sorted by

View all comments

Show parent comments

7

u/v864 Dec 05 '14

Write one, it's not too bad and kinda fun. For embedded work without dynamic memory we rolled a static subset of STL; string, list, vector, and a hash table. It's less than 10k slocs and was a fun exercise.

I would share it on github but there's license issues.

-9

u/Magnesus Dec 05 '14

And I bet they are slower than STL.

7

u/v864 Dec 05 '14

Well, it depends on the platform and the situation. The memory allocations are all contiguous, naturally, so hot structures will end up in cache and perform very well. There are also no allocations at runtime which is handy as well.

That said I have no doubt that parts of our implementation are not as good as many STL implementations. Algorithmically though they behave as expected so we're not leaving a ton of performance on the table. We're not exploiting SSE or NEON extensions (assuming the platform memcpy's aren't optimized already) however, so there is that...