• Advertisement
Sign in to follow this  

stack tracing - using guards

This topic is 3419 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
That depends on what your GUARD() and UNGUARD() macros do, and how long they take to execute compared to the rest of the function.

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
Sign in to follow this  

  • Advertisement