11
votes

Hopefully this is simple...

I want to performance profile my service fabric cluster.

So far I: - Go to Start Diagnostics tools without debugging. - Go through the wizard selecting my service fabric project as the startup project. - Then it asks which projects to include, so I include my service exe - Then I select instrumentation (I want method level timing)

Then I hit start and immediately my exe crashes. I assume this is because visual studio is trying to run my "service" outside of the service fabric context as a standalone exe.

Not sure what to do about that though...

The stack trace is:

DEBUG: Activating options

Unhandled Exception: System.Fabric.FabricConnectionDeniedException: Not authorized to connect ---> System.Runtime.InteropServices.COMException: Exception from HRESULT: 0x80071C43 at System.Fabric.Interop.NativeRuntime.FabricEndGetNodeContext(IFabricAsyncOperationContext context) at System.Fabric.FabricRuntime.NativeFabricRuntimeFactory.GetNodeContextEndWrapper(IFabricAsyncOperationContext context) at System.Fabric.Interop.AsyncCallOutAdapter2`1.Finish(IFabricAsyncOperationContext context, Boolean expectedCompletedSynchronously) --- End of inner exception stack trace --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.ServiceFabric.Services.Runtime.RuntimeContext.d__3.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.ServiceFabric.Services.Runtime.ServiceRuntime.d__0.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter.GetResult()

Thanks for the help in advance!

2
Thank you, but I found that. If you read a little more closely you'll see that I'm not talking about just getting that error trying to start it... I have no problem starting it for normal debugging. The question was how do I get around it in the case of starting it via the performance profiler.Steve

2 Answers

5
votes

What you're seeing is Visual Studio attempting to start your service host process on its own outside of the Service Fabric runtime. Normally, when you run a service through Visual Studio, you deploy the application project, which goes through the process of registering and instantiating your services on your local Service Fabric cluster.

Instrumentation currently doesn't work out-of-the-box with Service Fabric projects for this reason. We're looking at ways to make this possible in the future.

You can still do Sampling profiling, which allows you to attach the profiler to a running EXE. In that case, you'd deploy your application normally first, then attach the profiler to your service EXEs.

0
votes

See https://msdn.microsoft.com/en-us/library/dd255414.aspx?f=255&MSPPError=-2147217396

  1. If needed, initialize the profiling environment variables with a variant of VSPerfClrEnv {/globalsamplegc | /globalsamplegclife}[/samplelineoff], then reboot.
  2. Start the profiler to collect data with a variant of:

    VSPerfCmd /START:{COVERAGE|SAMPLE|CONCURRENCY|TRACE} /OUTPUT:file /ATTACH:(pid|name)[,(pid|name)]* [/USER:[domain\]username]

The /USER:[domain\]username is needed if the service or process is running under a different user account.

A .vspx or .vsp file extension is added to the /OUPUT:file specification. Then you can open the .vspx or .vsp file in Visual Studio to view the profiling report.

Run VSPerfCmd /? for more explanation and to see the full list of profiling options.