Tracing Performance Tips
I have recently been working with tracing performance and have posted several tidbits of information. Here is the overview.
- Use TraceSource instead of Trace
- Disable global locking
- Clear the default listener in configuration
- Don’t collect stacktrace information if not required
- Create TraceSource instances once per name and cache for reuse. I have encountered memory leaks from creating large numbers of instances of the same TraceSource name.
- Create a unique TraceSource and TraceListener for each logical part/tier/layer of the application (locking performance and data segregation)
- Use thread safe listeners if possible
- Check TraceSource.Switch.ShouldTrace before calculating any expensive information to provide to the trace message
On a side note, don’t forget to turn off code coverage for running load tests.
Written on January 12, 2009