ArrayObject performance boost?
by Daniel Buckmaster · in Torque 3D Professional · 12/19/2011 (10:24 am) · 2 replies
I've just been looking through ArrayObject and noticed that its internal storage is a Vector, so accessing its members on key values is a linear-time operation. I was wondering anyone ever considered replacing the Vector with an std::map, which will guarantee logarithmic-time lookups at a small space penalty.
Some of the features may have to be removed or hacked in, but it seems like a useful improvement, especially when dealing with larger arrays.
On that note, why does Torque not make more use of the standard library?
Some of the features may have to be removed or hacked in, but it seems like a useful improvement, especially when dealing with larger arrays.
On that note, why does Torque not make more use of the standard library?
About the author
Studying mechatronic engineering and computer science at the University of Sydney. Game development is probably my most time-consuming hobby!
#2
12/21/2011 (1:56 pm)
Quote:std::map has a lot more overhead than std::vector as vector is just like normal arrays, except the arrays are allocated dynamically in chunks.Are you referring to the cache misses resulting from the way map elements will be fragmented in memory? Versus arrays being contiguous? I was under the impression that it isn't too much of an issue, but I've not done any proper testing of my own. I'm just arguing from the perspective of average lookup times.
Quote:The Torque engine core goes as far back as to Starsiege Tribes as far as I know of and back then C++ was not standardized until C++98 (1998)Yep, good point! I didn't even make the connection that Tribes was written before C++ was even standardised. That's pretty intense. I do know there were issues with the STL and TGE's memory manager - I thought that was the reason. But yes, I'd also hope we see an increasing move towards the STL now that we can!
Torque Owner Nathan Martin
TRON 2001 Network
The Torque engine core goes as far back as to Starsiege Tribes as far as I know of and back then C++ was not standardized until C++98 (1998) and Starsiege Tribes was released in 1998, so was in development probably a couple of years before then. And from what I could tell with all the template hacks for TGE 1.1.0 they used VC++ 5 and until VC++ 7.1 (2003) that Microsoft's compiler finally started getting cleaned up for standardization. Visual Studio 2005 is when template mess was finally fixed in the C++ compiler.
Because of how much of a complete mess MS's VC++ compiler was and the incomplete provided "standard library" most developers had to come up with various hacks to get anything to work properly. In this case the Tribes developers opted for writing their own STL templates. I'm hoping by or on T3D 2.0 release Torque will be completely moved to using only the STL.