.NET Garbage Collection Performance Tips Sasha Goldshtein | SELA Group.

Slides:



Advertisements
Similar presentations
An Implementation of Mostly- Copying GC on Ruby VM Tomoharu Ugawa The University of Electro-Communications, Japan.
Advertisements

Wenjin Xu. BasicsAllocationCollectionFinalization GC Mode Sample.
Automatic Memory Management Noam Rinetzky Schreiber 123A /seminar/seminar1415a.html.
CMSC 330: Organization of Programming Languages Memory and Garbage Collection.
Lecture 10: Heap Management CS 540 GMU Spring 2009.
CMSC 330: Organization of Programming Languages Memory and Garbage Collection.
MC 2 : High Performance GC for Memory-Constrained Environments - Narendran Sachindran, J. Eliot B. Moss, Emery D. Berger Sowmiya Chocka Narayanan.
Memory Management Tom Roeder CS fa. Motivation Recall unmanaged code eg C: { double* A = malloc(sizeof(double)*M*N); for(int i = 0; i < M*N; i++)
Garbage Collection. Memory Management So Far ● Some items are preallocated and persist throughout the program: ● What are they? Some are allocated on.
11 How to detect and avoid memory and resources leaks in.NET applications Fabrice MARGUERIE Independent.NET expert Microsoft MVP metaSapiens / Tuneo.
Understanding heap data Using Windows Performance Analyzer.
By Jacob SeligmannSteffen Grarup Presented By Leon Gendler Incremental Mature Garbage Collection Using the Train Algorithm.
MC 2 : High Performance GC for Memory-Constrained Environments N. Sachindran, E. Moss, E. Berger Ivan JibajaCS 395T *Some of the graphs are from presentation.
Log-Structured Memory for DRAM-Based Storage Stephen Rumble, Ankita Kejriwal, and John Ousterhout Stanford University.
CS 326 Programming Languages, Concepts and Implementation Instructor: Mircea Nicolescu Lecture 18.
Increasing Memory Usage in Real-Time GC Tobias Ritzau and Peter Fritzson Department of Computer and Information Science Linköpings universitet
CS 536 Spring Automatic Memory Management Lecture 24.
1 The Compressor: Concurrent, Incremental and Parallel Compaction. Haim Kermany and Erez Petrank Technion – Israel Institute of Technology.
This presentation: Sasha GoldshteinCTO, Sela Group Garbage Collection Performance Tips.
MOSTLY PARALLEL GARBAGE COLLECTION Authors : Hans J. Boehm Alan J. Demers Scott Shenker XEROX PARC Presented by:REVITAL SHABTAI.
Generational Stack Collection And Profile driven Pretenuring Perry Cheng Robert Harper Peter Lee Presented By Moti Alperovitch
Connectivity-Based Garbage Collection Presenter Feng Xian Author Martin Hirzel, et.al Published in OOPSLA’2003.
Runtime The optimized program is ready to run … What sorts of facilities are available at runtime.
Memory Allocation and Garbage Collection. Why Dynamic Memory? We cannot know memory requirements in advance when the program is written. We cannot know.
Age-Oriented Concurrent Garbage Collection Harel Paz, Erez Petrank – Technion, Israel Steve Blackburn – ANU, Australia April 05 Compiler Construction Scotland.
U NIVERSITY OF M ASSACHUSETTS A MHERST Department of Computer Science Garbage Collection Without Paging Matthew Hertz, Yi Feng, Emery Berger University.
1 An Efficient On-the-Fly Cycle Collection Harel Paz, Erez Petrank - Technion, Israel David F. Bacon, V. T. Rajan - IBM T.J. Watson Research Center Elliot.
Garbage collection (& Midterm Topics) David Walker COS 320.
Chapter 3.7 Memory and I/O Systems. 2 Memory Management Only applies to languages with explicit memory management (C or C++) Memory problems are one of.
1 Reducing Generational Copy Reserve Overhead with Fallback Compaction Phil McGachey and Antony L. Hosking June 2006.
G1 TUNING Shubham Modi( ) Ujjwal Kumar Singh(10772) Vaibhav(10780)
UniProcessor Garbage Collection Techniques Paul R. Wilson University of Texas Presented By Naomi Sapir Tel-Aviv University.
A Parallel, Real-Time Garbage Collector Author: Perry Cheng, Guy E. Blelloch Presenter: Jun Tao.
1 Overview Assignment 6: hints  Living with a garbage collector Assignment 5: solution  Garbage collection.
SEG Advanced Software Design and Reengineering TOPIC L Garbage Collection Algorithms.
CLR: Garbage Collection Inside Out
Virtual Memory Chantha Thoeun. Overview  Purpose:  Use the hard disk as an extension of RAM.  Increase the available address space of a process. 
Exploiting Prolific Types for Memory Management and Optimizations By Yefim Shuf et al.
Tutorial 6 Memory Management
1 Thread Synchronization (Un)Fairness in the.NET Common Language Runtime If you are building an application that absolutely requires fair thread synchronization,
Tutorial 7 Memory Management presented by: Antonio Maiorano Paul Di Marco.
Dynamic Memory Allocation Questions answered in this lecture: When is a stack appropriate? When is a heap? What are best-fit, first-fit, worst-fit, and.
Ulterior Reference Counting: Fast Garbage Collection without a Long Wait Author: Stephen M Blackburn Kathryn S McKinley Presenter: Jun Tao.
File I/O Applied Component-Based Software Engineering File I/O CSE 668 / ECE 668 Prof. Roger Crawfis.
Chapter 3.5 Memory and I/O Systems. 2 Memory Management Memory problems are one of the leading causes of bugs in programs (60-80%) MUCH worse in languages.
Copyright (c) 2004 Borys Bradel Myths and Realities: The Performance Impact of Garbage Collection Paper: Stephen M. Blackburn, Perry Cheng, and Kathryn.
1 Lecture 22 Garbage Collection Mark and Sweep, Stop and Copy, Reference Counting Ras Bodik Shaon Barman Thibaud Hottelier Hack Your Language! CS164: Introduction.
UniProcessor Garbage Collection Techniques Paul R. Wilson University of Texas Presented By Naomi Sapir Tel-Aviv University.
Ben Watson Principal Software Engineer Shared Platform Group, Application Services Group, Microsoft Author, Writing High-Performance.NET Code.
G ARBAGE C OLLECTION CSCE-531 Ankur Jain Neeraj Agrawal 1.
Pool Overview The Windows Pool has four basic allocation areas: Allocations that can be paged out of memory to the pagefile Paged Pool Allocations.
Runtime The optimized program is ready to run … What sorts of facilities are available at runtime.
Introduction to Garbage Collection. Garbage Collection It automatically reclaims memory occupied by objects that are no longer in use It frees the programmer.
“WALK IN” SLIDE. August Taming the CLR: How to Write Really Fast Managed Code Rico Mariani Architect Developer Division Performance Team Microsoft.
® July 21, 2004GC Summer School1 Cycles to Recycle: Copy GC Without Stopping the World The Sapphire Collector Richard L. Hudson J. Eliot B. Moss Originally.
GC Assertions: Using the Garbage Collector To Check Heap Properties Samuel Z. Guyer Tufts University Edward Aftandilian Tufts University.
Lecture 10 Page 1 CS 111 Online Memory Management CS 111 On-Line MS Program Operating Systems Peter Reiher.
.NET Memory Primer Martin Kulov. "Out of CPU, memory and disk, memory is typically the most important for overall system performance." Mark Russinovich.
GARBAGE COLLECTION Student: Jack Chang. Introduction Manual memory management Memory bugs Automatic memory management We know... A program can only use.
Immix: A Mark-Region Garbage Collector Jennifer Sartor CS395T Presentation Mar 2, 2009 Thanks to Steve for his Immix presentation from
Java 9: The Quest for Very Large Heaps
Memory Management 6/20/ :27 PM
Automatic Memory Management
Patrick Dussud Technical Fellow Developer Division
PerfView Measure and Improve Your App’s Performance for Free
Memory Management and Garbage Collection Hal Perkins Autumn 2011
Strategies for automatic memory management
Beltway: Getting Around Garbage Collection Gridlock
Created By: Asst. Prof. Ashish Shah, J.M.Patel College, Goregoan West
New GC collectors in Java 11
Presentation transcript:

.NET Garbage Collection Performance Tips Sasha Goldshtein | SELA Group

Why This Talk? The.NET GC is a complex beast Many performance optimizations over the years Still many ways to shoot yourself in the foot Mark and SweepGenerationsLOH Fragmentation HoardingSegments FinalizationBackground GC VMMapPerfView Server GC

Refresher: Tracing GC.NET GC is not based on reference counting GC starts from roots and marks reachable objects as “live” The rest of the heap is swept as garbage Usually holes are compacted and objects are moved around Allocations are very cheap

Problems? Naïve implementation blocks mutators Full GC is very slow (think multi-GB heaps) Result: very long application pauses

GC Flavors CLR 2.0 Workstation GC Concurrent, non- concurrent Server GC Parallel GC CLR 4.0 Workstation background GC CLR 4.5 Server concurrent and background GC DEMO

Generations Full GC is slow and very inefficient – most objects are live New objects die quickly, old objects die hard Divide the heap into regions, enabling partial collections – Tricky to deal with cross-generation references Special area for large objects (>85K)

Measurement Profile apps for allocations, not just time Look for large allocation sources Look for objects with a long lifetime Pool temporary large objects (cf. WCF BufferManager)BufferManager DEMOS

GC and Virtual Memory Windows VirtualAlloc has 64KB granularity in user-mode CLR allocates consecutive 16MB-64MB segments (x86) of memory On x86, easy to fragment the address space VMMap to detect, x64/VM hoarding to fix DEMO

Finalization Finalizer (cleanup) runs automatically after object becomes unreachable Performance problems and bugs: – Allocation/finalization rate – Race conditions, deadlocks – The finalizer may run while a method is still executing on an instance DEMO

Conclusions Minimize the number and size of allocations Strive to quickly kill temporary objects Pool temporary large objects Don’t use finalization. Just don’t use it We have only scratched the surface here! Pro.NET Performance: Maoni Stephens MSDN blog: Advanced.NET Debugging (Hewardt):

Thank blog.sashag.net Sasha Goldshtein | SELA Group Two free Pro.NET Performance eBooks! Send an to with an answer to the following question: What do you need to do for your console application to use background server GC in.NET 4.5?