Once of the things I’ve been looking into at work lately is the performance of the TFS server. The two questions that I’m trying to answer are:

  • Is TFS slow today compared to yesterday or last week?
  • Is the current hardware up to the job?

One of the great things that changed in TFS2008 is that the Web Service Method / Command Logging was enabled in the Global web.config File Settings by default. Every web service call that TFS processes is logged in the tbl_Command table of the TfsActivityLogging database on your data tier.

This table includes some useful fields like:

  • Command - e.g. QueryLabel, CheckIn, etc.
  • StartTime - The UTC time when TFS started to process the command
  • ExecutionTime - The time it took to process the command (in millionths of a second)
  • ExecutionCount - The number of times the command was executed within a logical operation
  • UserAgent - e.g. DevEnv.exe, TFSBuildService.exe, etc.
  • IPAddress - The IP Address of the client

By default, 14 days worth of activity logging data is kept. This is set in the SQL Agent job: TfsActivityLogging Administration Job which is scheduled to run at midnight each night:

  • EXEC prc_PruneCommands @maxAgeDays = 14

SQL Agent Job Definition - Prune Command Logs  

Creating a PivotTable

By using Excel 2007 and connecting to the TfsActivityLogging table as a data source, we can apply some conditional formatting rules and get a fancy heat map.

TfsActivityLogging Heat Map in Excel

About this particular Report:

  1. You should read each line by itself. The colours are per-line instead of for the whole table.
  2. As you can see performance has been a little worse since Friday. This is because we did a few fairly large operations which have fragmented the indexes.
  3. The QueryLabels command is consistently taking a long time. I need to investigate what would cause this.

You will need to do this as a user that has access to query the TfsActityLogging database. By default a TFS Administrator has access.

  • Open a new Excel 2007 worksheet
  • Select Data | From Other Sources… | From SQL Server (shortcut: ALT-A-FO-Enter)

Excel 2007 - Add Data connection

  • On the Connect to Database Server screen, enter your TFS server name

Connect to Database Server wizard screen

  • On the Select Database and Table screen, Select TfsActivityLogging and tbl_Command.

Select Database and Table wizard screen

  • Select the defaults to save the file and finish the wizard.
  • On the Import Data dialog, select PivotTable Report

 Import Data dialog

  • You should now have a blank PivotTable Report that lets you select the different table fields.

Before we select fields to display, we want to specify our own SQL query to do some of the hard work.

  • Select PivotTable Options | Change Data Source | Connection Properties… (shortcut: ALT-JT-I-O)
  • Select the Definition tab
  • Change the Command type to: SQL
  • Paste in the following SQL query and replace the 4x “11″ with your GMT Timezone Offset (Australia is +11 hours in daylight saving)

SELECT 

    Command, 

    AVG(CAST(Duration AS float) / 1000000) as AvgDuration, 

    DATEADD(dd, 0, DATEDIFF(dd, 0, DATEADD(hh, 11, StartTime))) AS Day 

FROM ( 

    SELECT 

        Command, 

       (SUM(ExecutionTime) / SUM(ExecutionCount)) AS Duration, 

       DATEADD(dd, 0, DATEDIFF(dd, 0, DATEADD(hh, 11, StartTime))) AS StartTime 

    FROM 

       tbl_Command 

    GROUP BY 

       Command, 

       DATEADD(dd, 0, DATEDIFF(dd, 0, DATEADD(hh, 11, StartTime))) 

) AS sub 

GROUP BY 

    Command, 

    DATEADD(dd, 0, DATEDIFF(dd, 0, DATEADD(hh, 11, StartTime))) 

ORDER BY 

    Day DESC, 

    AvgDuration DESC

About the query:

  1. Nested: The reason this is a nested query is because the TFS team included a column called ‘ExecutionCount’. If a command is executed multiple times as part of a single logical operation, the ExecutionCount will reflect this. For averages to work correctly, we can’t just ignore the ExecutionCount and we must SUM the values.
  2. DATEADD() functions: The reason for these functions is twofold. 1) To GROUP BY each day we have to calculate the date (without the time). 2) Because TFS stores the StartTime as GMT we have to add our timezone offset to the time, otherwise it looks like the server was busy on the weekends.
  3. Divide by 1000000: The reason for this is that Duration field is stored in millionths of a second. We divide it to get the result in seconds which is easier to relate to.

 

  • Save the options, and add the fields so that your PivotTable Field List looks like this:

PivotTable Field List

And that’s it! You now have all the data in Excel ready to analyse to your heart’s content.

Creating a Heat Map

To get a useful heat map, we need to do a few things to prepare the data:

  • Select all the cells and reduce the number of digits shown after the decimal point. (shortcut: ALT-H-9)
  • Select a cell in the right-most column labelled “Grand Total”
  • Select the filter dropdown labelled “Column Labels” and untick dates that you don’t want included. e.g. Weekends, Today, etc.
  • Select Sort & Filter | Sort Largest to Smallest (shortcut: ALT-H-S-O). This will sort the longest running commands to the top
  • Select all rows except the top 10 and choose “Hide” (shortcut: ALT-H-O-U-R)
  • Change the label “Grand Total” to “Average Duration”

Then you will need to select the values in each row (except the last column) and choose conditional formatting. (shortcut: ALT-H-L-S-Right Arrow-Enter)

  • Save the workbook

Now whenever you want to view the latest performance metrics, you can select Refresh (shortcut: ALT-A-R-A) and Excel will execute the SQL query again and update the PivotTable.

Other Statistics and monitoring

If you’re interested in more general statistics about your server, these posts should help:

Future Enhancements

Of course this is a pretty Ad-Hoc solution, but it requires no special tools. Some other implementations that might be useful are:

  • Build it as a SQL Server Report that anybody can view
  • Build it as a System Center Operations Manager 2007 (SCOM) Management Pack

If you find this useful please leave a comment and share any enhancements that you make with others.



9 Responses to “TFS Performance & Excel 2007 Heat Map”  

  1. 1 Luke Elliott

    Hey Grant, very cool article.

    I’m curious as to what you use to annotate your screenshots. They look really well done.

    Cheers,
    Luke

  2. 2 Thomas Bittlingmayer

    Hi Grant,

    a very interesting article. Helped me a lot in my task of gaining performance data on TFS. Unfortunately, I had to leave out the ExecutionCount because I’m still bound to TFS 2005.

    My question would be: How does enabling the command logging affect performance?

    Regards,
    Thomas

  3. 3 Grant Holliday

    @Thomas - As far as I know, enabling the command logging would have a negligible effect on performance. We’re only talking an extra DB row anytime something happens.

    It’s not like it has to calculate/lock or join anything.

  4. 4 Damir

    Hi Grant,

    Very nice article.
    Would you happen to have a query that would work on the TFS 2005 version? Or give me some directions on how to do that considering that the ExecutionCount does not exists in the TFS 2005.

    Thanks,
    Damir

  5. 5 insurance motor car tesco

    insurance car motor tesco car motor tesco insurance

  1. 1 - David Yack's Blog! - Investigating TFS Performance
  2. 2 TFS Performance & Excel 2007 Heat Map « Grant Holliday « Noocyte’s Weblog
  3. 3 Team System News : VSTS Links - 02/28/2008
  4. 4 TFS Performance Heat Map Reporting Services Report « Grant Holliday

Leave a Reply