SlideShare a Scribd company logo
1 of 74
Ben Watson
Principal Software Engineer
Shared Platform Group, Application Services Group, Microsoft
Author, Writing High-Performance .NET Code
InfoQ.com: News & Community Site
• 750,000 unique visitors/month
• Published in 4 languages (English, Chinese, Japanese and Brazilian
Portuguese)
• Post content from our QCon conferences
• News 15-20 / week
• Articles 3-4 / week
• Presentations (videos) 12-15 / week
• Interviews 2-3 / week
• Books 1 / month
Watch the video with slide
synchronization on InfoQ.com!
http://www.infoq.com/presentations
/bing-net-performance
Purpose of QCon
- to empower software development by facilitating the spread of
knowledge and innovation
Strategy
- practitioner-driven conference designed for YOU: influencers of
change and innovation in your teams
- speakers and topics driving the evolution and innovation
- connecting and catalyzing the influencers and innovators
Highlights
- attended by more than 12,000 delegates since 2007
- held in 9 cities worldwide
Presented at QCon San Francisco
www.qconsf.com
Why Managed Code?
Benefits of .NET
Isolation and safety
Easy testing
Debugging
Code is easy to write*
GC JIT 3rd Party Code People Factors
Garbage Collection
Stops your program DEAD
The Threat
It’s very easy to build a system that spends an extraordinary
amount of time in GC.
This is not inherent to the CLR!
It is impossible to build a low-latency, high-
performance server without taking GC into
account from the beginning.
It is a myth that you can’t control the GC – you do so by
controlling allocations.
You need to understand the inner workings of the GC, just
like you would any memory allocator.
Generational GC in 30 seconds
Gen2 Gen1 Gen0
Allocation
point
Lessons Learned
Objects must die in a gen0 GC
- or –
They must live forever in gen2.
You will usually want to optimize for as little memory
allocation as possible.
The cost of a GC is proportional to the number of surviving
objects.
Consider pooling for objects with a long or unknown lifetime.
Pool everything in the large object heap.
github.com/Microsoft/Microsoft.IO.RecyclableMemoryStream
GC work never stops
Just In Time Compilation
Just in time to SLOW YOU DOWN
Should you worry about JIT?
The Threat
Reduce the amount of Code
Use the latest .NET
Warmup Code
Manual JIT
RuntimeHelpers.PrepareMethod
NGEN
A little of this, a little of that…
3rd Party Code
Trust No One
My Code vs. Your Code
Joking aside…
The Threat
The Framework Class Library
How would you implement Enum.HasFlag()?
Read the Source
Default collection sizes
Quiz: How many different XML serialization options ship with
.NET?
XmlTextReader
XmlValidatingReader
XDocument
XPathNavigator
XPathDocument
LINQ-to-XML
DataContractSerializer
XmlSerializer
Methods that throw exceptions in normal conditions.
Static analysis
FxCop
Stupid String Tricks: ToLower, ToUpper, Format, Join
FxCop
Stupid String Tricks: ToLower, ToUpper, Format, Join
Large Static Allocations (>85K go on LOH)
FxCop
Stupid String Tricks: ToLower, ToUpper, Format, Join
Large Static Allocations (>85K go on LOH)
Prevent finalizers
FxCop
Stupid String Tricks: ToLower, ToUpper, Format, Join
Large Static Allocations (>85K go on LOH)
Force use of pooling APIs for some types
Prevent finalizers
FxCop
Stupid String Tricks: ToLower, ToUpper, Format, Join
Large Static Allocations (>85K go on LOH)
Prevent finalizers
Warn against LINQ
Force use of pooling APIs for some types
It looks like you’re
writing awful, poorly
performing code.
Would you like to stop
already?
Projects like
RoslynClrHeapAllocationAnalyzer
This is the future…
(note: Clippy not actually included)
People Factors
(No, you can’t actually use a
hammer and sword.)
You must train people
Code does not exist in a vacuum
Understand the Tradeoffs
Understand the Tradeoffs
It is impossible to build a low-latency, high-
performance server without taking GC into
account from the beginning.
Performance is a Feature
GC JIT 3rd Party Code People Factors
Want to know more?
Thursday, 9am, Garden A
Resources
• Books
• Writing High-Performance .NET Code
• Book Site – Can get the following for free:
• Intro, Chapter 1 – general measurement guidelines, tools, how to use Windbg
and PerfView (and others)
• Chapter 5 – Performance Considerations of Class Design and General Coding
• Advanced .NET Debugging by Mario Hewardt
• Article: .NET memory allocation details
Resources
• Vance Morrison’s CLR Inside Out columns on performance: Measure Early and Often for
Performance, Parts 1 & 2
• http://msdn.microsoft.com/en-us/magazine/cc500596.aspx
• http://msdn.microsoft.com/en-us/magazine/cc507639.aspx
• Interface Dispatch: http://blogs.msdn.com/b/vancem/archive/2006/03/13/550529.aspx
• SOS command reference
• http://msdn.microsoft.com/en-us/library/bb190764.aspx
• Windbg command reference
• http://windbg.info/doc/1-common-cmds.html
Tools
• Reflector, ILSpy, ILDASM – tools to convert compiled binaries into readable code. Essential
for understanding how 3rd-party code (including the FCL) works.
• FxCop
• Performance rules are limited, but useful
• Warns about things like multiple casts, Equals() on value types, empty finalizers, etc.
• Lots of other style and correctness rules
• Get in the habit of running these as part of your build
• DON’T get in the habit of issuing exceptions for rule violations -- just fix the issue if
possible
Tools
• MeasureIt
• Small, simple tool for running microbenchmarks on the .Net framework
• http://blogs.msdn.com/b/vancem/archive/2009/02/06/measureit-update-tool-for-doing-
microbenchmarks.aspx
• PerfView
• ETW event analyzer with clever views (like a CPU profiler)
• Can analyze both CPU and memory events
• Can tell you who is allocating memory, who owns memory, who is allocating on the LOH
• How often are GCs? How long do they last?
• Exceptions being thrown and handled
• Jitting events
• Anything else that’s an ETW event (which is most things)
Tools
• Windbg & SOS
• The best way in many cases to understand what’s really going on
• SOS is the managed debugging extensions
• Comes with CLR, already setup to work with WinDbg in PHX
• See http://msdn.microsoft.com/en-us/library/bb190764.aspx for SOS commands
• Getting started:
• Attach to your process
• .loadby sos clr
• !bpmd program.exe Namespace.Type.Method
• g
• !U @rip
• !ClrStack
Watch the video with slide synchronization on
InfoQ.com!
http://www.infoq.com/presentations/bing-net-
performance

More Related Content

Viewers also liked

How to Analyze Reports in Jmeter
How to Analyze Reports in JmeterHow to Analyze Reports in Jmeter
How to Analyze Reports in Jmeter
Viviana Lesmes
 
Chef Fundamentals Training Series Module 1: Overview of Chef
Chef Fundamentals Training Series Module 1: Overview of ChefChef Fundamentals Training Series Module 1: Overview of Chef
Chef Fundamentals Training Series Module 1: Overview of Chef
Chef Software, Inc.
 
DockerCon EU 2015: Continuous Integration with Jenkins, Docker and Compose
DockerCon EU 2015: Continuous Integration with Jenkins, Docker and ComposeDockerCon EU 2015: Continuous Integration with Jenkins, Docker and Compose
DockerCon EU 2015: Continuous Integration with Jenkins, Docker and Compose
Docker, Inc.
 

Viewers also liked (17)

How to Analyze Reports in Jmeter
How to Analyze Reports in JmeterHow to Analyze Reports in Jmeter
How to Analyze Reports in Jmeter
 
Continuous integration and delivery for java based web applications
Continuous integration and delivery for java based web applicationsContinuous integration and delivery for java based web applications
Continuous integration and delivery for java based web applications
 
Docker Overview - Rise of the Containers
Docker Overview - Rise of the ContainersDocker Overview - Rise of the Containers
Docker Overview - Rise of the Containers
 
How to start performance testing project
How to start performance testing projectHow to start performance testing project
How to start performance testing project
 
Continuous Integration using Docker & Jenkins
Continuous Integration using Docker & JenkinsContinuous Integration using Docker & Jenkins
Continuous Integration using Docker & Jenkins
 
Chef Fundamentals Training Series Module 1: Overview of Chef
Chef Fundamentals Training Series Module 1: Overview of ChefChef Fundamentals Training Series Module 1: Overview of Chef
Chef Fundamentals Training Series Module 1: Overview of Chef
 
Interpreting Performance Test Results
Interpreting Performance Test ResultsInterpreting Performance Test Results
Interpreting Performance Test Results
 
Jenkins Docker
Jenkins DockerJenkins Docker
Jenkins Docker
 
Chef for DevOps - an Introduction
Chef for DevOps - an IntroductionChef for DevOps - an Introduction
Chef for DevOps - an Introduction
 
Reduce DevOps Friction with Docker & Jenkins by Andy Pemberton, Cloudbees
Reduce DevOps Friction with Docker & Jenkins by Andy Pemberton, CloudbeesReduce DevOps Friction with Docker & Jenkins by Andy Pemberton, Cloudbees
Reduce DevOps Friction with Docker & Jenkins by Andy Pemberton, Cloudbees
 
Jenkins and Chef: Infrastructure CI and Automated Deployment
Jenkins and Chef: Infrastructure CI and Automated DeploymentJenkins and Chef: Infrastructure CI and Automated Deployment
Jenkins and Chef: Infrastructure CI and Automated Deployment
 
DockerCon EU 2015: Continuous Integration with Jenkins, Docker and Compose
DockerCon EU 2015: Continuous Integration with Jenkins, Docker and ComposeDockerCon EU 2015: Continuous Integration with Jenkins, Docker and Compose
DockerCon EU 2015: Continuous Integration with Jenkins, Docker and Compose
 
CLIF meets Jenkins: performance testing in continuous integration, or more......
CLIF meets Jenkins: performance testing in continuous integration, or more......CLIF meets Jenkins: performance testing in continuous integration, or more......
CLIF meets Jenkins: performance testing in continuous integration, or more......
 
Docker introduction
Docker introductionDocker introduction
Docker introduction
 
Scaling Jenkins with Docker and Kubernetes
Scaling Jenkins with Docker and KubernetesScaling Jenkins with Docker and Kubernetes
Scaling Jenkins with Docker and Kubernetes
 
Connecting With the Disconnected
Connecting With the DisconnectedConnecting With the Disconnected
Connecting With the Disconnected
 
Guided Reading: Making the Most of It
Guided Reading: Making the Most of ItGuided Reading: Making the Most of It
Guided Reading: Making the Most of It
 

More from C4Media

More from C4Media (20)

Streaming a Million Likes/Second: Real-Time Interactions on Live Video
Streaming a Million Likes/Second: Real-Time Interactions on Live VideoStreaming a Million Likes/Second: Real-Time Interactions on Live Video
Streaming a Million Likes/Second: Real-Time Interactions on Live Video
 
Next Generation Client APIs in Envoy Mobile
Next Generation Client APIs in Envoy MobileNext Generation Client APIs in Envoy Mobile
Next Generation Client APIs in Envoy Mobile
 
Software Teams and Teamwork Trends Report Q1 2020
Software Teams and Teamwork Trends Report Q1 2020Software Teams and Teamwork Trends Report Q1 2020
Software Teams and Teamwork Trends Report Q1 2020
 
Understand the Trade-offs Using Compilers for Java Applications
Understand the Trade-offs Using Compilers for Java ApplicationsUnderstand the Trade-offs Using Compilers for Java Applications
Understand the Trade-offs Using Compilers for Java Applications
 
Kafka Needs No Keeper
Kafka Needs No KeeperKafka Needs No Keeper
Kafka Needs No Keeper
 
High Performing Teams Act Like Owners
High Performing Teams Act Like OwnersHigh Performing Teams Act Like Owners
High Performing Teams Act Like Owners
 
Does Java Need Inline Types? What Project Valhalla Can Bring to Java
Does Java Need Inline Types? What Project Valhalla Can Bring to JavaDoes Java Need Inline Types? What Project Valhalla Can Bring to Java
Does Java Need Inline Types? What Project Valhalla Can Bring to Java
 
Service Meshes- The Ultimate Guide
Service Meshes- The Ultimate GuideService Meshes- The Ultimate Guide
Service Meshes- The Ultimate Guide
 
Shifting Left with Cloud Native CI/CD
Shifting Left with Cloud Native CI/CDShifting Left with Cloud Native CI/CD
Shifting Left with Cloud Native CI/CD
 
CI/CD for Machine Learning
CI/CD for Machine LearningCI/CD for Machine Learning
CI/CD for Machine Learning
 
Fault Tolerance at Speed
Fault Tolerance at SpeedFault Tolerance at Speed
Fault Tolerance at Speed
 
Architectures That Scale Deep - Regaining Control in Deep Systems
Architectures That Scale Deep - Regaining Control in Deep SystemsArchitectures That Scale Deep - Regaining Control in Deep Systems
Architectures That Scale Deep - Regaining Control in Deep Systems
 
ML in the Browser: Interactive Experiences with Tensorflow.js
ML in the Browser: Interactive Experiences with Tensorflow.jsML in the Browser: Interactive Experiences with Tensorflow.js
ML in the Browser: Interactive Experiences with Tensorflow.js
 
Build Your Own WebAssembly Compiler
Build Your Own WebAssembly CompilerBuild Your Own WebAssembly Compiler
Build Your Own WebAssembly Compiler
 
User & Device Identity for Microservices @ Netflix Scale
User & Device Identity for Microservices @ Netflix ScaleUser & Device Identity for Microservices @ Netflix Scale
User & Device Identity for Microservices @ Netflix Scale
 
Scaling Patterns for Netflix's Edge
Scaling Patterns for Netflix's EdgeScaling Patterns for Netflix's Edge
Scaling Patterns for Netflix's Edge
 
Make Your Electron App Feel at Home Everywhere
Make Your Electron App Feel at Home EverywhereMake Your Electron App Feel at Home Everywhere
Make Your Electron App Feel at Home Everywhere
 
The Talk You've Been Await-ing For
The Talk You've Been Await-ing ForThe Talk You've Been Await-ing For
The Talk You've Been Await-ing For
 
Future of Data Engineering
Future of Data EngineeringFuture of Data Engineering
Future of Data Engineering
 
Automated Testing for Terraform, Docker, Packer, Kubernetes, and More
Automated Testing for Terraform, Docker, Packer, Kubernetes, and MoreAutomated Testing for Terraform, Docker, Packer, Kubernetes, and More
Automated Testing for Terraform, Docker, Packer, Kubernetes, and More
 

Recently uploaded

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 

Recently uploaded (20)

WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 

Lessons in Extreme .NET Performance

  • 1. Ben Watson Principal Software Engineer Shared Platform Group, Application Services Group, Microsoft Author, Writing High-Performance .NET Code
  • 2. InfoQ.com: News & Community Site • 750,000 unique visitors/month • Published in 4 languages (English, Chinese, Japanese and Brazilian Portuguese) • Post content from our QCon conferences • News 15-20 / week • Articles 3-4 / week • Presentations (videos) 12-15 / week • Interviews 2-3 / week • Books 1 / month Watch the video with slide synchronization on InfoQ.com! http://www.infoq.com/presentations /bing-net-performance
  • 3. Purpose of QCon - to empower software development by facilitating the spread of knowledge and innovation Strategy - practitioner-driven conference designed for YOU: influencers of change and innovation in your teams - speakers and topics driving the evolution and innovation - connecting and catalyzing the influencers and innovators Highlights - attended by more than 12,000 delegates since 2007 - held in 9 cities worldwide Presented at QCon San Francisco www.qconsf.com
  • 4.
  • 5.
  • 7. Benefits of .NET Isolation and safety Easy testing Debugging Code is easy to write*
  • 8. GC JIT 3rd Party Code People Factors
  • 11. It’s very easy to build a system that spends an extraordinary amount of time in GC. This is not inherent to the CLR!
  • 12. It is impossible to build a low-latency, high- performance server without taking GC into account from the beginning.
  • 13. It is a myth that you can’t control the GC – you do so by controlling allocations.
  • 14. You need to understand the inner workings of the GC, just like you would any memory allocator.
  • 15. Generational GC in 30 seconds
  • 18. Objects must die in a gen0 GC - or – They must live forever in gen2.
  • 19. You will usually want to optimize for as little memory allocation as possible.
  • 20. The cost of a GC is proportional to the number of surviving objects.
  • 21. Consider pooling for objects with a long or unknown lifetime.
  • 22. Pool everything in the large object heap.
  • 24. GC work never stops
  • 25. Just In Time Compilation Just in time to SLOW YOU DOWN
  • 26. Should you worry about JIT?
  • 28. Reduce the amount of Code
  • 32. NGEN
  • 33. A little of this, a little of that…
  • 35. My Code vs. Your Code
  • 36.
  • 37.
  • 41. How would you implement Enum.HasFlag()?
  • 42.
  • 43.
  • 44.
  • 47. Quiz: How many different XML serialization options ship with .NET?
  • 49. Methods that throw exceptions in normal conditions.
  • 51. FxCop Stupid String Tricks: ToLower, ToUpper, Format, Join
  • 52. FxCop Stupid String Tricks: ToLower, ToUpper, Format, Join Large Static Allocations (>85K go on LOH)
  • 53. FxCop Stupid String Tricks: ToLower, ToUpper, Format, Join Large Static Allocations (>85K go on LOH) Prevent finalizers
  • 54. FxCop Stupid String Tricks: ToLower, ToUpper, Format, Join Large Static Allocations (>85K go on LOH) Force use of pooling APIs for some types Prevent finalizers
  • 55. FxCop Stupid String Tricks: ToLower, ToUpper, Format, Join Large Static Allocations (>85K go on LOH) Prevent finalizers Warn against LINQ Force use of pooling APIs for some types
  • 56. It looks like you’re writing awful, poorly performing code. Would you like to stop already? Projects like RoslynClrHeapAllocationAnalyzer This is the future… (note: Clippy not actually included)
  • 57. People Factors (No, you can’t actually use a hammer and sword.)
  • 58.
  • 59.
  • 60. You must train people
  • 61. Code does not exist in a vacuum
  • 64. It is impossible to build a low-latency, high- performance server without taking GC into account from the beginning.
  • 65. Performance is a Feature
  • 66. GC JIT 3rd Party Code People Factors
  • 67.
  • 68. Want to know more? Thursday, 9am, Garden A
  • 69. Resources • Books • Writing High-Performance .NET Code • Book Site – Can get the following for free: • Intro, Chapter 1 – general measurement guidelines, tools, how to use Windbg and PerfView (and others) • Chapter 5 – Performance Considerations of Class Design and General Coding • Advanced .NET Debugging by Mario Hewardt • Article: .NET memory allocation details
  • 70. Resources • Vance Morrison’s CLR Inside Out columns on performance: Measure Early and Often for Performance, Parts 1 & 2 • http://msdn.microsoft.com/en-us/magazine/cc500596.aspx • http://msdn.microsoft.com/en-us/magazine/cc507639.aspx • Interface Dispatch: http://blogs.msdn.com/b/vancem/archive/2006/03/13/550529.aspx • SOS command reference • http://msdn.microsoft.com/en-us/library/bb190764.aspx • Windbg command reference • http://windbg.info/doc/1-common-cmds.html
  • 71. Tools • Reflector, ILSpy, ILDASM – tools to convert compiled binaries into readable code. Essential for understanding how 3rd-party code (including the FCL) works. • FxCop • Performance rules are limited, but useful • Warns about things like multiple casts, Equals() on value types, empty finalizers, etc. • Lots of other style and correctness rules • Get in the habit of running these as part of your build • DON’T get in the habit of issuing exceptions for rule violations -- just fix the issue if possible
  • 72. Tools • MeasureIt • Small, simple tool for running microbenchmarks on the .Net framework • http://blogs.msdn.com/b/vancem/archive/2009/02/06/measureit-update-tool-for-doing- microbenchmarks.aspx • PerfView • ETW event analyzer with clever views (like a CPU profiler) • Can analyze both CPU and memory events • Can tell you who is allocating memory, who owns memory, who is allocating on the LOH • How often are GCs? How long do they last? • Exceptions being thrown and handled • Jitting events • Anything else that’s an ETW event (which is most things)
  • 73. Tools • Windbg & SOS • The best way in many cases to understand what’s really going on • SOS is the managed debugging extensions • Comes with CLR, already setup to work with WinDbg in PHX • See http://msdn.microsoft.com/en-us/library/bb190764.aspx for SOS commands • Getting started: • Attach to your process • .loadby sos clr • !bpmd program.exe Namespace.Type.Method • g • !U @rip • !ClrStack
  • 74. Watch the video with slide synchronization on InfoQ.com! http://www.infoq.com/presentations/bing-net- performance