GeAutoDynamicArray and Particles
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 07/01/2012 at 16:47, xxxxxxxx wrote:
User Information:
Cinema 4D Version: R13
Platform: Windows ; Mac ;
Language(s) : C++ ;---------
Hey everyone,I have a particle system that is part of one of my plugins and I am currently finding it to be a bit cumbersome and resource intensive. I use GeAutoDynamicArray to create an array of particles that my system uses. My question is, is GeAutoDynamicArray ideal for such a situation? Is it designed in such a way so that inserting and removing objects in to the array will not use resources in an inefficient way? Am I better off using std::list for my particles? Or simply using standard C++ and creating my own dynamic array? Your thoughts and comments are most appreciated.
Thanks,
Shawn
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 08/01/2012 at 00:35, xxxxxxxx wrote:
Originally posted by xxxxxxxx
<ADDRESS>
User Information:
Cinema 4D Version: R13
Platform: Windows ; Mac ;
Language(s) :
C++ ;---------
</ADDRESS> Hey everyone,I have a particle system that is part of one of my plugins and I am currently finding it to be a bit cumbersome and resource intensive. I use GeAutoDynamicArray to create an array of particles that my system uses. My question is, is GeAutoDynamicArray ideal for such a situation? Is it designed in such a way so that inserting and removing objects in to the array will not use resources in an inefficient way? Am I better off using std::list for my particles? Or simply using standard C++ and creating my own dynamic array? Your thoughts and comments are most appreciated. Thanks,ShawnFirst of all (if you haven't done it yet), you should profile your plugin to see, if this is a problem related to insertion/removes or a cache access problem (too many data cache misses). If you're on Windows I'd suggest buying Intel's VTune - which goes fairly deep. On OS X you can use Apple's free Shark or Instruments - both with a better timer resolution than Vtune on Windows and much easier to use (as long as you don't have to deal with exotic stuff like cache line burst or reservation stalls, ...).
Regarding the performance I can give you these pro/con ratings:
GeDynamicArray & derivates (like GeAutoDynamicArray)
Pros:
- Faster than std::vector when inserting or removing elements (2 - 10 times)
- Much faster than std::list when accessing the array elements (lists get extremely bad, if you've to access 1000s or more elements)
- Less memory overhead than std::list
- Cache-friendly if accessed in a serial orderCons:
- Slower than std::vector when just appending data (1.2 - 2.0 times for small element counts; for more than 150000 elements the memory throughput evens it out)
- A bit slower than std::vector when accessing the array elements
- Slower insert/remove than std::list (gets worse for high element counts - although not as bad as in std::vector)std::list
Pros:
- Fast insert & remove (linear time)Cons:
- Memory overhead (double linked list needs two pointers per element)
- Slow element access (if you're dealing with more than just a dozen elements)
- Puts a high burden on the memory management (many small allocations/frees)
- Cache-unfriendlyI'd recommend to use a tested array code (GeDynamicArray or std::vector) instead of coding your own dynamic array (which often is a source of performance problems and bugs - memory trashers - if you don't pay attention to all the corner cases).
Best regards,
Wilfried Behne
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 08/01/2012 at 06:33, xxxxxxxx wrote:
Thanks Wilfried,
I will download the trial of VTune and see if it something I would like to buy. It's pretty pricey. LOL.. Okay so I will stick with GeAutoDynamicArray and optimize from there. There is definitely a problem somewhere because C4D's standard emitter can emit and monitor 10000 particles without too much lag but mine is only able to spit out about 1500. LOL then it starts to get choppy. So I get the feeling that I am allocating in the wrong spot. LOL
~Shawn