views:

289

answers:

4

When I enable trace, e.g.:

How badly this affects application performance?

+2  A: 

As with most questions, the answer is "It depends". Are you turning on Tracing for WCF components, or using your own trace calls? Is there a trace listener attached (e.g. writing to a file? Or is a DebugView tool opened to watch the system debug console)? Does your code make heavy use of tracing in tight loops, or does it do more moderate tracing only on non-recursive functions and the like?

You can try it and see, but for most apps, you will notice.

EricLaw -MSFT-
Yes, I was interested in tracing wcf components using System.Diagnostics.XmlWriterTraceListener in particular. No own trace calls.
dnk.nitro
A: 
  1. Decide what performance overhead for tracing is acceptable to you.
  2. Measure what the actual performance overhead is.
  3. If 2 <= 1 then smiley faces all round.
  4. If 2 > 1 then change your tracing (e.g., make it less verbose, change the trace listener), and go back to 1.
ShellShock
but the question is "how much is performance affected". this is essentially a tautology.
msulis
A: 

I had the same question since I'm considering the impact of leaving verbose tracing on in production for the first several months on a multi-tiered system.

The test I've performed indicates it's not too bad a performance hit. Here's the sequence of calls I'm making:

   UI Client (local pc)
      -> WCF service 1 (hosted locally)
         -> WCF service 2 (hosted locally)
            -> webservice hosted by business partner (offsite)

The UI client, as well as WCF Service 1 and WCF Service 2 are all tracing using System.Diagnostics.XmlWriterTraceListener.

Set to "ALL", the process averages 530ms.
Set to "OFF", the process averages 400ms.

That's a pretty big jump, but the actual processing happening is trivial, so this is almost ALL serialization & communications overhead. I suspect as the tasks become more processor-intensive, the logging overhead will decrease as a percentage.

If you're making a high volume of calls, and need performance, that overhead might be unacceptable. But in my case, the calls will be infrequent, so the small additional overhead will be worth the diagnostic potential.

msulis
A: 

Be sure to < clear /> the default listener if you're worried about performance.

Thoughts on System.Diagnostics Trace vs. Common.Logging