4 ms·
I ran into these problems with std::unordered_map. While developing my game, I would always run it in debug mode because I need to debug it. Loading a game worl
by _gabe_ 4y ago
I ran into these problems with std::unordered_map. While developing my game, I would always run it in debug mode because I need to debug it. Loading a game world was taking around 12 seconds, and it was beginning to grate on me because of the increased iteration times. So I decided to profile it and see what was taking so long. I compiled in release mode to begin debugging, and it magically took the world load time down to 2 seconds.
I wondered what code I had written that caused such a massive performance hit in debug mode. So I went to profile my code in a debug build to find out. Lo and behold, something like 90% of the CPU time was wasted doing lookups from std::unordered_map because of debug iterators. I tried everything I could to just turn debug iterators off, and eventually gave up and switched to robin_hood::unordered_map which runs great in debug and release. Now I have an unwarranted aversion to the std lib, even though it really is great so long as you're running it in release mode.
- foonathan 4y agoTo be fair, std::unordered_map is also very slow in release mode.
- leni536 4y ago> debug iterators MSVC then, I presume.
- gernb 4y agoIt'd maybe be nice to be able to mark which code gets optimized. If I could make all std as "don't debug this and keep it optimized" I would. I know some debuggers have the option to at least not step into certain code that that doesn't solve the optimization issue
- TillE 4y agoAs others have mentioned, you can accomplish the equivalent by using a release build with pragmas to turn off optimizations in certain sections of code.
- gumby 4y agoYou don't have to compile every file with the same flags. You can vary them with each invocation of the compiler, so trivially get what you want at the translation unit level.
- triknomeister 4y agoAnd get equivalent of ODR errors.
- gumby 4y agoI really doubt flags like -g or -O if going to cause those issues.
- MauranKilom 4y agoIsn't it just a matter of /D_ITERATOR_DEBUG_LEVEL=0?
- quietbritishjim 4y agoI think that won't work because all objects limited together have to use the same debug iterator level. But you can go the other direction: start with release mode (make a separate build profile if you like) and turn on all debug features except debug iterators (and the debug CRT).
- eezurr 4y agoHow do you see the key/value pairs with robinhood in debug mode? I could never find them.
- Night_Thastus 4y agoSecond recommendation for robin_hood's map. I've used it as well, excellent performance compared to the default implementation in GCC.