• Home
  • Products
    • Game Engine
      • Base
      • Mathematics
      • Geometry
      • Physics
      • Particles
      • Animation
      • Graphics
      • Game
      • Game UI
    • Windows Forms
      • Docking Windows
      • Text Editor Control
  • Downloads
  • Buy
    • Overview
    • Professional
    • Indie
    • Non-Commercial
  • Support
    • Overview
    • Blog
    • Forum
    • License FAQ
    • Documentation
  • About
    • About Us
      • Services
    • Contact Us
    • Press
    • Legal Terms
      • Imprint (English)
      • Imprint (German)
Select the search type
 
  • Site
  • Web
Search
DigitalRune.com
Login |Register
NEWS News RSS Feed BLOG Blog RSS Feed FORUM News RSS Feed DOCUMENTATION DigitalRune Software on YouTube DigitalRune Software on Twitter
You are here: SupportForum

If you want to contribute to the forum discussions, please Register or Login.

SearchHome
  • 1
  • 2
  • 3
  • 4
  • 5
HomeHomeDigitalRune Sof...DigitalRune Sof...Game EngineGame EnginePhysics and garbage collectionPhysics and garbage collection
Previous
 
Next
New Post
2/23/2012 4:21 PM
 
Juan Alberto
No Ranking

Joined: 3/2/2011
Posts: 59
Physics and garbage collection 

Hi, I've been running my game through the CLR Profiler and it's telling me that the two main allocations happening at run time are:

1) DigitalRune.Geometry.Partitioning.AabbTree

2) DigitalRune.Geometry.Collisions.ContactSetCollection

Both called from Simulation.Update. The second one comes from one of the internal Wheel methods.

Could you confirm that these are indeed generating garbage? If so, is there anything that could be done to alleviate it (apart from not using the AabbTree, which I will try in the meantime in case it does not affect the frame rate)?

(Note I'm using version 1.5.2 of Digital Rune Geometry).

Thanks

 
New Post
2/23/2012 5:34 PM
 
HelmutG
6th Level Poster

www.digitalrune.com
Joined: 10/15/2006
Posts: 565
Re: Physics and garbage collection 

Yes, these are known to make garbage - although the garbage should be small. The garbage in the wheel method, is actually a bug that should be simple to remove. Removing the other garbage source is also already on our todo list.

Is the generated garbage significantly impacting the performance of your game? How often does the garbage collector run and how long does a garbage collection take?

 
New Post
2/24/2012 11:26 AM
 
Juan Alberto
No Ranking

Joined: 3/2/2011
Posts: 59
Re: Physics and garbage collection 

Well it's odd because according to CLRProf (on the PC) the allocations do not add up enough to produce more than one GC/minute, however on the Xbox the Remote Performance Monitor is showing like 4-5 GCs/minute. There is a first one shortly after starting a race (*) which freezes the game for a fraction of a second, and then the others are not really noticeable.

(*) I should mention that this first GC seems to always coincide with the first collision between cars... hmmm...

Also I'm explicitly forcing a GC at the end of the loading, so each race should start "clean". In theory.

Anyway I'll keep investigating, thanks.

 
New Post
2/24/2012 12:16 PM
 
HelmutG
6th Level Poster

www.digitalrune.com
Joined: 10/15/2006
Posts: 565
Re: Physics and garbage collection 

Regarding the garbage caused by the wheels, I might be able to provide a simply fix for that. That should remove some of the garbage. Do you use our prebuilt DigitalRune.Physics.Specialized.dll or do you build it from source in your project?

The first longer GC sounds suspicious. Maybe there are some first-time initializations running when the cars hit. Which collision objects do you use for terrain, car chassis and other objects?

 
New Post
2/24/2012 12:39 PM
 
Juan Alberto
No Ranking

Joined: 3/2/2011
Posts: 59
Re: Physics and garbage collection 

I'm using the prebuilt DLL.

The terrain is a HeightField shape, and the car is the raycast vehicle, with a CompositeShape made of boxes and spheres.

About the fix for the wheels, better don't do it yet, let me investigate a bit further ok? Thanks.

 
New Post
2/26/2012 9:22 AM
 
Nieldy
No Ranking

Joined: 6/24/2011
Posts: 32
Re: Physics and garbage collection 

Hi Helmut,

I'm also having some occasional slow-downs in my game, but I still haven't worked out where it's coming from. I've been running the CLR profiler today and have also found that the Wheel class produces a bit of garbage. I'm pretty new to the whole CLR profiling thing, so still struggling to understand what's normal and what's a lot of GCs. Out of interest (and I suppose to eliminate the call to GetContacts as a potential source of my problems), it would be nice to know how you'd go about removing the garbage produced in the UpdateContactInfo method of the Wheel class.

 
New Post
2/27/2012 10:51 AM
 
HelmutG
6th Level Poster

www.digitalrune.com
Joined: 10/15/2006
Posts: 565
Re: Physics and garbage collection 

UpdateContactInfo() contains the following line:

var contactSet = CollisionObject.Domain.GetContacts(CollisionObject).FirstOrDefault();

 

The original code uses GetContacts(CollisionObject) which produces garbage. Even if this method did not produce garbage, the LINQ method FirstOrDefault() would probably create garbage (an enumerator on the heap).

This method can be replaced by manually iterating over all ContactSets:

ContactSet contactSet = null;
foreach (var cs in CollisionObject.Domain.ContactSets)
{
  if (cs.ObjectA == CollisionObject || cs.ObjectB == CollisionObject)
  {
    contactSet = cs;
    break;
  }
}

 

Further optimizations:
If we have many vehicles, it wastes CPU time if each wheel iterates over the contact sets. If this shows up in a performance profiler, then we could restructure the vehicle code: For example create a "VehicleManager" that knows all vehicles and that iterates over the contact sets only once per frame and updates all known wheels.

 
New Post
2/27/2012 11:29 AM
 
Juan Alberto
No Ranking

Joined: 3/2/2011
Posts: 59
Re: Physics and garbage collection 
I've just verified that all GCs come from Simulation.Update. As soon as I stop calling it, there are no more GCs. So I'll be trying the solutions suggested and report back. Thanks.
 
New Post
2/27/2012 4:01 PM
 
Juan Alberto
No Ranking

Joined: 3/2/2011
Posts: 59
Re: Physics and garbage collection 

Ok. Here's the deal. I applied the fix to the Wheel source code, but the impact is minimal. The real killer for me is the AabbTree: if I don't use it, I get zero GCs, and if I use it, I get one 15ms GC every 5-6 seconds, and occasional 30ms ones. Not really noticeable most of the time, but still there.

Problem is, I must use the AabbTree. Performance drops to the floor without it. It is being used to partition a CompositeShape made of hundreds of boxes (I think I discussed that in another thread).

So my options at this point would be:

A) Try the other classes in the Partitioning namespace. Does any of them not generate garbage and is suitable for this case?

B) Write my own ISpatialPartition. Perhaps a simple grid would do, although there are quite a few members to implement.

C) Use a fixed version of AabbTree or similar that you may kindly provide ;) in source code form.

D) Live with it. My game is just days away from submission and I'm very wary of any major changes.

 

Suggestions welcome :)

 
New Post
2/27/2012 5:26 PM
 
HelmutG
6th Level Poster

www.digitalrune.com
Joined: 10/15/2006
Posts: 565
Re: Physics and garbage collection 

I suppose these GC values are from the Xbox?

You forgot option E): Ask Microsoft for a generational GC on the Xbox ;-)

Do not try the other partitioning classes. They will behave similar to the AabbTree.

We have discussed some possible fixes internally and maybe we can provide a quick fix for this in the next days. I let you know a soon as possible.

 
 Page 1 of 2
12Next 
Previous
 
Next
HomeHomeDigitalRune Sof...DigitalRune Sof...Game EngineGame EnginePhysics and garbage collectionPhysics and garbage collection


DigitalRune is a trademark of Garstenauer Information Technology OG.

Garstenauer Information Technology OG
Weingartenstrasse 35, 4452 Ternberg
Austria (EUROPE)
office@digitalrune.com

Home Products Downloads Buy Support About Us
Game Engine Particles Windows Forms Professional Blog Services
Base Animation Docking Windows Indie Forum Contact Us
Mathematics Graphics Text Editor Control Non-Commercial License FAQ Press (News)
Geometry Game Documentation Legal Terms
Physics Game UI Imprint
Impressum
Copyright © 2006-2012 Garstenauer Information Technology OG Terms Of UsePrivacy Statement