46 minutes ago · 8 min read1648 words · Tech · hide

For the past 2 years I have been toying with graphics and one of the things I keep improving is the startup time. Last year I wrote about using executors vs TBB to throw more cores at the problem. With that more or less addressed, the bottleneck has moved to the filesystem. Or more precisely, to misuses of the C++ file and filesystem APIs. Below are 4 performance traps in the standard library that you need to be aware of. I have personally had to deal with each of them, although some are older and date back from my time working with VFS on Paradox games. Trap #1: std::filesystem::exists() is almost always redundant C++20 added std::map::contains which I dislike because it solves the wrong problem. The rationale was “it looks nicer than map.find( x ) != end( map )” (or map.count( x ) > 0 which is equally terrible in my opinion). The problem is: you very rarely need to check if a map contains a given key without a follow-up action that will also require a lookup in the map. So…

Commenting on Bubbles has been removed. Why? If you want to talk about this post, write to the author, use the comments on their blog if it has them, or reply with a "RE:" post on your own blog. Suggestions? feedback@bubbles.town