GC::new in HXCPP Profiling

108 views
Skip to first unread message

Joseph Kopena

unread,
Sep 25, 2013, 9:15:52 AM9/25/13
to haxe...@googlegroups.com
I'm trying to use the cpp.vm.Profiler to figure out some bottlenecks.  I don't understand some of the output.  In particular, GC::new appears in functions where there aren't any allocations.

For example, this is a snippet from a log:

RigidBody2DComponent::checkCollision 7.60%/1.08%
   RigidBody2DComponent::checkBoxVsBox 85.8%
   (internal) 14.2%
GC::new 7.19%/
5.09%
   GC
::collect 29.2%
   
(internal) 70.8%
RigidBody2DComponent::checkBoxVsBox 6.53%/4.25%
   GC
::new 34.8%
   
(internal) 65.2%

But the function RigidBody2DComponent::checkBoxVsBox is simply as follows:

  private function checkBoxVsBox(b:RigidBody2DComponent,
                                 manifold
:CollisionManifold2D):Bool
 
{

   
var normX:Float = b.x - x;
   
var normY:Float = b.y - y;

   
var overlapX:Float = (width/2) + (b.width/2) - ((normX>0)?normX:-normX);
   
if (overlapX < 0)
     
return false;

   
var overlapY:Float = (height/2) + (b.height/2) - ((normY>0)?normY:-normY);
   
if (overlapY < 0)
     
return false;

   
if (overlapX < overlapY) {

     
if (normX < 0)
        manifold
.normX = -1;
     
else
        manifold
.normX = 1;

      manifold
.normY = 0;
      manifold
.penetration = overlapX;

   
} else {

     
if (normY <= 0)
        manifold
.normY = -1;
     
else
        manifold
.normY = 1;

      manifold
.normX = 0;
      manifold
.penetration = overlapY;

   
}

   
return true;

   
// end checkBoxVsBox
 
}

At first I thought perhaps CG:new is also involved in creating the local primitive variables, but that doesn't seem to be the case.

Any help understanding this would be greatly appreciated!

Thanks

Hugh

unread,
Sep 27, 2013, 12:35:48 AM9/27/13
to haxe...@googlegroups.com
Hi,
That does seem odd. I guess it could be a couple of things. 1 it actually calls new for some reason.  You could be able to look at the source code to see if this is the case.  Are the manifold variables "Dynamic" or properties with side-effects?   2.  There is a bug in the profile system - what version of hxcpp are you using?  I have not looked at this for a while.

You could also attach a debugger and breakpoint checkBoxVsBox, and then add a breakpoint in new and see if it gets there.

Hugh

Joseph Kopena

unread,
Sep 27, 2013, 8:35:18 AM9/27/13
to haxe...@googlegroups.com
On Fri, Sep 27, 2013 at 12:35 AM, Hugh <game...@gmail.com> wrote:
> That does seem odd. I guess it could be a couple of things. 1 it
> actually calls new for some reason. You could be able to look at
> the source code to see if this is the case. Are the manifold
> variables "Dynamic" or properties with side-effects? 2. There is a
> bug in the profile system - what version of hxcpp are you using? I
> have not looked at this for a while.

Hi Hugh,

None of the properties touched there are Dynamic or have side-effects,
they're all basic properties. CollisionManifold2D itself is an
interface though, but a very basic one with just a couple Float
properties. The implementation being passed in here does contain a
Dynamic property, but not one of the ones touched here. Doesn't seem
like either the interface or that indirect Dynamic should matter?

I'm using hxcpp 3.0.2.

> You could also attach a debugger and breakpoint checkBoxVsBox, and
> then add a breakpoint in new and see if it gets there.

That is a good idea, I'll have to try it.

Thx

--
- joe kopena
right here and now

Hugh

unread,
Oct 1, 2013, 1:32:24 AM10/1/13
to haxe...@googlegroups.com
Hi,
If you pass an interface implementer to a function that takes an interface, a temporary object (delegate) will get created, requiring GC.
So you might be able to get a performance boost from:

for(i in 0...1000)
   checkBoxVsBox(manifoldImpl);

to:

var iManifold:CollisionManifold2D = manifoldImpl;
for(i in 0...1000)
   checkBoxVsBox(iManifold);

Hugh
   
Reply all
Reply to author
Forward
0 new messages