Sign in to follow this  
irreversible

stack tracing - using guards

Recommended Posts

In short: what's the optimal level of call depth for guards? I'm thinking they contribute very little to overall performance loss, but I'm still not sure where the appropriate depth to start omitting them would be. Consider:

//1
void Render()
{
GUARD();
  RenderObject();
UNGUARD();
}

//2
void RenderObject()
{
GUARD();
  RenderMesh();
UNGUARD();
}

//3
void RenderMesh()
{
GUARD();
  RenderFace();
UNGUARD();
}

//4
void RenderFace()
{
GUARD();
  RenderTriangle();
UNGUARD();
}

//5
void RenderTriangle()
{
GUARD();
  RenderVertex();
UNGUARD();
}

//6
void RenderVertex()
{
GUARD();
  //7
  SetVertexColor(); //guarded
  SetVertexTexCoord(); //guarded
  RenderPoint(); //guarded
UNGUARD();
}

//etc

On the one hand, rationally thinking each of these steps could fail if there's an access violation or some other similar problem. However, there's no real benefit beyond call depth 5 in a vast majority of cases. The question becomes - will the performance impact of registering the guard info string become substantial at some point (in this case assuming ten to a few hundred thousand polygons rendered per second)? Note that it doesn't really seem like a thing to spend time on profiling at this point so I'm just asking what the common practice is.

Share this post


Link to post
Share on other sites
Exception/error reporting in general - I'm trying to set down a generic framework for a small engine and stack tracing is an important part of it as the framework is supposed to assist with general error handling. As for the stack trace itself, the tracer element is initialized as a static object (and records information about the function) and the entry and exit calls translate to a couple of assignments and numeric tests. Nothing much in itself - hence my asking what the general practice is. Eg, how far do commercial engines go? Are there, under normal circumstances, any real practical reasons not to guard every single function?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this