Demystifying Visual Studio
2012 Performance Tools




Martin Kulov | kulov.net
  www.devreach.com
You cannot manage,
What you do not measure




www.devreach.com
You cannot Improve,
What you do not measure




www.devreach.com
Trace Analysis

                             Our code


                    CLR         COM          WinRT


                             Win32 API


                          Operating System


                   HDD    RAM      CPU        LAN      CPU
                                                     Counters


www.devreach.com
CPU Counters
• Hardware events – portable and platform
   –   Instructions Retired
   –   Non Halted Cycles
   –   ITLB Misses
   –   Branches Retired
   –   Mis-predicted Branches
   –   L2 Cache Read Misses
   –   L2 Cache Read References




www.devreach.com
Trace Analysis

                             Our code


                    CLR         COM          WinRT
                                                     Windows

                             Win32 API                 Perf

                                                     Counters
                          Operating System


                   HDD    RAM      CPU        LAN      CPU
                                                     Counters


www.devreach.com
Windows Performance Counters
•    They are …counters
•    Min interval – 1sec
•    Apps and kernel send Increment signals
•    Accessed by Windows API




    www.devreach.com
Perf Counters Demo




www.devreach.com
Trace Analysis

                             Our code


                    CLR         COM          WinRT
                                                     Windows
  Event
                             Win32 API                 Perf
 Tracing
                                                     Counters
    for                   Operating System

Windows
                   HDD    RAM      CPU        LAN      CPU
                                                     Counters


www.devreach.com
Event Tracing for Windows
• General purpose, high speed tracing
• Buffering and logging in kernel
• Faster than printf
       – 20,000 events per second while only using 5% CPU load on a P3 500MHz!

•    Provider, Consumer, Controller model
•    Over 700 providers in Win7, ~900 in Win8!
•    Aggregates all sources
•    Stack walking (on kernel events)
    www.devreach.com
ETW Kernel Providers
•    Hardware Configuration Events
•    Disk-level I/O
•    File-level I/O
•    Image Layouts
•    Page Faults
•    Network I/O
•    Registry I/O
•    Process and Thread info
    www.devreach.com
ETW Application Providers
•    Windows Firewall
•    WLAN, LAN
•    USB, Bluetooth
•    IIS, ASP.NET, CLR, HTTP.SYS
•    Security
•    … many more



    www.devreach.com
ETW Demo




www.devreach.com
Side note: Symbols
• _NT_SYMBOL_PATH=SRV*c:mss*http://
  msdl.microsoft.com/download/symbols
• Call stack information
• Private managed code fields
• Link to source code repository




www.devreach.com
Concurrency Visualizer
•    Utilization
•    Threads
•    Cores
•    Stack Walking




    www.devreach.com
Trace Analysis
                              Profiler


                             Our code


                    CLR         COM          WinRT
                                                     Windows
  Event
                             Win32 API                 Perf
 Tracing
                                                     Counters
    for                   Operating System

Windows
                   HDD    RAM      CPU        LAN      CPU
                                                     Counters


www.devreach.com
Profiler
•    Instrumentation
•    Sampling
•    Concurrency
•    Stack Walking




    www.devreach.com
Profiler setup
• There can be only one
• Uses environment variables
   – COR_ENABLE_PROFILING
   – COR_PROFILER
   – COR_XXX…
• Profiler API



www.devreach.com
Instrumentation
•    Profiler based
•    Requires full code recompilation
•    Best during development phase
•    Complete execution path




    www.devreach.com
Sampling
•    Profiler based
•    Data collection on sample intervals
•    Suitable for long runs
•    Call Stack




    www.devreach.com
Concurrency
• Show resource contention
• Based on Detours
• Microsoft Research project now sold for
  $10k
• http://research.microsoft.com/en-us/projects/detours/
• Stack Walking



 www.devreach.com
Profiling extras
•    GC, Allocation
•    Tier Interaction
•    JavaScript
•    Production use
•    Licensing




    www.devreach.com
Profiler Demo




www.devreach.com
Thank you!
   @kulov
   www.kulov.net
   www.linkedin.com/in/kulov




Martin Kulov | kulov.net
  www.devreach.com

Demystifying Visual Studio 2012 Performance Tools

  • 1.
    Demystifying Visual Studio 2012Performance Tools Martin Kulov | kulov.net www.devreach.com
  • 2.
    You cannot manage, Whatyou do not measure www.devreach.com
  • 3.
    You cannot Improve, Whatyou do not measure www.devreach.com
  • 4.
    Trace Analysis Our code CLR COM WinRT Win32 API Operating System HDD RAM CPU LAN CPU Counters www.devreach.com
  • 5.
    CPU Counters • Hardwareevents – portable and platform – Instructions Retired – Non Halted Cycles – ITLB Misses – Branches Retired – Mis-predicted Branches – L2 Cache Read Misses – L2 Cache Read References www.devreach.com
  • 6.
    Trace Analysis Our code CLR COM WinRT Windows Win32 API Perf Counters Operating System HDD RAM CPU LAN CPU Counters www.devreach.com
  • 7.
    Windows Performance Counters • They are …counters • Min interval – 1sec • Apps and kernel send Increment signals • Accessed by Windows API www.devreach.com
  • 8.
  • 9.
    Trace Analysis Our code CLR COM WinRT Windows Event Win32 API Perf Tracing Counters for Operating System Windows HDD RAM CPU LAN CPU Counters www.devreach.com
  • 10.
    Event Tracing forWindows • General purpose, high speed tracing • Buffering and logging in kernel • Faster than printf – 20,000 events per second while only using 5% CPU load on a P3 500MHz! • Provider, Consumer, Controller model • Over 700 providers in Win7, ~900 in Win8! • Aggregates all sources • Stack walking (on kernel events) www.devreach.com
  • 11.
    ETW Kernel Providers • Hardware Configuration Events • Disk-level I/O • File-level I/O • Image Layouts • Page Faults • Network I/O • Registry I/O • Process and Thread info www.devreach.com
  • 12.
    ETW Application Providers • Windows Firewall • WLAN, LAN • USB, Bluetooth • IIS, ASP.NET, CLR, HTTP.SYS • Security • … many more www.devreach.com
  • 13.
  • 14.
    Side note: Symbols •_NT_SYMBOL_PATH=SRV*c:mss*http:// msdl.microsoft.com/download/symbols • Call stack information • Private managed code fields • Link to source code repository www.devreach.com
  • 15.
    Concurrency Visualizer • Utilization • Threads • Cores • Stack Walking www.devreach.com
  • 16.
    Trace Analysis Profiler Our code CLR COM WinRT Windows Event Win32 API Perf Tracing Counters for Operating System Windows HDD RAM CPU LAN CPU Counters www.devreach.com
  • 17.
    Profiler • Instrumentation • Sampling • Concurrency • Stack Walking www.devreach.com
  • 18.
    Profiler setup • Therecan be only one • Uses environment variables – COR_ENABLE_PROFILING – COR_PROFILER – COR_XXX… • Profiler API www.devreach.com
  • 19.
    Instrumentation • Profiler based • Requires full code recompilation • Best during development phase • Complete execution path www.devreach.com
  • 20.
    Sampling • Profiler based • Data collection on sample intervals • Suitable for long runs • Call Stack www.devreach.com
  • 21.
    Concurrency • Show resourcecontention • Based on Detours • Microsoft Research project now sold for $10k • http://research.microsoft.com/en-us/projects/detours/ • Stack Walking www.devreach.com
  • 22.
    Profiling extras • GC, Allocation • Tier Interaction • JavaScript • Production use • Licensing www.devreach.com
  • 23.
  • 24.
    Thank you! @kulov www.kulov.net www.linkedin.com/in/kulov Martin Kulov | kulov.net www.devreach.com

Editor's Notes

  • #12 Hardware configuration events CPUs, hard drives, NICs, video card, and ACPI power statesDisk-level I/O every I/O on the system, IRP flags, operation time in ms, number of bytes, diskFile-level I/O every access to every file on the system (tie it to the disk I/Os above)Image layoutsfilenames, locations in memory, and PIDs for every image in the systemPage faultspointers to instructions and pages whenever a fault occursNetwork I/O all TCP and UDP actions, including connects/accepts, transmits, recieves, etc.Registry I/O all Registry key/value creation/deletions/changes, registry flushes, etc.Process and thread info all creations/deletions of processes and threads