Hey Guys,
So I have been putting my engine to use on a game for school, it is very dense in actors, however the world is very small, it has a small area, which just happens to be packed full of actors.
I noticed how my performance was dipping quite a bit and decided to run some profiling on my code, to my surprise, every single hotspot in my code was leading to std::map::find , some were using std::string as the key and some (like the actors) using unsigned integers.
I have been trying to find things to use then map, but really I can't think of anything to compare strings that would be faster than map, I have tried unordered_map however the results aren't a whole lot different. I tried hashing my strings and using an integer compare, but the string hashing is just as slow as actually comparing.
There are SOME things I can 'pre-hash' but there are some things that I need to compare using a string, for instance my shader system grabs GLSL uniform locations by string, but instead of having to do that twice it will store the location with a string index.
This is the biggest bottleneck in my engine so far, and I am having trouble resolving it, everywhere else says 'just use unordered map'.
So I have been putting my engine to use on a game for school, it is very dense in actors, however the world is very small, it has a small area, which just happens to be packed full of actors.
I noticed how my performance was dipping quite a bit and decided to run some profiling on my code, to my surprise, every single hotspot in my code was leading to std::map::find , some were using std::string as the key and some (like the actors) using unsigned integers.
I have been trying to find things to use then map, but really I can't think of anything to compare strings that would be faster than map, I have tried unordered_map however the results aren't a whole lot different. I tried hashing my strings and using an integer compare, but the string hashing is just as slow as actually comparing.
There are SOME things I can 'pre-hash' but there are some things that I need to compare using a string, for instance my shader system grabs GLSL uniform locations by string, but instead of having to do that twice it will store the location with a string index.
This is the biggest bottleneck in my engine so far, and I am having trouble resolving it, everywhere else says 'just use unordered map'.
PC - Custom Built
CPU: 3rd Gen. Intel i7 3770 3.4Ghz
GPU: ATI Radeon HD 7959 3GB
RAM: 16GB
Laptop - Alienware M17x
CPU: 3rd Gen. Intel i7 - Ivy Bridge
GPU: NVIDIA GeForce GTX 660M - 2GB GDDR5
RAM: 8GB Dual Channel DDR3 @ 1600mhz
CPU: 3rd Gen. Intel i7 3770 3.4Ghz
GPU: ATI Radeon HD 7959 3GB
RAM: 16GB
Laptop - Alienware M17x
CPU: 3rd Gen. Intel i7 - Ivy Bridge
GPU: NVIDIA GeForce GTX 660M - 2GB GDDR5
RAM: 8GB Dual Channel DDR3 @ 1600mhz