1 / 43

Deep dive into the kernel of the .NET Framework

TOOL-813T. Deep dive into the kernel of the .NET Framework. Mark Miller Pracheeti Nagarkar Senior SDET Program Manager II .NET Core Platform Team Microsoft Corporation. Quick Reminder – What Is The CLR. Entity Frame-work. ASP. NET. WCF. WPF. Win Forms. Work Flow. And more!.

lan
Download Presentation

Deep dive into the kernel of the .NET Framework

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. TOOL-813T Deep dive into the kernel of the .NET Framework Mark Miller Pracheeti Nagarkar Senior SDET Program Manager II .NET Core Platform Team Microsoft Corporation

  2. Quick Reminder – What Is The CLR Entity Frame-work ASP. NET WCF WPF Win Forms Work Flow And more! The CLR Base Class Libraries Profiling& Debugging APIs JIT & NGEN Garbage Collector Security Model Exception Handling Loader & Binder

  3. Agenda slide WHO WILL BENEFIT FROM THIS TALK TOPICS WHAT YOU’LL LEAVE WITH • What’s new in the 4.5 CLR • How you can leverage it • Performance Improvements to CLR in .NET Framework 4.5 • GC • Managed Profile Guided Optimizations • Automatic NGen • Multi-core JIT • Diagnostics Improvements to CLR in .NET Framework 4.5 • Re-JIT • .NET Developers

  4. Improvements to the Garbage Collector

  5. Generation 1 Generation 0 Quick Reminder – GC Fundamentals Roots Heap • New objects allocated as Generation 0 • Accessible References Keep Objects Alive • GC Compacts Referenced Objects • Objects Promoted to Older Generation

  6. Quick Reminder – GC Fundamentals • 2 Modes: Client (default) and Server • Heaps • Collection Flavors

  7. Quick Reminder - Server Mode (4.0) • (.NET 4.0) Maximizes application scalability

  8. Background GC For Server Mode (New in 4.5)Performance: Reduces pause times (Desktop apps) • (.NET 4.5) Gen0/Gen1 collections can proceed during Gen2 GC

  9. Other GC ImprovementsPerformance • (Server GC) Scalable Marking for full blocking GCs • Large Object Heap Allocation Improvements • Better use of free space on LOH • (Server only) Balancing the LOH allocations across processors • … And More! LEARN MORE http://blogs.msdn.com/b/clrteam/ “Enhancements to the CLR GC in .NET 4.5”

  10. Managed Profile Guided Optimization for .NET Apps

  11. Problems Memory usage Startup Time

  12. Managed Profile Guided OptimizationPerformance: Improves startup time, memory usage (All apps) • Let’s reduce the number of pages loaded from disk. • Let’s reduce the number of copy-on-write pages. Hot Hot Copy on Write HOT Copy on Write

  13. Managed Profile Guided OptimizationPerformance: Improves startup and execution time (All apps) Hot/Cold Hot/Cold Read-Only/Write DATA CLR Data Structures, Metadata CODE Basic Blocks

  14. Managed Profile Guided OptimizationPerformance: Improves startup and execution time (All apps) BUILD SETUP RUN • Identify Scenario • Generate Profile Data • Embed data into IL • Generate Native Image • Page density improved • Lower memory use

  15. Managed Profile Guided OptimizationUsage of MPGO.exe • MPGO –scenario “MyTax.exe /params foo” –AssemblyList“Mytax.dll MyTaxUtil2011.dll” –OutDir “C:\Optimized” –TimeOut 15 • MPGO –scenario “wav2wma.exe –input song1.wav –output song1.wma” –AssemblyList“transcode.dll” –OutDir “C:\Optimized” –TimeOut 15 LEARN MORE http://blogs.msdn.com/b/clrteam/

  16. video Using Managed Profile Guided Optimization on a .NET App

  17. Automatic NGen

  18. Problems .NET Framework Install Size Difficult Setup Authoring Managed Metro style app performance

  19. Solution: Reduce NGened assemblies .NET 3.5 .Net 3.5 .Net 4.5 .NET 4.5 .NET 3.5 .NET 4.5 Full .NET Framework NGened Frequent Set NGened

  20. Classic NGen model App Run • Native Images Created • Native Images Used • Native Images Removed App Install App Uninstall

  21. Automatic NGen model App Execute (MyApp.exe) App Execute App Execute Native Image Cache Assembly Image Usage Logs MyApp.ni.exe MyApp.exe OtherApp.ni.exe Auto Ngen Maintenance Task

  22. Automatic NGen • Windows 8 only • .NET 3.5 – Framework Only • .NET 4.5 • Desktop app – Only assemblies in the GAC • Metro style app – All assemblies eligible

  23. Multi-Core Background JIT

  24. Problems Startup matters JITing takes time Unused resources

  25. Multi-Core Background JITPerformance: Improves startup time (Desktop apps) First Launch Subsequent Launch Executed Methods Profile

  26. Multi-Core Background JITApps and Hosts need to opt-in • using System.Runtime; • public static void Main(string[] args) • { • // Security Critical APIs • ProfileOptimization.SetProfileRoot(Config.GetAppPath); • ProfileOptimization.StartProfile("App1_Startup.prof"); • }

  27. ~10% startup time improvementAutomatically Enabled in ASP.net and Silverlight 5 Applications

  28. Re-JIT No-restart production monitoring

  29. Problems Production monitoring Instrumentation adds overhead Requires app restart LEARN MORE (792) Advanced IntelliTrace and using IntelliTrace in Production with Visual Studio 11

  30. Instrumenting code with profiler • .method private hidebysig instance void InitiateTransaction() cil managed • { • .maxstack 8 • ldstr"TxnsInProgress" • call void ProductionMonitoring::IncrementTelemetry(string)ldarg.0 • newobjinstance voidCustomTransaction::.ctor() • stfldclass CustomTransaction App::m_CurrentTxn • ldarg.0 • ldfldclass CustomTransaction App::m_CurrentTxn • ldarg.0 • ldfldobjectApp::m_CurrentEnvironment • callvirtinstance void CustomTransaction::Initialize(object) • ret • }

  31. Production MonitoringToday (.NET 4) Process start Process restart Process restart Instrumentation Problem detected Instrumentation Diagnose Instrumentation App runs

  32. Production MonitoringWith Re-JIT

  33. Re-JIT code • ICorProfilerInfo::SetEventMask(COR_PRF_ENABLE_REJIT • | COR_PRF_DISABLE_ALL_NGEN_IMAGES); • HRESULT ICorProfilerInfo4::RequestReJIT(ULONG cFunctions, • ModuleIDmoduleIds[], • mdMethodDefmethodIds[]); • HRESULT ICorProfilerCallback4:GetReJITParameters( • ModuleIDmoduleId, • mdMethodDefmethodId, • ICorProfilerFunctionControl*pFunctionControl); • HRESULT ICorProfilerFunctionControl::SetILFunctionBody( • LPCBYTE pbNewIL, ULONG cbNewIL);

  34. Review

  35. Background GC available for Server Mode

  36. Managed Profile Guided Optimizations are available for .NET Apps

  37. Automatic NGen is Automatic!

  38. ASP.net and SL5 use the new Multi-Core Background JIT

  39. Production Monitoring no longer requires app-restarts

  40. “For more information” Slide RELATED SESSIONS DOCUMENTATION & ARTICLES CLR Team Blog: http://blogs.msdn.com/b/clrteam/ (TOOL-834T) What's new in .NET Framework 4.5 (TOOL-930C) A .NET developer's view of Windows 8 app development [chalk talk] (TOOL-810T) Async made simple in Windows 8, with C# and Visual Basic (TOOL-792T) Advanced IntelliTrace in production with Visual Studio 11

  41. thank you Feedback and questions http://forums.dev.windows.com Session feedbackhttp://bldw.in/SessionFeedback

  42. © 2011 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

More Related