Posts Tagged ‘dotTrace Performance’

dotTrace 5.5 EAP: Introducing Subsystems

Tuesday, June 4th, 2013

This happens to be a hot week for JetBrains .NET tools, as today we are opening the Early Access Progam for dotTrace 5.5 Performance. Please feel free to grab the latest build of our performance profiler. And here are the reasons why you should give it a try:

Subsystems

With version 5.5 we’re offering a new way to analyze snapshots in terms of Subsystems. Discover your code bottlenecks faster without digging deep into callstacks. With Subsystems view you get a quick overview of where a possible bottleneck may originate from:
dotTrace 5.5 Performance Subsystems
Note that you can customize this view to fit your needs by creating your own profiles and restyling the color scheme the way you like it. dotTrace 5.5 Performance comes with a built-in Default profile which gives you an example of how you can benefit from using Subsystems:

dotTrace 5.5 Performance Managing Subsystems options
Go to View | Options to see how it works and set up your own profile.

Bookmarks

We’ve also enabled you to add bookmarks to your snapshots so you could easily find and navigate between interesting pieces of a snapshot. Click Ctrl+K to create a bookmark, then you can use Ctrl+W shortcut to see and edit the full list of bookmarks from the current snapshot.

dotTrace 5.5 Performance Bookmarks editor

Other impovements

  • List of application’s Hot Spots is now shown right upon opening a snapshot in the updated Overview tab.
  • New Hot Spots algorithm accounting for system code.
  • dotTrace snapshot files (*.dtp) now occupy twice less disk space.
  • Integration with ReSharper 8 EAP.
  • Improved stability in incorrect metadata write/read.

Please note that current version of the EAP build doesn’t support working with snapshots created by previous versions of dotTrace, but this should be fixed by RTM.

You can start playing with dotTrace 5.5 Performance by downloading the latest nightly build from the Early Access Program Page today!

Please don’t foreget to let us know about any issues you might be facing via dotTrace issue tracker.

Remote Profiling using dotTrace

Thursday, March 21st, 2013

We’ve already had a series of blog posts on remote profiling with dotTrace. We’re now accompanying it with a short video that demonstrates how to attach the dotTrace profiler to a remote server (in this case hosted on Azure), which may become handy when a performance problem only occurs on staging or production. Head over to JetBrains TV to watch this screencast.


Enjoy the screencast! As always, comments and questions are more than welcome.

Remote profiling Windows Azure Cloud Services with dotTrace

Wednesday, March 13th, 2013

With dotTrace Performance, we can profile applications running on our local computer as well as on remote machines. The latter can be very useful when some performance problems only occur on the staging server (or even worse: only in production). And what if that remote server is a Windows Azure Cloud Service?

Note: in this post we’ll be exploring how to setup a Windows Azure Cloud Service for remote profiling using dotTrace, the “platform-as-a-service” side of Windows Azure. If you are working with regular virtual machines (“infrastructure-as-a-service”), the only thing you have to do is open up any port in the loadbalancer, redirect it to the machine’s port 9000 (dotTrace’s default) and follow the regular remote profiling workflow.

Preparing your Windows Azure Cloud Service for remote profiling

Since we don’t have system administrators at hand when working with cloud services, we have to do some of their work ourselves. The most important piece of work is making sure the load balancer in Windows Azure lets dotTrace’s traffic through to the server instance we want to profile.

We can do this by adding an InstanceInput endpoint type in the web- or worker role’s configuration:

Windows Azure InstanceInput endpoint

By default, the Windows Azure load balancer uses a round-robin approach in routing traffic to role instances. In essence every request gets routed to a random instance. When profiling later on, we want to target a specific machine. And that’s what the InstanceInput endpoint allows us to do: it opens up a range of ports on the load balancer and forwards traffic to a local port. In the example above, we’re opening ports 9000-9019 in the load balancer and forward them to port 9000 on the server. If we want to connect to a specific instance, we can use a port number from this range. Port 9000 will connect to port 9000 on server instance 0. Port 9001 will connect to port 9000 on role instance 1 and so on.

When deploying, make sure to enable remote desktop for the role as well. This will allow us to connect to a specific machine and start dotTrace’s remote agent there.

Windows Azure Remote Desktop RDP

That’s it. Whenever we want to start remote profiling on a specific role instance, we can now connect to the machine directly.

Starting a remote profiling session with a specific instance

And then that moment is there: we need to profile production!

First of all, we want to open a remote desktop connection to one of our role instances. In the Windows Azure management portal, we can connect to a specific instance by selecting it and clicking the Connect button. Save the file that’s being downloaded somewhere on your system: we need to change it before connecting.

Windows Azure connect to specific role instance

The reason for saving and not immediately opening the .rdp file is that we have to copy the dotTrace Remote Agent to the machine. In order to do that we want to enable access to our local drives. Right-click the downloaded .rdp file and select Edit from the context menu. Under the Local Resources tab, check the Drives option to allow access to our local filesystem.

Windows Azure access local filesystem

Save the changes and connect to the remote machine. We can now copy the dotTrace Remote Agent to the role instance by copying all files from our local dotTrace installation. The Remote Agent can be found in C:\Program Files (x86)\JetBrains\dotTrace\v5.3\Bin\Remote, but since the machine in Windows Azure has no clue about that path we have to specify \\tsclient\C\Program Files (x86)\JetBrains\dotTrace\v5.3\Bin\Remote instead.

From the copied folder, launch the RemoteAgent.exe. A console window similar to the one below will appear:

image

Not there yet: we did open the load balancer in Windows Azure to allow traffic to flow to our machine, but the machine’s own firewall will be blocking our incoming connection. To solve this, configure Windows Firewall to allow access on port 9000. A one-liner which can be run in a command prompt would be the following:

netsh advfirewall firewall add rule name=”Profiler” dir=in action=allow protocol=TCP localport=9000

Since we’ve opened ports 9000 thru 9019 in the Windows Azure load balancer and every role instance gets their own port number from that range, we can now connect to the machine using dotTrace. We’ve connected to instance 1, which means we have to connect to port 9001 in dotTrace’s Attach to Process window. The Remote Agent URL will look like http://<yourservice>.cloudapp.net:PORT/RemoteAgent/AgentService.asmx.

Attach to process

Next, we can select the process we want to do performance tracing on. I’ve deployed a web application so I’ll be connecting to IIS’s w3wp.exe.

Profile application dotTrace

We can now use our application and try reproducing performance issues. Once we feel we have enough data, the Get Snapshot button will download all required data from the server for local inspection.

dotTrace get performance snapshot

We can now perform our performance analysis tasks and hunt for performance issues. We can analyze the snapshot data just as if we had recorded the snapshot locally. After determining the root cause and deploying a fix, we can repeat the process to collect another snapshot and verify that you have resolved the performance problem. Note that all steps in this post should be executed again in the next profiling session: Windows Azure’s Cloud Service machines are stateless and will probably discard everything we’ve done with them so far.

Analyze snapshot data

Bonus tip: get the instance being profiled out of the load balancer

Since we are profiling a production application, we may get in the way of our users by collecting profiling data. Another issue we have is that our own test data and our live user’s data will show up in the performance snapshot. And if we’re running a lot of instances, not every action we do in the application will be performed by the role instance we’ve connected to because of Windows Azure’s round-robin load balancing.

Ideally we want to temporarily remove the role instance we’re profiling from the load balancer to overcome these issues.The good news is: we can do this! The only thing we have to do is add a small piece of code in our WebRole.cs or WorkerRole.cs class.

SetBusy code in RoleEnvironment.StatusCheck event

Essentially what we’re doing here is capturing the load balancer’s probes to see if our node is still healthy. We can choose to respond to the load balancer that our current instance is busy and should not receive any new requests. In the example code above we’re checking if the file C:\Config\profiling.txt exists. If it does, we respond the load balancer with a busy status.

When we start profiling, we can now create the C:\Config\profiling.txt file to take the instance we’re profiling out of the server pool. After about a minute, the management portal will report the instance is “Busy”.

Role instance marked Busy

The best thing is we can still attach to the instance-specific endpoint and attach dotTrace to this instance. Just keep in mind that using the application should now happen in the remote desktop session we opened earlier, since we no longer have the current machine available from the Internet.

image

Once finished, we can simply remove the C:\Config\profiling.txt file and Windows Azure will add the machine back to the server pool. Don’t forget this as otherwise you’ll be paying for the machine without being able to serve the application from it. Reimaging the machine will also add it to the pool again.

Line-by-line profiling with dotTrace Performance

Wednesday, January 30th, 2013

dotTrace Performance allows us to profile an application in several ways. We can choose between sample profiling, tracing profiling and line-by-line profiling. Generally sampling profiling is used first to acquire a high-level overview of call performance in an application, after which tracing and line-by-line profiling is used to close in on a performance issue.

image

Profiling types

Sampling is the fastest and the least precise mode of profiling. With sampling, dotTrace basically grabs current call stacks on all threads once in a while. When capturing a snapshot, the number of calls isn’t available and times are approximate. Accuracy cannot be more than the sampling frequency.

Tracing is slower yet more precise than sampling. Instead of grabbing call stacks on all threads, tracing subscribes to notifications from the CLR whenever a method is entered and left. The time between these two notifications is taken as the execution time of the method. Tracing gives us precise timing information and the number of calls on the method level.

Line-by-line is the slowest yet most precise mode of profiling. It collects timing information for every statement in methods and provides the most detail on methods that perform significant work. We can specify exactly which methods we want to profile or profile all methods for which dotTrace Performance can find symbol information.

Advantages of line-by-line profiling

Line-by-line profiling is the most accurate method since it provides exact timing information on the statement level. While sampling and tracing give us an idea of the individual methods being called and their execution time, these profiling methods do not provide statement-level info. When a method body contains a lot of logic, sampling and tracing will not provide information that is accurate enough to analyze performance of that method. Consider the following source code:

image

If we use tracing profiling, dotTrace allows us to find out that the Foo method is taking up 98,82% of execution time. However if we look at the source code view at the bottom, there is no information provided on which statement(s) are responsible for this.

image

By right-clicking the Foo method, we can add this function to a line-by-line profiling session.

image

Once we’ve run line-by-line profiling, the source code view provides us with profiling information at the statement level. This becomes clear when having a look at the source code view below. We can clearly see that the for loop consists of 3 statements that are executed by the CLR. What’s more important though, is the color coding dotTrace uses to visualize the number of calls per statement. Line 24 is being executed 400 times, the light blue background for that line depicts that it uses most execution time relative to other statements.

image

Using line-by-line profiling, we are able to have a very detailed view on our application’s performance. Using sampling or tracing we can determine which methods are taking most execution time which we can drill further into using line-by-line profiling.

Performance tracing a Windows Store application with dotTrace

Monday, December 24th, 2012

More and more developers are jumping on the opportunity to create applications for the Windows Store. Since most of these apps are very visual and need to be very responsive, it’s really important to know if and where there’s room for improving the application’s code. With the release of dotTrace Performance 5.3, you can now profile Windows Store applications and test projects from within Visual Studio.

As a sample project, I’ve created a simple RSS feed viewer which displays all blog posts on the JetBrains .NET blog. In the screenshot below, you’ll see that there’s a list of blog posts on the left and their contents on the right.

Profiling Windows 8 Store applications using dotTrace

When using the application, everything feels smooth and responsive. Nevertheless it’s good practice to use a profiler to check if you have any potential bottlenecks. After installing the latest version of dotTrace Performance, you will find a new menu item in Visual Studio 2012 from which you can launch a profiling session.

DotTrace Visual Studio 2012 integration

From this menu, you can either profile the current startup project that’s open in Visual Studio, or launch a profiling session for another application. Let’s go with Profile Startup Project as you will probably have it open in your IDE.

Windows Store application profiler session settings

Before the profiling session starts, you have to specify how you want to profile. Specifics on all the knobs and handles can be found in the dotTrace Web Help section. For this profiling session, I’ve selected the line-by-line profiling mode. Typically your first profiling session would be based on sampling (less precise but faster) and once you know what you are after you can have more precise results by selecting the tracing or line-by-line profiling mode. Since my RSS reader is a fairly small and simple application, I’m immediately opting for the most precise results using line-by-line mode.

After clicking Run, your application will be launched. If you’re not sure what you’re looking for, simply navigate through it and use it. I’ve clicked a couple of blog posts and waited for them to show up in the application. Once you feel you’ve collected enough information, click the Get Snapshot button in the dotTrace profiler window.

image

A snapshot of your profiling session is now shown. On the left hand side, you can select one of the various views available in dotTrace Performance to dive into the collected results. In the next screenshot, I’ve selected the Threads Tree. You will notice that the first two threads shown are annotated with a red arrow instead of a black one. This is because those threads have been using the CPU much more than the other threads.

dotTrace Performance thread tree

It may be worth investigating the Main Thread, but most often the time shown here is the total time you have had your application running. Thread #3 in the current profiler snapshot is more interesting. It seems that by clicking just a couple of posts in the application, there’s 1430ms spent in the ItemListView_SelectionChanged method. If I drill down deeper, it looks like the TrackView method is taking 1418ms out of that time. That’s a large percentage of time!

Drilling down in profiler results

If you look at the source code in dotTrace’s bottom pane, the purpose of this TrackView() method is to gain some insight into which posts are being read through the RSS feed viewer application. This method is obviously taking quite some time and may slow down the displaying of a post when I’m using the application on a slower Internet connection.

By profiling this RSS feed viewer Windows Store application, I’ve now successfully identified a potential performance issue even if there was no direct reason for me to go and dive in. Go and download a trail version of dotTrace Performance and profile your own applications too. It may make them much more responsive once published to the Windows Store.

Enjoy profiling your Windows Store applications!

dotTrace 5.3 Performance, ReSharper 7.1.1 are Available

Monday, December 17th, 2012

Rolling out updates to two .NET tools simultaneously is twice as fun: please download the shiny and new dotTrace 5.3 Performance for Visual Studio 2012 integration and Windows Store app profiling, and ReSharper 7.1.1 for bug fixes and performance improvements.

Major changes in dotTrace 5.3 Performance include:

  • The most requested and expected feature: integration with Visual Studio 2012. Prior versions of Visual Studio are still supported as well.
  • Integration with ReSharper 7.1 and 7.1.1.
  • Support for profiling Windows Store applications, including Windows Store test projects.
  • Profiling Windows Store applications with dotTrace Performance

  • New filters in Hot Spots view: “Filter system functions” and “Filter event-waiting trees”.
    New filters in Hot Spots view
  • A new measurement method: Thread Cycle Time, in addition to previously available Wall Time (CPU and performance counter) and Thread Time methods.
  • An updated Welcome screen that includes Attach To Process button and more cosmetic improvements for a comfortable profiling experience.
    Updated Welcome screen in dotTrace 5.3 Performance

dotTrace 5.3 Performance comes as a free upgrade for all dotTrace 5.0 Performance users, as well as for all dotTrace 4.x Performance customers who have purchased the product after February 23, 2012.

ReSharper 7.1.1 is a maintenance release that further refines performance and stability of the ReSharper 7.x family. Notable updates include:

  • Unit test runner enhancements related to debugging, inconclusive tests, and Unit Test Output window, among other fixes.
  • Bug fixes in the installation wizard, code formatter, IntelliSense, and Remove Unused References.
  • Miscellaneous performance improvements.

For further details, please see the entire list of fixes included in ReSharper 7.1.1.

ReSharper 7.1.1 is a free upgrade for all ReSharper 7.x users and also for ReSharper 6.x customers who have purchased their licenses on June 1, 2012 or later.

Please feel free to download and try dotTrace 5.3 Performance and ReSharper 7.1.1!

Using NuGet to simplify remote profiling with dotTrace

Tuesday, December 11th, 2012

We’ve all been there, someone calls you about the fact that the application is slow. No matter how hard you try, it’s impossible to reproduce the issue on your development machine: the issue only occurs in production. What do you do?

dotTrace makes it really easy to attach a profiler to a remote application. We’re now providing a NuGet package which makes it even easier to get your production application profiled.

Step 1: Install-Package dotTrace.Performance.Remote

Using the Package Manager Console or by using the Manage NuGet Packages dialog, you will be able to install the dotTrace Performance NuGet package into your project.

dotTrace Performance NuGet package

This NuGet package will verify if you have dotTrace installed on your system. If that’s not the case, it will ask you if you want to download a trial version from the JetBrains website.

Download Leading Profiling Tool for .NET Applications

The NuGet Package generates the files required for remote profiling from the instance of dotTrace installed on the computer, which varies based on the version. All this is done automatically, but it does require that you have dotTrace installed. Note that the NuGet package currently works with dotTrace Performance 5.2 and 5.3 EAP.

Step 2: Enable-DotTrace

In the Package Manager Console within Visual Studio, we’re adding two commands:

  • Enable-DotTrace, which configures your application for profiling with dotTrace
  • Disable-DotTrace, which removes the profiler assemblies from your application

To profile your application, simply invoke Enable-DotTrace:

Enable-DotTrace

After invoking this command, you will see some assemblies being added to your project. You can now deploy this application to production and start profiling.

Step 3: Profile application

Once you’ve deployed your application, it’s easy to attach dotTrace Performance to it remotely. The only thing you need is the URL where it lives. Simply attach to a remote application and specify the URL, e.g. http://myapp.prod.example.org/AgentService.asmx.

Profile application

After connecting to the remote profiler, simply attach dotTrace Performance to the process you wish to profile.

Attach profiler

Once attached to the remote process, you can work with dotTrace the way you are used to working with it: get a snapshot and analyze the results. After determining the root cause and deploying a fix, you can repeat the process to collect another snapshot and verify that you have resolved the performance problem.

Profiling from the Command Line using dotTrace Performance

Tuesday, September 25th, 2012

Did you know that you can run dotTrace Performance from the command line? Why would you want to run it from the command line? Maybe you want to share the same profiling configuration across the team? Maybe you want to run it as part of your build process? Maybe you want to run dotTrace as part of a larger testing process with other command line tools?

There are lots of reasons why you might want to run dotTrace Performance from the command line. Let’s look at how we can do exactly this.

Profiling from the command line is divided into two steps. First we create a configuration file that specifies the options we want to use. Next we launch dotTrace Performance using that profiling configuration file.

Creating a profiling configuration file

  1. To create a profiling configuration file, open a command prompt and change to the dotTrace installation directory:
    cd c:\Program Files (x86)\JetBrains\dotTrace\v5.2\Bin\
  2. Run Configuration2Xml.exe with the full path of the configuration file that you want to create:
    .\Configuration2Xml.exe <ConfigFilePath>
    For example:
    .\Configuration2Xml.exe c:\code\ProfilingConfiguration.xml
    N.B. Running Configuration2Xml.exe with an existing profiling configuration file will edit the file rather than overwriting it.
  3. The Profile Application dialog will open. Select the type of application that you want to profile and click OK:
    Profile Application
  4. The Profiler Configuration dialog will open. Select the profiler options that you want to use and click Save:
    dotTrace Profiler Configuration
  5. Configuration2Xml.exe will create the specified profiling configuration XML file.
    dotTrace XML configuration file

Profiling

  1. To start profiling, run dotTraceProfiler.exe with the profiling configuration file:
    .\dotTraceProfiler.exe <ConfigFilePath>
    For example:
    .\dotTraceProfiler.exe c:\code\ProfilingConfiguration.xml
  2. Once the application exits, a DTP file will be written in the current working directory, which can be opened and analyzed in dotTrace Performance.


For additional control of profiling, dotTraceProfiler.exe has a number of optional command line arguments:

  • /showcontroller: Open the profile controller dialog where you can start/stop profiling, capture snapshots, and detach/kill the profiled process.
    dotTrace controller
  • /output=<OutputPath>: Specify the file name and/or directory where snapshots should be saved.
  • /rawformat: Use an uncompressed snapshot format for faster processing and saving at the expense of increased file size.

dotTrace Performance can easily be orchestrated from the command line and integrated into your development process. Profile with pleasure!

An update to dotTrace SDK is released

Friday, September 21st, 2012

Good news for dotTrace Performance SDK users. Today we’ve released a minor update which includes the following fixes and changes:

  • A new updated sample for better understanding of how to use dotTrace Performance SDK in the most efficient way.
  • ProfilerState.IsProfilerActive property is now being set to true when it’s used in ProfilingControlKind.API parameter. See this issue.
  • Improved repeated attach.

Please feel free to download the latest version of dotTrace SDK.

And don’t forget to check this post for more details on how dotTrace SDK can help you improve performance of your applications.

Remote Profiling with dotTrace Performance

Monday, September 10th, 2012

You’ve got a thorny performance problem, but it only happens in your staging and production environments. For some reason, you just can’t seem to reproduce it on your local machine. What’s a developer to do? Fortunately dotTrace can profile a remote application and with dotTrace 5.2, it’s easier than ever before. Let’s walk through the steps of collecting a performance snapshot from a remote machine.

Step 1: Copy the dotTrace Remote Agent to the remote server

First we need some way for dotTrace to connect to the remote machine. This is done using the dotTrace Remote Agent, which ships with dotTrace. It can be found in:

C:\Program Files (x86)\JetBrains\dotTrace\v5.2\Bin\Remote

dotTrace Remote Agent directory

The contents of this directory are XCopy deployable. The target machine requires .NET 2.0 or greater installed. Simply copy the “.\Bin\Remote” directory to the remote server using RDP, file share, or any other file copy method of your choice.

Step 2: Run the dotTrace Remote Agent on the remote server

Log into the remote server and run RemoteAgent.exe. To profile an application running as a different user (e.g. ASP.NET web app running under IIS), shift-right-click RemoteAgent.exe and select “Run as administrator”. A console window similar to the one below will appear:

dotTrace Remote Agent running

By default, the Remote Agent will listen on all network interfaces and both IPv4 and IPv6 protocols. Network traffic happens over HTTP and it defaults to port 9000. You can configure a variety of options if you need to change the defaults. Run `RemoteAgent.exe /?` for a full list of options. You will need to configure your firewall to allow TCP traffic on port 9000 (or whichever port you configured with the /port=VALUE option).

Step 3: Attach to the dotTrace Remote Agent from dotTrace on your local machine

Once the Remote Agent is running on the remote computer, you can connect to it from dotTrace running on your local machine using the “Attach To Process” button in dotTrace.

Attach to Process

If you haven’t remotely profiled an application before, click on the “Profile on remote computer” link to bring up the Add Host dialog. If you have remotely profiled an application before, but not on this remote server, click the Add… button and enter the Remote Agent URL for that remote computer.

Profile App

Add Host

The Remote Agent URL will look like http://URL:PORT/RemoteAgent/AgentService.asmx. If you have connected to the remote computer before, it will be available in the drop down list.

Step 4: Profile the application

After the remote computer is selected, a list of .NET 4.0 and above processes will be displayed. Due to limitations of the .NET Profiler API, it is only possible to attach to processes running .NET 4.0 and above.

Profile App with Connection to Remote Server

Choose whether you want to start profiling immediately or whether you would like to start with profiling disabled and click “Run”. The usual dotTrace profiling control dialog will appear. The only difference is that the performance data is being acquired on the remote computer.

dotTrace profiling control dialog

Step 5: Get Snapshot and Analyze

Exercise the remote application in a way that demonstrates the performance problem and click “Get Snapshot”. The performance snapshot will automatically be downloaded to dotTrace and opened - ready for analysis.

Analyze snapshot

You can analyze the snapshot data just as if you had recorded the snapshot locally. After determining the root cause and deploying a fix, you can repeat the process to collect another snapshot and verify that you have resolved the performance problem.

Profile with pleasure!