How to Build High Performing.NET Applications Vance Morrison.NET Performance Architect July 2009.

Slides:



Advertisements
Similar presentations
Module 13: Performance Tuning. Overview Performance tuning methodologies Instance level Database level Application level Overview of tools and techniques.
Advertisements

Virtual Memory Operating System Concepts chapter 9 CS 355
May 7, A Real Problem  What if you wanted to run a program that needs more memory than you have?
Copyright © 2003, SAS Institute Inc. All rights reserved. Where's Waldo Uncovering Hard-to-Find Application Killers Claire Cates SAS Institute, Inc
Chapter 6 Limited Direct Execution
Project 4 U-Pick – A Project of Your Own Design Proposal Due: April 14 th (earlier ok) Project Due: April 25 th.
Tools for Investigating Graphics System Performance
1 CSSE 477 – A bit more on Performance Steve Chenoweth Friday, 9/9/11 Week 1, Day 2 Right – Googling for “Performance” gets you everything from Lady Gaga.
Overview Of Microsoft New Technology ENTER. Processing....
Chapter 14 Chapter 14: Server Monitoring and Optimization.
Tiny OS Optimistic Lightweight Interrupt Handler Simon Yau Alan Shieh
Copyright © 1998 Wanda Kunkle Computer Organization 1 Chapter 2.1 Introduction.
EET 4250: Chapter 1 Performance Measurement, Instruction Count & CPI Acknowledgements: Some slides and lecture notes for this course adapted from Prof.
CS4315A. Berrached:CMS:UHD1 Operating System Structures Chapter 3.
Patterns & practices Designing For Performance (For.NET) Vance Morrison Performance Architect.NET Runtime Team.
Basics of Operating Systems March 4, 2001 Adapted from Operating Systems Lecture Notes, Copyright 1997 Martin C. Rinard.
Microsoft ® Official Course Monitoring and Troubleshooting Custom SharePoint Solutions SharePoint Practice Microsoft SharePoint 2013.
CPU PROFILING FIND THE BOTTLENECK. WHAT? WHEN? HOW?
Microsoft Visual Basic 2012 CHAPTER ONE Introduction to Visual Basic 2012 Programming.
Microsoft Visual Basic 2005 CHAPTER 1 Introduction to Visual Basic 2005 Programming.
Chapter 3 Memory Management: Virtual Memory
Chocolate Bar! luqili. Milestone 3 Speed 11% of final mark 7%: path quality and speed –Some cleverness required for full marks –Implement some A* techniques.
Introduction Optimizing Application Performance with Pinpoint Accuracy What every IT Executive, Administrator & Developer Needs to Know.
MapReduce April 2012 Extract from various presentations: Sudarshan, Chungnam, Teradata Aster, …
Improving Efficiency of I/O Bound Systems More Memory, Better Caching Newer and Faster Disk Drives Set Object Access (SETOBJACC) Reorganize (RGZPFM) w/
Presentation: SOAP/WS in a distributed object framework, Application Servers & AXIS SOAP.
Buffered dynamic run-time profiling of arbitrary data for Virtual Machines which employ interpreter and Just-In-Time (JIT) compiler Compiler workshop ’08.
Lecture Topics: 11/17 Page tables TLBs Virtual memory flat page tables
An Introduction to Visual Basic.NET. What is.NET.Net is a new framework for developing windows-based and web-based applications within the Microsoft environment.
Presentation: SOAP/WS in a distributed object framework, Application Servers & AXIS SOAP.
CE Operating Systems Lecture 3 Overview of OS functions and structure.
Sofia, Bulgaria | 9-10 October Troubleshooting Web Site Performance Issues with Visual Studio Team System Martin Kulov Director,.NET Development National.
Debugging and Profiling With some help from Software Carpentry resources.
Framework for MDO Studies Amitay Isaacs Center for Aerospace System Design and Engineering IIT Bombay.
ITC Research Computing Support Using Matlab Effectively By: Ed Hall Research Computing Support Center Phone: Φ Fax:
Chapter 1 Computer Abstractions and Technology. Chapter 1 — Computer Abstractions and Technology — 2 The Computer Revolution Progress in computer technology.
Operating Systems Lecture 14 Segments Adapted from Operating Systems Lecture Notes, Copyright 1997 Martin C. Rinard. Zhiqing Liu School of Software Engineering.
CF Performance Tuning Matt Liotta President & CEO Montara Software, Inc.
Ben Watson Principal Software Engineer Shared Platform Group, Application Services Group, Microsoft Author, Writing High-Performance.NET Code.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts Essentials – 9 th Edition Chapter 9: Virtual-Memory Management.
Full and Para Virtualization
Tips & Tricks: Writing Performant Managed Code Rico Mariani FUNL04 Performance Architect Microsoft Corporation.
Software Quality Assurance and Testing Fazal Rehman Shamil.
Efficient Software-Based Fault Isolation Authors: Robert Wahbe Steven Lucco Thomas E. Anderson Susan L. Graham Presenter: Gregory Netland.
Microsoft Visual Basic 2015 CHAPTER ONE Introduction to Visual Basic 2015 Programming.
The Anatomy of a Large-Scale Hypertextual Web Search Engine S. Brin and L. Page, Computer Networks and ISDN Systems, Vol. 30, No. 1-7, pages , April.
Chapter 6 Limited Direct Execution Chien-Chung Shen CIS/UD
Beyond Application Profiling to System Aware Analysis Elena Laskavaia, QNX Bill Graham, QNX.
Introduction to Operating Systems
Introduction to Visual Basic 2008 Programming
A Real Problem What if you wanted to run a program that needs more memory than you have? September 11, 2018.
Chapter 9: Virtual Memory – Part I
Applying Control Theory to Stream Processing Systems
Outline SOAP and Web Services in relation to Distributed Objects
Outline What does the OS protect? Authentication for operating systems
Outline SOAP and Web Services in relation to Distributed Objects
Outline What does the OS protect? Authentication for operating systems
Introduction to Operating Systems
O.S Lecture 13 Virtual Memory.
PerfView Measure and Improve Your App’s Performance for Free
CIS16 Application Development – Programming with Visual Basic
Intro. To Operating Systems
CPU scheduling decisions may take place when a process:
CSE 451: Operating Systems Autumn 2003 Lecture 10 Paging & TLBs
CSE 451: Operating Systems Autumn 2003 Lecture 10 Paging & TLBs
Why Threads Are A Bad Idea (for most purposes)
Why Threads Are A Bad Idea (for most purposes)
Why Threads Are A Bad Idea (for most purposes)
Cache writes and examples
Dependency Architecture
Presentation transcript:

How to Build High Performing.NET Applications Vance Morrison.NET Performance Architect July 2009

Microsoft Engineering Excellence Microsoft Confidential Writing High Performance Apps The Bad News High Performance Doesn’t Just Happen! You Have to Design Them That Way! Most Performance is Lost Very Early in the Design Performance Lost Early Can Never be Regained Most Designs Consider Perf too Late in Development The Good News Most (e.g. 95%) of Your App is Not Perf Critical Generally it is easy to identify the ‘Hot Spots’

Microsoft Engineering Excellence Microsoft Confidential Have a Plan ALL Applications need a Performance Plan Perf Plans Can Be Easy! Perf Plans Can Be Easy! 1. Decide what Good Performance Means 2. Determine the Perf Critical Parts 3. Determine if Good Perf is in Jeopardy If Perf is not in Jeopardy, you are Done! You don’t even need to write it down necessarily Otherwise you have more work to do.

Microsoft Engineering Excellence Microsoft Confidential Measure Early, Measure Often Can you Meet your perf Goals? You MUST Measure to do this Evaluating Alternatives Evaluating Alternatives You MUST Measure to do this Tradeoffs Against Other Goals You MUST Measure to do this If you aren’t measuring, you are not designing high performance software!

Microsoft Engineering Excellence Microsoft Confidential Example: ETW Event Log Parsing Problem: Event Tracing for Windows (ETW), can create detailed logs Event Tracing for Windows (ETW), can create detailed logs The logs are large (10Meg to > 10 Gig) The logs are large (10Meg to > 10 Gig) How users may want to manipulate the data varies widely How users may want to manipulate the data varies widely Solution: Solution: We need a programmatic way of access the data (Data Model) We need a programmatic way of access the data (Data Model) That model needs to be ‘User Centric’ (Easy to understand) That model needs to be ‘User Centric’ (Easy to understand) It has to handle the wide variety of ETW data It has to handle the wide variety of ETW data It has to scale to the data set sizes involved. It has to scale to the data set sizes involved. Design a High Performance Solution

Microsoft Engineering Excellence Microsoft Confidential Event Log Parsing Performance Plan What is Good Performance? < 1 sec for small traces (10MB), < 10sec medium (100MB). What are the hot spots? Any code path that ‘touches’ the whole data stream Disk I/O is likely to be a bottleneck Is Good Performance in Jeopardy? Yes Is Good Performance Possible? Is Good Performance Possible? Probably: 50MB / sec Disk I/O throughput possible. Probably: 50MB / sec Disk I/O throughput possible.

Microsoft Engineering Excellence Microsoft Confidential Event Log Parsing Design Issues Should a Database be used to store the Data? No => Databases relatively poor at ADDING large amounts of data How did I know? I Measured it! Should In-memory structures be used? No => excessive paging for large data sizes, 32bit limitation. Should a Managed Language be used? Yes => Hot code path not limited by managed code. Should we use a ‘classic’ foreach() Event model? No => Requires an allocation per event, which is unnecessary Should value types or object be used? Objects, otherwise we are constrained to a callback model.

Microsoft Engineering Excellence Microsoft Confidential OK, I Will Measure: How? One of the simplest ways, is simply to measure time System.Diagnositics.StopWatch is a high resolution timer Managed interface to QueryPerformanceCounter Typically a resolution < 1usec. Stopwatch sw = new Stopwatch(); sw.Start(); // Code you wish to measure // Code you wish to measuresw.Stop(); Console.WriteLine("Time = {0} msec", sw.Elapsed.Milliseconds); sw.Reset(); // Set up for the next measurement

Microsoft Engineering Excellence Microsoft Confidential Improving on Stopwatch For microbenchmarks, Stopwatch is Inconvinient For microbenchmarks, Stopwatch is Inconvinient Small times need to be ‘amplified’ by putting in loops Small times need to be ‘amplified’ by putting in loops Subtract out Stopwatch overhead Subtract out Stopwatch overhead ‘First time’ (JIT compilation) costs are not interesting ‘First time’ (JIT compilation) costs are not interesting Need to run several times and gather statistics Need to run several times and gather statistics Want an easy reporting mechanism for comparisons Want an easy reporting mechanism for comparisons

Microsoft Engineering Excellence Microsoft Confidential MeasureIt MicroBenchmark Tool Available in April 2008 MSDN article. CLR Inside Out: Measure Early and Often for Performance A Single Executable Comes with User’s Guide MeasureIt /UsersGuide Comes with its source code. Comes with built-in benchmarks Easy to add your own

Microsoft Engineering Excellence Microsoft Confidential MeasureIt Output

Microsoft Engineering Excellence Microsoft Confidential Measuring More ETW + XPERF Event Tracing for Windows (ETW) logging service Window’s Kernel provides a wealth of information Every Process creation / destruction Samples of what the CPU is doing every msec per CPU Every Disk access Every Page fault / Module Load Every File I/O Full Stack traces on kernel events CLR adds its own When GCs happen, how big the heap is before and after When modules are loaded / unloaded, When JIT compilations happens You can add to the events too XPERF is the tool used to view all this wonderful information

Microsoft Engineering Excellence Microsoft Confidential Summary High Performance Apps Don’t Happen by Accident You need a Performance Plan To Plan you need Measurements Can you hit your goals? Evaluate different implementation techniques Trade off performance against other goals in a rational manner MeasureIt is useful for micro-benchmarking Comes with useful.NET benchmarks ‘out of the box’ Comes with its complete source code Easy to add new benchmarks in an area of interest Measurements Need to Validated It is very easy to measure the wrong thing or misapply the result Don’t use numbers that don’t ‘Make sense’. Figure them out!

Microsoft Engineering Excellence Microsoft Confidential To Learn More Articles Vance Morrison's MSDN articles Vance Morrison's MSDN articles The Fallacy of Premature Optimization (Randall Hyde, ACM.org) The Fallacy of Premature Optimization (Randall Hyde, ACM.org) MSDN Performance: Designing Distributed Applications MSDN Performance: Designing Distributed Applications The Ten Rules of Performance The Ten Rules of Performance Improving.NET Application Performance and Scalability Improving.NET Application Performance and ScalabilityBlogs Vance Morrison's Weblog Vance Morrison's Weblog Rico Mariani's Performance Tidbits Rico Mariani's Performance Tidbits CLR and Framework Perf Blog CLR and Framework Perf Blog Xperf Blog Xperf BlogTools MeasureIt Xperf performance analysis tool Xperf performance analysis tool

Questions?